Ant

Ant , . Ant - , Java, . Ant 1.4 . Ant 1.4 Apache/Jakarta. , Ant, Apache/Jakarta.

Ant, jakarta-ant-1.4. Ant docs/manual. docs/manual/index.html Ant . Ant . , - Ant, PATH, ant . jakarta-ant-1.4/bin PATH ( ). , Ant /usr/local/Java/Ant/jakarta-ant-1.4, PATH /usr/local/Java/Ant/jakarta-ant-1.4/bin. win32, Ant G:/tmp/jakarta-ant-1.4 G:/tmp/jakarta-ant-1.4/bin PATH.

bin JDK 1.3 (Java development kit) java. JAVA_HOME JDK 1.3, Ant javac. Ant , , Ant .

Ant shell . build.xml , :

1.1. Ant build.xml Ant


<!-- Simple Ant build script to test an Ant installation -->
<project name="TestInstall" default="run" basedir=".">

  <target name="init">
    <available file="ASimpleHelloObject.java" property="ASimpleHelloObject"/>
  </target>

  <target name="ASimpleHelloObject" unless="ASimpleHelloObject" depends="init">
    <echo file="ASimpleHelloObject.java">
public class ASimpleHelloObject
{
    public static void main(String[] args)
    {
        System.out.println("ASimpleHelloObject.main was called");
    }
}
    </echo>
    <echo message="Wrote ASimpleHelloObject.java" />
  </target>

  <target name="compile" depends="ASimpleHelloObject">
    <javac destdir="." srcdir="." debug="on" classpath=".">
        <include name="ASimpleHelloObject.java"/>
    </javac>
  </target>

  <target name="run" depends="compile">
    <java classname="ASimpleHelloObject" classpath="." />
    <echo message="Ant appears to be successfully installed" />
  </target>

</project>

linux- build.xml, /tmp :


bash-2.04$ ant
Buildfile: build.xml

init:

ASimpleHelloObject:
     [echo] Wrote ASimpleHelloObject.java

compile:
    [javac] Compiling 1 source file to /tmp

run:
ASimpleHelloObject.main was called
     [echo] Ant appears to be successfully installed

BUILD SUCCESSFUL

Total time: 2 seconds


win32 build.xml D:/temp :

D:\temp>ant
Buildfile: build.xml

init:

ASimpleHelloObject:

compile:
    [javac] Compiling 1 source file to D:\temp

run:
ASimpleHelloObject.main was called
     [echo] Ant appears to be successfully installed

BUILD SUCCESSFUL

Total time: 2 seconds

- :


D:\temp>ant

Warning: JAVA_HOME environment variable is not set.
  If build fails because sun.* classes could not be found
  you will need to set the JAVA_HOME environment variable
  to the installation directory of java.

Buildfile: build.xml

init:

ASimpleHelloObject:
     [echo] Wrote ASimpleHelloObject.java

compile:
    [javac] Modern compiler is not available - using classic compiler
    [javac] Compiling 1 source file to D:\temp

BUILD FAILED

D:\temp\build.xml:22: Cannot use classic compiler, as it is not available A comm
on solution is to set the environment variable JAVA_HOME to your jdk directory.

Total time: 1 second

JAVA_HOME JDK 1.3.