My first gant

  • property は変数を宣言する様に書く (SRC_DIR, etc)
  • 最新 1.9.1 では Ant.javac ではエラーになり、ant.javac では OK だった。
  • classpathref は ant.path で定義
  • ant.java の element の部分 (classpath) は ant.javaクロージャの中にさらに classpathクロージャを作る感じ。


// JDK_HOME = new File('...')
// JAVAC = JDK_HOME + 'bin' + 'javac'
SRC_DIR = new File('src')
BIN_DIR = new File('bin')

ant.path(id: 'compile.classpath') {
fileset(dir: 'bin', includes: '*.class')
}

target(compile: 'Compile Sources') {
ant.javac(srcdir: SRC_DIR,
destdir: BIN_DIR,
fork: 'yes', classpathref: 'compile.classpath', debug:'on',
debugLevel:'lines,vars,source', target:'1.5', source:'1.5')
}

target(run: 'Run app') {
ant.java(classname:'XPathExample', fork:'true', maxmemory:'32m') {
classpath() {
pathelement(location: BIN_DIR)
}
arg(value: 'book.xml')
}
}

setDefaultTarget(compile)
includeTargets << gant.targets.Clean
cleanDirectory << 'bin'