蟻からの解放
やっと ant 一発で Compile して,Obfuscate して,preverify して,manifest ファイルを作成して,jar に固めて,jad を作って,kjx にして,CRC を付けて,ダウンロード用の HDML までの作成ができるようになる。
さぁ,コーディングに取り組むぞ。
最適化(?) されていないのだが,バックアップの意味も踏まえてここに掲載。
// 何だかんだで,長編大作 build.xml になっているぞ…。
<project name="Ezthello" default="all" basedir=".">
<property name="midpname" value="Ezthello" />
<property name="vendor" value="'Studio High-Score'" />
<property name="datasize" value="1024" />
<property name="src" location="src" />
<property name="res" location="res" />
<property name="bin" location="bin" />
<property name="tmp" location="tmpclasses" />
<property name="mangled" location="mangled_classes" />
<property name="classes" location="classes" />
<property name="manifest" location="${bin}/MANIFEST.MF" />
<property name="hdmlfile" value="download.hdml" />
<property name="myclasses" value="/Users/take/classes" />
<property name="midplib" value="${myclasses}/midpapi.zip" />
<property name="kddiplib" value="${myclasses}/kddip.jar" />
<property name="jmangle" value="${myclasses}/jmangle.jar" />
<property name="kjxarchiver" value="${myclasses}/KJXArchiver.jar" />
<property name="eztooldir" value="/Users/take/Documents/midp/masui/tools" />
<property name="manifest2jad" value="${eztooldir}/manifest2jad" />
<property name="makemanifest" value="${eztooldir}/makemanifestfile" />
<property name="downloadhdml" value="${eztooldir}/downloadhdmlfile" />
<property name="cp" value="${midplib}:${kddiplib}:${jmangle}:${tmp}" />
<target name="all" depends="downloadHDML"/>
<target name="rebuild" depends="clean, all"/>
<target name="downloadHDML" depends="addCRC" >
<exec executable="${downloadhdml}" dir="${bin}">
<arg line="${hdmlfile} ${midpname}" />
</exec>
</target>
<target name="addCRC" depends="kjx" >
<copy file="${bin}/${midpname}.kjx" tofile="${bin}/${midpname}_nocrc.kjx" />
<java classname="CRC" fork="true">
<classpath>
<pathelement path="${myclasses}" />
</classpath>
<arg line="${bin}/${midpname}.kjx" />
</java>
</target>
<target name="kjx" depends="makejad" >
<java jar="${kjxarchiver}" fork="true">
<arg line="-c ${bin}/${midpname}.jad" />
<arg line="${bin}/${midpname}.jar" />
<arg line="${bin}/${midpname}.kjx" />
</java>
</target>
<target name="makejad" depends="jarres">
<exec executable="${manifest2jad}" dir="${bin}">
<arg line="${midpname}" />
</exec>
</target>
<target name="jarres" depends="jarclass">
<jar update="true"
destfile="${bin}/${midpname}.jar"
basedir="${res}" manifest="${manifest}">
<include name="*.png" />
</jar>
</target>
<target name="jarclass" depends="preverify,makemanifest">
<jar update="false"
destfile="${bin}/${midpname}.jar"
basedir="${classes}" manifest="${manifest}">
<include name="**/*.class" />
</jar>
</target>
<target name="makemanifest_" >
<exec executable="${makemanifest}">
<arg line="${midpname} ${manifest} ${vendor}" />
</exec>
</target>
<target name="makemanifest" >
<manifest file="${manifest}">
<attribute name="MIDlet-Name" value="${midpname}" />
<attribute name="MIDlet-Vendor" value="${vendor}" />
<attribute name="MIDlet-Version" value="1.0" />
<attribute name="MicroEdition-Configuration" value="CLDC-1.0" />
<attribute name="MicroEdition-Profile" value="MIDP-1.0" />
<attribute name="MIDlet-1" value="${midpname},,${midpname}" />
</manifest>
</target>
<target name="preverify" depends="mangle" >
<exec executable="preverify">
<arg line="-d ${classes} -classpath ${cp} ${mangled}" />
</exec>
</target>
<target name="preverify_" depends="compile" >
<exec executable="preverify">
<arg line="-d ${classes} -classpath ${cp} ${tmp}" />
</exec>
</target>
<target name="mangle" depends="compile" >
<java classname="jmangle" fork="true">
<classpath>
<pathelement location="${midplib}" />
<pathelement location="${kddiplib}" />
<pathelement location="${jmangle}" />
<pathelement path="${tmp}" />
</classpath>
<arg line="+prefix t +verbose - +map - ${tmp} ${mangled}" />
</java>
</target>
<target name="compile" depends="makedir" >
<javac srcdir="${src}" destdir="${tmp}" encoding="SJIS" debug="off" >
<bootclasspath location="${midplib}:${kddiplib}" />
<classpath location="${tmp}" />
</javac>
</target>
<target name="ascii">
<native2ascii
encoding="ISO2022JP"
src="./"
dest="./"
includes="**/*.jis"
ext=".java"
/>
</target>
<target name="jis">
<native2ascii reverse="on" encoding="ISO2022JP" src="./" dest="./" includes="**/*.java" ext=".jis" />
</target>
<target name="makedir">
<mkdir dir="${bin}" />
<mkdir dir="${tmp}" />
<mkdir dir="${mangled}" />
<mkdir dir="${classes}" />
</target>
<target name="clean">
<delete dir="${bin}" />
<delete dir="${tmp}" />
<delete dir="${mangled}" />
<delete dir="${classes}" />
</target>
</project>