java - ant: the generated JAR cannot be executed -
i've written/copied simple ant illustration , trying deploy java progamm it. build file bsp0201.xml
:
<?xml version="1.0" encoding="utf-8" ?> <project name="bsp0201" default="main" basedir="."> <property name="dir.src" value="./source" /> <property name="dir.build" value="./classes" /> <property name="dir.lib" value="./lib" /> <path id="cp"> <pathelement path="${classpath}" /> <pathelement location="${dir.build}" /> </path> <target name="main" depends="prepare, compile, run" /> <target name="prepare"> <mkdir dir="${dir.build}" /> <delete> <fileset dir="${dir.build}" includes="**/*" /> </delete> </target> <target name="compile"> <javac classpathref="cp" destdir="${dir.build}" srcdir="${dir.src}" includes="**/*.java" includeantruntime="false" /> <mkdir dir="${dir.lib}" /> <jar destfile="${dir.lib}/ae.jar"> <fileset dir="${dir.build}" includes="**/*.class" /> </jar> </target> <target name="run" if="test"> <java classname="main.geoanalyzermain" classpath="${dir.lib}/ae.jar"> <arg line="${test}" /> </java> </target> </project>
my ant commando & result output:
# ant -f bsp0201.xml run -dtest=echo buildfile: /var/www/sandbox/ant/bsp0201/bsp0201.xml run: build successful total time: 1 sec
ant generates folders, class files , jar file ae.jar
. size of jar file 19.1 kb (instead of 297 kb of jar file, when generate eclipse) , cannot execute it. do wrong?
thx
yes, thought compare jars. :) here can see comparsion result:
the folder /img , /.classpath missing in ant-jar. why has ant not included them? how can create ant include missing files/folders?
java ant jar javac
No comments:
Post a Comment