Apache Ant is an open source, cross-platform based build tool that is used to describe a build process and its dependencies and implemented in XML scripts using Java classes that ensures its extensible to any development environment (based on Java) and its integrity with other build tools.
This article is about how to start with ant tool. In this article I am going to create a Java Project and will create a jar file of java project using ant file.
In my previous post I have written about Eclipse | Hello World Java Project. I am going to use same project and here also.
So my project structure will be as below:
Image may be NSFW.
Clik here to view.
Now to introduce ant file create a xml file using File–> New wizard and name it projectBuilder.xml and place below code in xml file.
- <project name="AntProject" default="makejar" basedir=".">
- <target name ="makejar" description="Create a jar for the ant project">
- <jar jarfile="HelloWorld.jar" includes="*.class" basedir="bin"/>
- </target>
- </project>
Now right click on projectbuilder.xml select run as ant file. As the execution stops refresh the ant project.
A jar file named HelloWorld.jar will be in root project folder.
Clik here to view.
