I am learning about build.xml file for ant build. I have a simple "Hello World" project in Eclipse.
Is there any way to generate a build.xml file in Eclipse for this project?
Thanks in Advance.
xml by choosing "Run As..." and "Ant Build". The build. xml file, if it is an ant script, is not used to import the project into an IDE like Eclipse or Netbeans. A build script is used to build the project (or produce some desired output) rather than an mechanism for importing the project into an IDE.
The build. xml file is an Ant script that is created by the PDE to take your plug-in components and combine them into a deployable format. This file compiles and archives your plug-in source code into a single JAR file.
How do I write build. xml file? here is a sample build. xml you just need to know important element e.g. project ,target ,property and task and the order in which different target gets executed to start with basic build procedure.
xml file, right click the project select new->other->xml , enter the name as build. xml and click finish . to build the project right click the build. xml file and select ant build .
Yes - click on File -> Export -> General -> Ant Buildfiles
and specify the file name, project, etc.
I find that I've got a single generic Ant build.xml that I reuse again and again. It's not something that has to be done from scratch every time.
If you're learning Ant, what's the point of using a generated build.xml?
Something like this:
<?xml version="1.0" encoding="UTF-8"?> <project name="xslt-converter" basedir="." default="package"> <property name="version" value="1.6"/> <property name="haltonfailure" value="no"/> <property name="out" value="out"/> <property name="production.src" value="src"/> <property name="production.lib" value="lib"/> <property name="production.resources" value="config"/> <property name="production.classes" value="${out}/production/${ant.project.name}"/> <property name="test.src" value="test"/> <property name="test.lib" value="lib"/> <property name="test.resources" value="config"/> <property name="test.classes" value="${out}/test/${ant.project.name}"/> <property name="exploded" value="out/exploded/${ant.project.name}"/> <property name="exploded.classes" value="${exploded}/WEB-INF/classes"/> <property name="exploded.lib" value="${exploded}/WEB-INF/lib"/> <property name="reports.out" value="${out}/reports"/> <property name="junit.out" value="${reports.out}/junit"/> <property name="testng.out" value="${reports.out}/testng"/> <path id="production.class.path"> <pathelement location="${production.classes}"/> <pathelement location="${production.resources}"/> <fileset dir="${production.lib}"> <include name="**/*.jar"/> <exclude name="**/junit*.jar"/> <exclude name="**/*test*.jar"/> </fileset> </path> <path id="test.class.path"> <path refid="production.class.path"/> <pathelement location="${test.classes}"/> <pathelement location="${test.resources}"/> <fileset dir="${test.lib}"> <include name="**/junit*.jar"/> <include name="**/*test*.jar"/> </fileset> </path> <path id="testng.class.path"> <fileset dir="${test.lib}"> <include name="**/testng*.jar"/> </fileset> </path> <available file="${out}" property="outputExists"/> <target name="clean" description="remove all generated artifacts" if="outputExists"> <delete dir="${out}" includeEmptyDirs="true"/> <delete dir="${reports.out}" includeEmptyDirs="true"/> </target> <target name="create" description="create the output directories" unless="outputExists"> <mkdir dir="${production.classes}"/> <mkdir dir="${test.classes}"/> <mkdir dir="${reports.out}"/> <mkdir dir="${junit.out}"/> <mkdir dir="${testng.out}"/> <mkdir dir="${exploded.classes}"/> <mkdir dir="${exploded.lib}"/> </target> <target name="compile" description="compile all .java source files" depends="create"> <!-- Debug output <property name="production.class.path" refid="production.class.path"/> <echo message="${production.class.path}"/> --> <javac srcdir="src" destdir="${out}/production/${ant.project.name}" debug="on" source="${version}"> <classpath refid="production.class.path"/> <include name="**/*.java"/> <exclude name="**/*Test.java"/> </javac> <javac srcdir="${test.src}" destdir="${out}/test/${ant.project.name}" debug="on" source="${version}"> <classpath refid="test.class.path"/> <include name="**/*Test.java"/> </javac> </target> <target name="junit-test" description="run all junit tests" depends="compile"> <!-- Debug output <property name="test.class.path" refid="test.class.path"/> <echo message="${test.class.path}"/> --> <junit printsummary="yes" haltonfailure="${haltonfailure}"> <classpath refid="test.class.path"/> <formatter type="xml"/> <batchtest fork="yes" todir="${junit.out}"> <fileset dir="${test.src}"> <include name="**/*Test.java"/> </fileset> </batchtest> </junit> <junitreport todir="${junit.out}"> <fileset dir="${junit.out}"> <include name="TEST-*.xml"/> </fileset> <report todir="${junit.out}" format="frames"/> </junitreport> </target> <taskdef resource="testngtasks" classpathref="testng.class.path"/> <target name="testng-test" description="run all testng tests" depends="compile"> <!-- Debug output <property name="test.class.path" refid="test.class.path"/> <echo message="${test.class.path}"/> --> <testng classpathref="test.class.path" outputDir="${testng.out}" haltOnFailure="${haltonfailure}" verbose="2" parallel="methods" threadcount="50"> <classfileset dir="${out}/test/${ant.project.name}" includes="**/*.class"/> </testng> </target> <target name="exploded" description="create exploded deployment" depends="testng-test"> <copy todir="${exploded.classes}"> <fileset dir="${production.classes}"/> </copy> <copy todir="${exploded.lib}"> <fileset dir="${production.lib}"/> </copy> </target> <target name="package" description="create package file" depends="exploded"> <jar destfile="${out}/${ant.project.name}.jar" basedir="${production.classes}" includes="**/*.class"/> </target> </project>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With