Note, that this recipe is not updated long time and could be outdated!
Got it.

QUIT WINDOWS, IT SEVERELY HARMS HEALTH OF YOUR COMPUTER!

COMPUTERS RUNNING WINDOWS DIE YOUNG!

Ant on Windows

Ant along with Maven is a build tool. Ant allows to write low level build scripts, where each file manipulation task is written explicitly. Along with predefined tasks (such as copying, archiving, compilation, etc.) Ant allows defining user-specific tasks, which can be used along with predefined ones in the build script file build.xml

  1. Unzip file apache-ant-1.7.0-bin.zip, e.g. under c:/tools
  2. Define a new environment variable ANT_HOME with this value - c:/tools/apache-ant-1.7.0 (see Defining System Environment Variables).
  3. Add another directory to the Path variable - i.e. add before all other path entries %ANT_HOME%/bin and separate it from the next Path values by a semicolon (;)

Checking the installation

  1. Close DOS and Total Commander windows, if they were opened before you redefined the environment variables.
  2. Open a DOS window window somewhere, type "ant -version" and check the response

    c:\temp>ant -version
    Apache Ant version 1.6.5 compiled on June 2 2005
  3. If you are new to Apache Ant, you may want to test the Ant installation by building some simple Ant project. For example, create a subdirectory c:/temp/src and create any file Hello.java in this directory (see the source text of Hello.java above). Also create the following file with EditPlus or a similar text editor and save it as build.xml in the directory c:/temp

    <project name="testproject" default="usage" basedir=".">
        <target name="usage" description="Message on how to use Ant buildfiles">
            <echo>Please use the 'build -projecthelp' to see
                a list of available build targets.</echo>
        </target>
        <target name="clean" description="Removes build artifacts">
            <delete dir="build" failonerror = "false"/>
        </target>
        <target name="init" depends="clean" description="Creates
            the directory structure for a simple Java project">
            <mkdir dir="build"/>
        </target>
        <target name="compile" depends="init"
                description="Compiles the sources">
            <echo level="info">Compiling files</echo>
            <javac srcdir="src"
                destdir="build"
                debug="true"
                source="1.5"
                target="1.5"/>
        </target>
        <target name="run">
            <java classname="Hello"
                fork="true"
                classpath="build">
            </java>
        </target>
    </project>
  4. Run the following commands in a DOS window:

    c:\temp>ant
    c:\temp>ant -projecthelp
    c:\temp>ant compile
    c:\temp>ant run

    These should display

    1. a usage message,
    2. a list of all commands availabe in the Ant script,
    3. a message of successful compilation of the file c:\temp\src\Hello.java,
    4. the message printed out by the Java program.

  
Tags Windows Rīki Uzstādīšana Programmēšana
Created by Valdis Vītoliņš on 2013-09-08 13:33
Last modified by Valdis Vītoliņš on 2013-09-08 13:34
 
Xwiki Powered
Creative Commons Attribution 3.0 Unported License