To integrate Ant build file with the Eclipse IDE, first create a build.xml file, right click the project selectNew->Other->XML, enter the name as build.xml and click Finish.
01.
<?
xml
version
=
"1.0"
?>
02.
<
project
name
=
"Ant Example"
default
=
"execute"
>
03.
04.
<
target
name
=
"init"
depends
=
"clean"
>
05.
<
mkdir
dir
=
"build/classes"
/>
06.
</
target
>
07.
08.
<
target
name
=
"compile"
depends
=
"init"
>
09.
<
javac
srcdir
=
"src"
destdir
=
"build/classes"
/>
10.
</
target
>
11.
12.
<
target
name
=
"execute"
depends
=
"compile"
>
13.
<
java
classname
=
"com.vaannila.helloworld.HelloWorld"
classpath
=
"build/classes"
/>
14.
</
target
>
15.
16.
<
target
name
=
"clean"
>
17.
<
delete
dir
=
"build"
/>
18.
</
target
>
19.
20.
</
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.
01.
<?
xml
version
=
"1.0"
?>
02.
<
project
name
=
"Ant Example"
default
=
"execute"
>
03.
04.
<
target
name
=
"init"
depends
=
"clean"
>
05.
<
mkdir
dir
=
"build/classes"
/>
06.
</
target
>
07.
08.
<
target
name
=
"compile"
depends
=
"init"
>
09.
<
javac
srcdir
=
"src"
destdir
=
"build/classes"
/>
10.
</
target
>
11.
12.
<
target
name
=
"execute"
depends
=
"compile"
>
13.
<
java
classname
=
"com.vaannila.helloworld.HelloWorld"
classpath
=
"build/classes"
/>
14.
</
target
>
15.
16.
<
target
name
=
"clean"
>
17.
<
delete
dir
=
"build"
/>
18.
</
target
>
19.
20.
</
project
>
No comments:
Post a Comment