Saturday, October 16, 2010

Gant Script: print ant default properties

If you want to know exactly what kind of ant properties in your environment, try the following gant target:

target(properties : "print ant default properties") {
     println "ant properties are:"
     ant.project.properties.each { key, value ->
         println "${key} = ${value}"
     }
}

Here are some of the out put:
ant properties are:
ant.version = Apache Ant version 1.8.1 compiled on April 30 2010
sun.os.patch.level = unknown
java.vm.vendor = Apple Inc.
environment.HOME = /Users/steve
environment.TERM_PROGRAM = Apple_Terminal
file.encoding = MacRoman
user.language = en
java.class.path = /opt/local/share/java/gant/lib/groovy-all-1.7.3.jar
file.separator = /
java.runtime.name = Java(TM) SE Runtime Environment
basedir = /Users/steve/dev/gant
java.vm.specification.version = 1.0
awt.nativeDoubleBuffering = true

...
...

Look how easy it work in the Groovy/Gant script, I am sure it is much harder to write in ant xml build script, and you have to use ant-contrib to implement the for loop!  Byebye XML!

No comments:

Post a Comment