What Is Ant?
<project name="test" default="hello">
<target name="hello" depends="setup, pre-hello1, pre-hello2">
<echo> Hello World</echo>
</target>
<target name="setup">
<property name="company.name" value="MindTree"/>
<condition property="os.is.solaris">
<os name="SunOS" />
</condition>
</target>
<target name="pre-hello1" if="os.is.solaris">
<echo> You are running this script in Solaris </echo>
</target>
<target name="pre-hello2" unless="os.is.solaris">
<echo> You are NOT running this script in Solaris </echo>
</target>
</project>
Buildfile: test.xml
setup:
pre-hello1:
pre-hello2:
[echo] You are NOT running this script in Solaris
hello:
[echo] Hello World
BUILD SUCCESSFUL
Total time: 1 second
basedir | The absolute path of the project's basedir (as set with the basedir attribute of <project>). |
ant.file | The absolute path of the buildfile. |
ant.version | The version of Ant |
ant.project.name | The name of the project that is currently executing; it is set in the name attribute of <project>. |
ant.java.version | the JVM version Ant detected; |
<target name="compile" depends="init, setup" description="compile the source " >
<!-- Compile the java code from ${src} into ${build} -->
<javac srcdir="${src}" destdir="${build}"/>
</target>
<antcall target="copymodule">
<param name="module.name" value="user"/>
</antcall>
<target name="copymodule" if="gws.prepared">
<echo>Module : ${module.name} </echo>
<copy todir="${gws.app}/j2ee-apps/gws/${module.name}"
includeEmptyDirs="no">
<fileset dir="${gws.class.folder}">
<patternset>
<include name="**/${module.name}/**"/>
</patternset>
</fileset>
</copy>
</target>
<target name="ROOT">
<ant dir="${basedir}/ROOT" target="dist"/>
</target>
<target name="examples">
<ant dir="${basedir}/examples" target="dist"/>
<ant antfile="subproject/subbuild.xml" dir="${basedir}/subproject" target="compile"/>
</target>
<?xml version="1.0"?>
<project name="OwnTaskExample" default="main" basedir=".">
<taskdef name="mytask" classname="com.mydomain.MyVeryOwnTask"/>
<target name="main">
<mytask message="Hello World! MyVeryOwnTask works!"/>
</target>
</project
-help | print this message |
-projecthelp | print project help information |
-version | print the version information and exit |
-diagnostics | print information that might be helpful to diagnose or report problems. |
-quiet, -q | be extra quiet |
-verbose, -v | be extra verbose |
-debug | print debugging information |
-emacs | produce logging information without adornments |
-logfile <file> | use given file for log |
-l <file> | "" |
-logger <classname> | the class which is to perform logging |
-listener <classname> | add an instance of class as a project listener |
-buildfile <file> | use given buildfile |
-file <file> | "" |
-f <file> | "" |
-D<property>=<value> | use value for given property |
-propertyfile | taking precedence |
-inputhandler <class> | the class which will handle input requests |
-find <file> <name> | load all properties from file with -D properties search for buildfile towards the root of the filesystem and use it |