2009-03-09

Tips on Ant []

Moved to the page http://3rdstage.wikia.com/wiki/On_Ant in my wiki as of 6th Aug. 2012.

Readings : References, Articles and Tutorials

Pattern to Specify Files and Directories

Notable Ant Tasks

Using Saxon in Ant XSLT Task

If you don't read the following article, you would do really lots of trial and error to use Saxon XSLT processor with XSLT task of Ant.

Listing members of fileset or path-like structure line by line

For eye-checking or reporting purpose, sometimes it is necessary to list members of fileset each one in it's line.
You can do this using pathconvert and echo tasks.

The following is snippet used to list non-java files in source directories of Maven projects (which are multi-module form).

You can also list path-like structure line by line using <pathconvert> task.

Actually <pathconvert> can also be applied to dirset, filelist, or propertyset as well. For details, refer http://ant.apache.org/manual/Tasks/pathconvert.html

Including another path-like structure within a path-like structure

If you want include a path-like structure to another, you can use <path refid="..."> like this.

Note that you should not use <pathelement path="...">. The value of path attribute in pathelement is expected to be string corresponding to path not id of path-like structure.
The following would cause error.

If you really want to use pathelement all the way, you can use toString function.
The following would work.

Note that ${java.class.path} which can be evaluated from default system properties of Java is just string corresponding to classpath and maven.plugin.classpath which is defined implicitly with maven-antrun-plugin is id of path-like structure.
So, you should use them like the following.

Printing environment variables

To identify all the environment variables and their values defined within the process the current Ant build is running, you can use echo task with environment attribute.

The above property task makes properties for all the environment variables in current process with the property names prefixed by 'env'.

1 comments:

Gia W said...

Nice blog you have thanks for posting

Post a Comment