venerdì 13 aprile 2012

Ant Tips

1- Launching  Multiple Ant build
Commonly a complete software delivery is made of a set of jar/war files and each jar/war file may be produced by a distintinct ant .xml build file.
To make full release you wish to launch a building process that will call each  ant file in sequence.
This is a sample of a possible solution:
Assume that the whole software realease is the union of this 2 projects (named Project1 and Project2).
Assume that  and each project has it own directory structure and its own build.xml and file so directory structure is :
     -> Project1

You may define an upper level  ant file in the root directory:
 <target name="softwareRelease"  description="my full build ant task">
  <ant antfile="Project1/build.xml" target="Build_And__deploy_Jar" inheritAll="false">
   <property file="Project1/"/>
  <ant antfile="Project2/build.xml" target="Build_And__deploy_Jar" inheritAll="false">
   <property file="Project2/"/>

inheritAll="false" means that each ant refers only to its file.

2- Ant parameters
Basically you have tree choices to pass parameters to ant build file file
This is most used option. Good if your property are the same in all build environment (developers pc , code management environment) otherwise choose another option.
es: in  file define
To use property defined in file put in build.xml file
<project name="myproject" basedir="." default="build">
 <property file=""/>

environment variables
This options loads all environment properties. This is a more flexible option than the previous one so you may define different variable values in different building environments.
To use env vars in ant build.xml file
<project name="myproject" basedir="." default="build">
<property environment="env"/>

Also a good option. You may launch ant build with a -Dproperty_name=property_value (as many as you need). This way you may override property value defined in file (good to ovverride development property values with code management environment values).

Nessun commento:

Posta un commento