Tool for generating Ant Script

Posted on 2005-05-02
Last Modified: 2010-03-31

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

Question by:naqsh
    LVL 30

    Accepted Solution

    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.
    LVL 21

    Assisted Solution

    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}" />


    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    PGP Decryption code using Bouncy Castle jars 11 72
    scoresIncreasing challenge 10 49
    count7 challenge 12 53
    countAbc challenge 9 35
    After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
    In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
    Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
    Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now