2017  Kodetalk | Feedback | Privacy Policy | Terms | About
userimage

how to setup ant in eclipse IDE

how to setup ant in eclipse IDE
userimage

To integrate Ant build file with the Eclipse IDE, first create a build.xml file, right click the project select New->Other->XML, enter the name as build.xml and click Finish.



<?xml version="1.0" ?>
<project name="Ant Example" default="execute">

    <target name="init" depends="clean">
        <mkdir dir="build/classes" />
    </target>

    <target name="compile" depends="init">
        <javac srcdir="src" destdir="build/classes" />
    </target>
   
    <target name="execute" depends="compile">
        <java classname="com.test.code.ConcatQuote" classpath="build/classes" />
    </target>

    <target name="clean">
        <delete dir="build" />
    </target>
   
</project>


To build the project right click the build.xml file and select Ant Build.


The ConcatQuote.java file will be compiled and executed. The following message shows the sequence of events that happen once the build file is executed.


Buildfile: D:/workspace/TestCondition/build.xml
clean:
   [delete] Deleting directory D:/workspace/TestCondition/build
init:
    [mkdir] Created dir: D:/workspace/TestCondition/build/classes
compile:
    [javac] D:/workspace/TestCondition/build.xml:9: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
    [javac] Compiling 19 source files to D:/workspace/TestCondition/build/classes
execute:
     [java] value : Jenkins
BUILD SUCCESSFUL
Total time: 3 seconds



Answer is