java - how to compile source file using ant -
i new in ant
programming, have made build.xml
execute compiled file. want learn " should automatically build .java
file , move target
folder.
currently compiling java file eclipse & moving target folder & running ant
.
i have folder structure like
myproject source helloworld.java target lib build.xml
in build.xml have below code,
<?xml version="1.0" encoding="utf-8"?> <project name="hello world project" default="info"> <path id="master-classpath"> <fileset dir="lib"> <include name="*.jar"/> </fileset> </path> <target name="info"> <junit printsummary="yes" haltonfailure="yes"> <classpath> <pathelement location="target"/> </classpath> <classpath refid="master-classpath"/> <test name="helloworld" haltonfailure="no" outfile="result"> <formatter type="plain"/> <formatter type="xml"/> </test> </junit> </target> </project>
you need use javac
ant task this:
<target name="build" description="compile main source tree java files"> <mkdir dir="target"/> <javac destdir="target" source="1.6" target="1.6" debug="true" deprecation="false" optimize="false" failonerror="true"> <src path="src"/> <classpath refid="master-classpath"/> </javac> </target>
you need put dependency jars in master-classpath
.
hope helps.
Comments
Post a Comment