Posted by Robert on Tue 18 Nov 11:36
report abuse | View followups from Robert | download | new post
- def buildDir = 'gant'
- def classesDir = "${buildDir}/classes"
- def sourceDir = "src"
- def testSourceDir = "test"
- def reportsDir = "reports"
- def jarsDir = "lib"
- def testJarsDir = "${jarsDir}/test"
- def distributables = "dist"
- def distributedJarName = "simple.jar"
- def distributedJarPath = "${distributables}/${distributedJarName}"
- fileset(dir: jarsDir) {
- include(name: '*.jar')
- }
- }
- dirset(dir: classesDir)
- }
- target(initDirs: 'Create all the required directories') {
- }
- target(compile: 'Build all the binary class files') {
- depends(initDirs)
- Ant.javac(srcdir: sourceDir, destdir: classesDir)
- Ant.javac(srcdir: testSourceDir, destdir: classesDir) {
- classpath() {
- path(refid: 'jars')
- }
- }
- }
- target(jar: 'Jar up the code') {
- Ant.jar(basedir: classesDir,
- destfile: distributedJarPath,
- excludes: '**/*Test*') {
- manifest() {
- attribute(name: 'Main-Class',
- value: 'example.Hello')
- }
- }
- }
- target(test: 'Run the test suite for the code') {
- depends(compile)
- Ant.junit(haltonfailure: 'yes') {
- formatter(type: 'plain')
- classpath() {
- path(refid: 'jars')
- path(refid: 'source')
- }
- batchtest(todir: reportsDir) {
- fileset(dir: "${classesDir}") {
- include(name: "**/*Test*")
- }
- }
- }
- }
- target(dist: 'Create release artefacts') {
- depends(test)
- depends(jar)
- }
- target(run: 'Run the distributed jar') {
- depends(dist)
- Ant.java(jar: distributedJarPath, fork: 'true')
- }
- target(hello: 'Hello World') {
- }
- setDefaultTarget(dist)
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.