• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 185
  • Last Modified:

Tool for generating Ant Script


Editing Ant scripts by hand seems to be an arduous task. Is there any tool around that automates/ facilitates the generation of these scripts?

2 Solutions
Mayank SAssociate Director - Product EngineeringCommented:
You can do it in Sun One Studio:


In IntelliJ IDEA too:


Some Ant tools can also be found here: http://ant.apache.org/external.html

See if it has what you want.
Almost every IDE has a ant-editor view.  In Eclipse, the built in ant perspective will allow you to fill in allowed elements and attributes, with an alt-space.  I Googled for a plug-in an found http://sourceforge.net/projects/antbuildcreator.  But all it does, is past in a template to the specified file.

Your best bet is to have a standard project directory structure and have a template build script that works on that structure.  For example, for a simple java application, I would recomend this structure:
 -src                     - Store java source code here
 -srcTest              - Store jUnit source code here
 -bin                    - Compile source code to here
 -dist                   - Build jar file here

and have the following generic build.xml file in the project root:
<project name="Ant Builder" default="dist" basedir=".">
        Application build file.
  <!-- set global properties for this build -->
  <property name="src" location="src" />
  <property name="srcTest" location="srcTest" />
  <property name="build" location="bin" />
  <property name="target.testreports.dir" location="c:\temp\testResults"/>
  <property name="dist" location="dist" />
  <!-- change this value to the name of the application -->
  <property name="app.name" value="test"/>

  <target name="init">
    <!-- Create the time stamp -->
    <tstamp />
    <!-- Create the build directory structure used by compile -->
    <mkdir dir="${build}" />
    <mkdir dir="${target.testreports.dir}" />

  <target name="compile.java" depends="init" description="compile the source ">
    <!-- Compile the java code from ${src} into ${build} -->
    <javac srcdir="${src}" destdir="${build}" />

  <target name="compile.junit" depends="init" description="compile the junit source">
    <!-- Compile the java code from ${srcTest} into ${build} -->
    <javac srcdir="${srcTest}" destdir="${build}" />

  <target name="compile" depends="compile.java,compile.junit" description="compile the all of the java">

    <target name='test' depends='compile.junit' description="Run JUnit tests">
        <junit printsummary='yes'
            <formatter type="plain" usefile="false"/>
            <formatter type="xml"/>
            <classpath refid='junit.classpath'/>
            <batchtest todir="${target.testreports.dir}" >
                <fileset dir='${build}' includes='**/*Test.java'/>


  <target name="dist" depends="compile" description="generate the distribution">
    <!-- Create the distribution directory -->
    <mkdir dir="${dist}/lib" />

    <jar jarfile="${dist}/lib/${app.name}-${DSTAMP}${TSTAMP}.jar" basedir="${build}" />

  <target name="clean" description="clean up">
    <!-- Delete the ${build} and ${dist} directory trees -->
    <delete dir="${build}" />
    <delete dir="${dist}" />


Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now