一个antenna的打包j2me程序的脚本

2010/3/30 17:42:19
build.xml
<?xml version="1.0" encoding="UTF-8"?>

<!--
Author: Erik lu
Date: 2010-03-30
version: 1.0.1
change log:
1. 分拆为两个文件build和j2me_build_core. j2me_build_core中所有的内容都参数化了
-->

<project name="test" default="usage" basedir=".">
<!--
文件输出目录
输出结构
dist_
|preproc_output
|proj_1
|device1
|device2
|proj_2
|device1
|device2
|bin
|proj_1
|device1
|device2
|proj_2
|device1
|device2
|deploy
|proj_1
|device1
|device2
|proj_2
|device1
|device2
-->
<property name="dist" value="E:\hard\dist" />
<property name="wtk.home" value="D:\WTK2.5.2" />
<property name="path.antenna.jar" value="E:\\study\\antenna-bin-1.1.0-beta.jar" />
<property name="wtk.proguard.home" value="D:\\proguard4.3\\proguard4.3" />


<!--
假定项目目录里面有一个名字为Application Descriptor的jad文件
一般用MTJ插件生成的项目目录下都有这个文件
-->
<property name="descriptor.name" value="Application Descriptor" />
<property name="src.encoding" value="GBK" />
<property name="platform_om_lib" value="E:\\hard\\lib\\classes.zip" />
<property name="j2me.classpath" value="${wtk.home}\\lib\\cldcapi11.jar;${wtk.home}\\lib\\wma20.jar;${wtk.home}\\lib\\mmapi.jar;${wtk.home}\\lib\\j2me-ws.jar;${wtk.home}\\lib\\j2me-xmlrpc.jar;${wtk.home}\\lib\\jsr75.jar;${wtk.home}\\lib\\jsr082.jar;${wtk.home}\\lib\\jsr184.jar;${wtk.home}\\lib\\jsr179.jar;${wtk.home}\\lib\\satsa-apdu.jar;${wtk.home}\\lib\\satsa-jcrmi.jar;${wtk.home}\\lib\\satsa-pki.jar;${wtk.home}\\lib\\satsa-crypto.jar;${wtk.home}\\lib\\jsr211.jar;${wtk.home}\\lib\\jsr238.jar;${wtk.home}\\lib\\jsr229.jar;${wtk.home}\\lib\\jsr180.jar;${wtk.home}\\lib\\jsr234.jar;${wtk.home}\\lib\\jsr226.jar;${wtk.home}\\lib\\jsr239.jar;${platform_om_lib}" />
<property name="flag.preverify" value="true" />
<property name="wtk.midp.version" value="2.1" />
<property name="wtk.cldc.version" value="1.1" />

<!-- 预定义的一些变量 -->
<property name="_176X220_proproc_symbols" value="screen.width=176" />
<property name="_176X220_res_dir" value="176X220" />
<property name="_176X220_device" value="176X220" />

<property name="_240X320_proproc_symbols" value="screen.width=240" />
<property name="_240X320_res_dir" value="240X320" />
<property name="_240X320_device" value="240X320" />

<!-- 一下定义不好控制 build时引用的midp, cldc的版本,如果尝试建议手动列出 -->
<path id="j2me.lib">
<fileset dir="${wtk.home}\lib">
<include name="*.jar"/>
</fileset>
<!-- 其他开发商的特定包 -->
<path location="E:\\hard\\lib\\classes.zip"/>
</path>

<!--
程序用到的第三方jar包,将作源代码的一部分。
-->
<path id="classpath">
<path location="E:/hard/lib/kxml.jar"/>
</path>

<property name="third_lib" value="E:/hard/lib/BaseFrame.jar;E:/hard/lib/BaseTools.jar" />


<!-- Import the low-level targets -->
<import file="j2me_build_core.xml" />

<target name="usage" >
<echo message="usage ....." />
</target>

<target name="Antenna_init">
<echo message="Initializing MTJ Antenna build environment..."/>
<taskdef resource="antenna.properties">
<classpath location="${path.antenna.jar}"/>
</taskdef>
</target>

<!--
项目部署例子示例
-->
<target name="MobileLocation_deploy" description="depoly test project">
<!-- 部署 176X220版本 -->
<antcall target="deploy">
<param name="proj_name" value="MobileLocation" />
<param name="proj_dir" value="E:\hard\MobileLocation" />
<param name="device" value="${_176X220_device}" />
<param name="res_dir" value="${_176X220_res_dir}" />
<param name="symbols" value="${_176X220_proproc_symbols}" />
</antcall>

