Saturday, 26 January 2013

JAD Updating, and Automating the build process with ANT

JAD Updating

The JAD file has its contents updated to reflect the properties of the JAR file.

Automating the build process with ANT

ANT can be used to perform all of the build steps in sequence saving you much time and effort. The source code download also includes a sample ANT build script.
build.xml
<project name="helloworld" default="dist" basedir="." >
        <property name="app.name" value="helloworld" />
        <property name="app.path" value="/${app.name}"  />
        <property name="build.home" value="${basedir}/build" />
        <property name="lib.home" value="${basedir}/lib" />
        <property name="dist.home" value="${basedir}/dist" />
        <property name="src.home" value="${basedir}/src" />
        <property name="compile.debug" value="true" />
        <property name="compile.deprecation" value="false" />
        <property name="compile.optimize" value="true" />

        <target name="all" depends="dist" description="Clean build and dist directories, then compile" />

        <target name="clean" description="Delete old build directory">
               <delete dir="${build.home}" />
        </target>

        <target name="compile" description="Compile Java sources">
               <javacsrcdir="${src.home}" destdir="${build.home}" debug="${compile.debug}" deprecation="${compile.deprecation}" optimize="${compile.optimize}">
                       <classpath>
                               <filesetdir="${lib.home}" includes="*.jar,*.zip" />
                       </classpath>
                       <include name="**/*.java"/>
               </javac>
        </target>

        <target name="bundle" depends="compile" description="Takes the built objects and makes a JAR file.">
               <mkdirdir="${build.home}/META-INF"/>
               <copy todir="${build.home}/META-INF">
                       <filesetdir="META-INF" includes="**/*.MF" />
               </copy>
               <jar jarfile="${dist.home}/HelloWorld.jar" basedir="${build.home}" includes="**/*.class" />
        </target>

        <target name="preverify" depends="bundle" description="Preverifies the JAR file.">
               <exec dir="${dist.home}" executable="<path-to-project>/dist/preverify">
                       <arg line="-d ${dist.home} -classpath ${lib.home}/cldcapi11.jar:${lib.home}/midpapi20.jar ${dist.home}/HelloWorld.jar"/>
               </exec>
        </target>

        <target
               name="dist"
               depends="preverify"
               description="Create binary distribution">

               <exec dir="${dist.home}" executable="java">
                       <arg line="-cp %CLASSPATH%;.;.. -jar JammedUp.jar HelloWorld.jad -b -d -s"/>
               </exec>

        </target>

</project>

No comments:

Post a Comment