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?

Who is Participating?
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:

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  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="" 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="" 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.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='**/*'/>


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

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

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

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.