<!-- 部署 240X320版本 -->
<antcall target="deploy">
<param name="proj_name" value="MobileLocation" />
<param name="proj_dir" value="E:\hard\MobileLocation" />
<param name="device" value="${_240X320_device}" />
<param name="res_dir" value="${_240X320_res_dir}" />
<param name="symbols" value="${_240X320_proproc_symbols}" />
</antcall>
</target>

<target name="clean_all" >
<delete dir="${dist}/preproc_output" failonerror="false" />
<delete dir="${dist}/deploy" failonerror="false" />
<delete dir="${dist}/bin" failonerror="false" />
</target>
</project>

文件:j2me_build_core.xml
<?xml version="1.0" encoding="UTF-8"?>
<project name="deploy_core" default="help" >
<target name="help" >
<echo> 本文件的中的target不能直接运行 </echo>
</target>

<!-- - - - - - - - - - - - - - - - - -
target: deploy 部署应用的模板
- - - - - - - - - - - - - - - - - -->
<target name="deploy" depends="Antenna_init" >
<fail message="Property proj_name must be set" unless="proj_name" />
<!-- 删除临时文件
1: 删除预处理目录
2: 删除生成的文件
3:删除编译的class文件
-->
<echo>删除临时文件</echo>
<delete dir="${dist}/preproc_output/${proj_name}/${device}" failonerror="false" />
<delete dir="${dist}/deploy/${proj_name}/${device}" failonerror="false" />
<delete dir="${dist}/bin/${proj_name}/${device}" failonerror="false" />

<!-- 生成目录 -->
<echo>生成相关目录</echo>
<mkdir dir="${dist}/preproc_output/${proj_name}/${device}" />
<mkdir dir="${dist}/deploy/${proj_name}/${device}" />
<mkdir dir="${dist}/bin/${proj_name}/${device}" />
<!-- 预处理 -->
<echo message="proproc: ${symbols}" />
<wtkpreprocess srcdir="${proj_dir}/src"
destdir="${dist}/preproc_output/${proj_name}/${device}"
symbols="${symbols}"
debuglevel="info"
printsymbols="true"
verbose="true" />
<!-- 生成jad文件, 暂时未做 -->

<!-- 编译代码 -->
<wtkbuild
destdir="${dist}/bin/${proj_name}/${device}"
encoding="${src.encoding}" source="1.3" sourcepath=""
srcdir="${dist}/preproc_output/${proj_name}/${device}"
classpath="${j2me.classpath};${third_lib}"
>

</wtkbuild>

<!-- 打包 -->
<copy file="${proj_dir}/${descriptor.name}"
tofile="${dist}/deploy/${proj_name}/${device}/${proj_name}.jad"/>
<echo message="${dist}/bin/${proj_name}/${device}"/>
<wtkpackage autoversion="${flag.autoversion}"
jadfile="${dist}/deploy/${proj_name}/${device}/${proj_name}.jad"
jarfile="${dist}/deploy/${proj_name}/${device}/${proj_name}.jar"
obfuscate="false"
preverify="true"
verbose="true"
classpath="${j2me.classpath}"
bootclasspath="${j2me.classpath}"
libclasspath="${third_lib}"
>
<fileset dir="${dist}/bin/${proj_name}/${device}">
</fileset>

<fileset dir="${proj_dir}/src">
<exclude name="**/*.java"/>
</fileset>

<fileset dir="${proj_dir}/res/${res_dir}">
</fileset>
</wtkpackage>
<!-- 混淆, 预验证 -->

<wtkobfuscate jadfile="${dist}/deploy/${proj_name}/${device}/${proj_name}.jad"
jarfile="${dist}/deploy/${proj_name}/${device}/${proj_name}.jar"
classpath="${j2me.classpath}" >
<argument value="'-keep public class * extends javax.microedition.midlet.MIDlet'"/>
<argument value="-dontusemixedcaseclassnames -dontnote -defaultpackage '' -libraryjars ${platform_om_lib} -injars ${third_lib} "/>
</wtkobfuscate>
<wtkpreverify classpath="${bootclasspath.DefaultColorPhone}" if="flag.preverify"
jadfile="${dist}/deploy/${proj_name}/${device}/${proj_name}.jad"
jarfile="${dist}/deploy/${proj_name}/${device}/${proj_name}.jar"
bootclasspath="${j2me.classpath}"
/>

</target>
</project> <!-- 预处理 --> <!-- 生成jad文件, 暂时未做 --> <!-- 编译代码 --> <!-- 打包 --> <!-- 混淆, 预验证 -->

你可能感兴趣的:(xml,脚本)