Difference between revisions of "User:Minooz/Ant"
(→Tutorials) |
(→Tutorials) |
||
(9 intermediate revisions by the same user not shown) | |||
Line 7: | Line 7: | ||
==Tutorials== | ==Tutorials== | ||
* [http://individual.utoronto.ca/kia/ Eclipse based Tutorial ] | * [http://individual.utoronto.ca/kia/ Eclipse based Tutorial ] | ||
− | * Notes from | + | * Notes from [[User:JAnastasiade| Jordan Anastasiade]] Notes and [http://ant.apache.org/manual/ Apache Manual] |
: Ant is a Java-based build tool. Instead of a model where it is extended with shell-based commands, ant is extended using Java classes | : Ant is a Java-based build tool. Instead of a model where it is extended with shell-based commands, ant is extended using Java classes | ||
:Instead of writing shell commands, the configuration files are XML-based, calling out a target tree where various tasks get executed. | :Instead of writing shell commands, the configuration files are XML-based, calling out a target tree where various tasks get executed. | ||
Line 15: | Line 15: | ||
::set JAVA_HOME=... | ::set JAVA_HOME=... | ||
::set PATH=%PATH%;%ANT_HOME%\bin | ::set PATH=%PATH%;%ANT_HOME%\bin | ||
− | :ant buildfiles are written in XML – build.xml. Each buildfile contains one project and at least one (default) target. | + | :ant buildfiles are written in XML – build.xml. Each buildfile contains one project and at least one (default) target. |
<source lang=java> | <source lang=java> | ||
<?xml version="1.0"?> | <?xml version="1.0"?> | ||
Line 29: | Line 29: | ||
</project> | </project> | ||
</source> | </source> | ||
+ | :A project has three attributes: '''name''': the name of the project. '''default''': the default target to use when no target is supplied. '''basedir''': the base directory from which all path calculations are done | ||
+ | : Each project defines one or more targets which are a set of task elements you want to execute | ||
+ | : When starting ant, you can select which target(s) you want to have executed | ||
+ | |||
+ | :A target has the following attributes: '''name''': the name of the target. '''depends''': a comma-separated list of names of targets. '''if''': the name of the property that must be set in order for this target to execute | ||
+ | |||
+ | :It should be noted, however, that Ant's depends attribute only specifies the order in which targets should be executed - it does not affect whether the target that specifies the dependency(s) gets executed if the dependent target(s) did not (need to) run. | ||
+ | |||
+ | ::'''NOTE''': In Cygwin in the ''build'' folder. Just typing ''ant'', will build the default target of the project. But typing '' ant assign1.test'' for example, will build dependents too. |
Latest revision as of 09:42, 14 October 2010
ANT
Apache Website
Tutorials
- Eclipse based Tutorial
- Notes from Jordan Anastasiade Notes and Apache Manual
- Ant is a Java-based build tool. Instead of a model where it is extended with shell-based commands, ant is extended using Java classes
- Instead of writing shell commands, the configuration files are XML-based, calling out a target tree where various tasks get executed.
- Installing Ant :
- Add the bin directory to your path. Set the ANT_HOME environment variable to the directory where you installed Ant. Assume ant is installed in c:\ant\. The following sets up the environment:
- set ANT_HOME=c:\ant
- set JAVA_HOME=...
- set PATH=%PATH%;%ANT_HOME%\bin
- ant buildfiles are written in XML – build.xml. Each buildfile contains one project and at least one (default) target.
<?xml version="1.0"?>
<!-- compile java files from all subdirectories -->
<project name="First" default="build" basedir=".">
<target name="build" >
<javac srcdir="."
debug="false"
optimize="false"
includes="**/*.java"
/>
</target>
</project>
- A project has three attributes: name: the name of the project. default: the default target to use when no target is supplied. basedir: the base directory from which all path calculations are done
- Each project defines one or more targets which are a set of task elements you want to execute
- When starting ant, you can select which target(s) you want to have executed
- A target has the following attributes: name: the name of the target. depends: a comma-separated list of names of targets. if: the name of the property that must be set in order for this target to execute
- It should be noted, however, that Ant's depends attribute only specifies the order in which targets should be executed - it does not affect whether the target that specifies the dependency(s) gets executed if the dependent target(s) did not (need to) run.
- NOTE: In Cygwin in the build folder. Just typing ant, will build the default target of the project. But typing ant assign1.test for example, will build dependents too.