Jump to: navigation, search


1,385 bytes added, 12:21, 15 October 2010
CI System Project Related
: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.
<echo>Files foo.txt and bar.txt are present.</echo>
<target name="myTarget.check">
:A project can have a set of properties
:A ''property'' has a name and a value; the name is case-sensitive. Properties may be used in the value of task attributes. This is done by placing the property name between "${" and "}" in the attribute value. Example:
::If "builddir" property with the value “c:/test",
::This could be used in an attribute like this: ${builddir}/classes
::This is resolved at run-time as c:/test/classes
<source lang=java>
<project name="MyProject" default="init" basedir=".">
<description> simple example build file </description>
<!-- set global properties for this build -->
<property name="src" location="src"/>
<property name="build" location="build"/>
<target name="init">
<!-- Create the build directory structure used by compile -->
<mkdir dir="${build}"/>
<target name="compile" depends="init" description="comp-source ">
<!-- Compile the java code from ${src} into ${build} -->
<javac srcdir="${src}" destdir="${build}"/>
<target name="clean" description="clean up" >
<!-- Delete the ${build} directory tree -->
<delete dir="${build}"/>
==ANT & Mercurial==
:[ ANT4HG] is an ANT task for HG ( mercurial ).
: How to add ant4hg tasks to ant:
::1- Download binaries. Latest version is ant4hg V0.07. It has been released with ant 1.8.0 and hg 1.5.1. Source code and binaries are available on the [ download page].
::2- Copy ant4hg-Vx.y.jar to the ant lib directory
::3- Consider using : <code> <taskdef resource="net/sourceforge/ant4hg/taskdefs/antlib.xml"/></code> instead of: <code> <taskdef resource="net/sourceforge/ant4hg/antlib.xml"/> </code>.
::4- Available tasks and the instruction of using them can be found in this [ documentation].
:In Cygwin in the ''build'' folder. Just typing <code>ant</code>, will build the default target of the project. But typing <code>ant assign1.test</code> for example, will start from mentioned target.
:Also, option -f will build any files that's not named ''build.xml'' e.g. <code>ant -f buildHudson.xml</code>
:We can use a new ant script e.g. ''buildHudson.xml'' that triggers the target(assign1.test) of main build file(build.xml) of the project. See below:
<source lang=java>
<project name="assign1_MY" basedir="." default="myTarget">
<target name="">
<!-- Call the target that does everything -->
<ant antfile="build.xml" target="assign1.test"/>
<target name="myTarget.check" depends="">
<echo>The was called!</echo>

Navigation menu