Ant
- take control of compilation, packaging, testing, and deployment stages of the build process in a way that is portable, scalable, and often reusable.
- three levels: project (each build file), target (dependencies), task (extensible, e.g, javac, mkdir)
<-- target is to resolve dependencies, conditionally execution. e.g., -->
<target name="m.clean">
....
<property name="cleaned" value="true"/>
</target>
<target name="m.compile">
<javac destdir="..." ></javac>
<antcall target="m.binding" />
</target>
<target name="m.binding" if="cleaned">
<bind load="true"> ...</bind>
</target>
- DataTypes: Path, Fileset, Patternset, Filterset, ZipFilest, etc.
- Ant properties ${property.name}
i. built in properties such as ant.file (the absolute path of the build file, can use ant.file.fgl-common-build where fgl-common-build is the project name of the build file which is included in the main build file)
ii. JVM system properties, e.g., user.name, java.home
iii. Set with 'property' task
<property name="build.debug" value="on"/> -- name/value pair
<property file="build.properties" /> -- load from properties file
<property name="src.dir" location="somedir" /> - refer to relative path
iv. load environment varialbe
<property environment="env" />
v. set property conditionally
<!-- if debug, set debugLevel to all; else lines only -->
<condition property="debugLevel" value="lines,vars,source" else="lines,source">
<istrue value="${debug}"/>
</condition>
all env vairables are loaded with prefix env such as env.CATALINA_HOME
Properties are immutable. A property define in build file doesn't override the one from property file. However, there are ways to break the immutability of property using <ant/>, <antcall>, <available> and -D command line operation. Among them, -D has the highest priority.
No comments:
Post a Comment