Meyyappan has posted 101 posts at DZone. View Full User Profile

Ant Eclipse IDE Integration

06.13.2012
| 20576 views |
  • submit to reddit

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.vaannila.helloworld.HelloWorld" 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 HelloWorld.java file will be compiled and executed. The following message shows the sequence of events that happen once the build file is executed.

<?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.vaannila.helloworld.HelloWorld" classpath="build/classes" />
	</target>

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

You can download the build file here.

Build file :Download
Project :Download
Published at DZone with permission of its author, Meyyappan Muthuraman.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Tags:

Comments

Lisa Coffey replied on Sat, 2014/07/19 - 7:43am

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

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.