How to create Ant build file for existing Java project in Eclipse
- Details
- Written by Nam Ha Minh
- Last Updated on 07 August 2019   |   Print Email
- Select File > Export from main menu (or right click on the project name and select Export > Export…).
- In the Export dialog, select General > Ant Buildfilesas follows:
- Click Next. In the Generate Ant Buildfilesscreen:
- Check the project in list.
- Uncheck the option "Create target to compile project using Eclipse compiler" because we want to create a build file which is independent of Eclipse.
- Leave the Name for Ant buildfile as default: build.xml
- Click Finish, Eclipse will generate the build.xmlfile under project’s directory as follows:
<target name="war" description="Bundles the application as a WAR file" depends="clean, build"> <mkdir dir="WebContent/WEB-INF/classes"/> <copy includeemptydirs="false" todir="WebContent/WEB-INF/classes"> <fileset dir="build/classes"> <include name="**/*.class"/> </fileset> </copy> <war destfile="UploadServlet30.war" basedir="WebContent" needxmlfile="false"> </war> </target>
ant war
Output:NOTE: You must have Ant installed and configured properly to execute the above command. This Ant installation is separate from the one bundled with Eclipse.Related Tutorials:
Other Eclipse Tutorials:
- How to use Eclipse IDE for Java EE Developers
- How to create, build and run a Java Hello World program with Eclipse
- How to generate Javadoc in Eclipse
- How to create WAR file for Java web application in Eclipse
- How to create JAR file in Eclipse
- How to pass arguments when running a Java program in Eclipse
- How to create Java web project with Maven in Eclipse
- 25 Eclipse Shortcut Keys for Code Editing
- How to Add Copyright License Header for Java Source Files in Eclipse
Comments
Including an email target didn't do the job for me.
E.g.
operable program or batch file.
'operable' is not recoginized as an internal or external command, operable program or batch file
Does anyone help on this above issue facing in my cmd prompt