// Gant build script for SwingX Builder // 25 April 2007 // Author: James Williams // Ant.property ( file : 'local.build.properties' ) Ant.property ( file : 'build.properties' ) includeTargets << gant.targets.Clean cleanPattern << [ '**/*~' , '**/*.bak' ] cleanDirectory << [ Ant.project.properties.'swingxbuilder.dist' , Ant.project.properties.'swingxbuilder.build' ] Ant.path ( id : 'lib.groovy' ) { fileset ( dir : System.properties.'groovy.home' + '/lib' , includes : '**/*.jar', excludes : '**/groovy-*.jar' ) } Ant.path ( id : 'build.classpath' ) { fileset ( dir : Ant.project.properties.'swingxbuilder.lib' , includes : '**/*.jar' ) fileset ( dir : System.properties.'java.home' , includes : 'lib/tools.jar' ) path ( refid : 'lib.groovy' ) } Ant.path ( id : 'test.classpath' ) { path ( refid : 'build.classpath' ) dirset ( dir : Ant.project.properties.'swingxbuilder.build.classes' ) } Ant.taskdef ( name : 'groovyc' , classname : 'org.codehaus.groovy.ant.Groovyc' , classpathref : 'build.classpath' ) target ( '-initialize' : '' ) { mkdir ( dir : Ant.project.properties.'swingxbuilder.build.classes' ) mkdir ( dir : Ant.project.properties.'swingxbuilder.build.reports' ) mkdir ( dir : Ant.project.properties.'swingxbuilder.build.tests' ) mkdir ( dir : Ant.project.properties.'swingxbuilder.dist' ) } target ( compile : 'Compile all classes.' ) { depends ( '-initialize' ) groovyc ( srcdir : Ant.project.properties.'swingxbuilder.src.main' , destDir : Ant.project.properties.'swingxbuilder.build.classes' ) { classpath ( refid : 'build.classpath' ) } } target ( 'compile-tests' : 'Compile all the tests.' ) { depends ( compile ) groovyc ( srcdir : Ant.project.properties.'swingxbuilder.src.test' , destdir : Ant.project.properties.'swingxbuilder.build.tests') { classpath ( refid : 'test.classpath' ) } } target ( test : 'Run all the tests in the build.' ) { depends ( 'compile-tests' ) junit ( printsummary : 'yes' , haltonfailure : 'true' ) { formatter ( type : 'plain' ) formatter ( type : 'xml' ) batchtest ( fork : 'yes' , todir : Ant.project.properties.'swingxbuilder.build.reports' ) { fileset ( dir : Ant.project.properties.'swingxbuilder.build.tests' , includes : '**/*Test.class' ) } classpath { pathelement ( location : Ant.project.properties.'swingxbuilder.build.tests' ) pathelement ( location : Ant.project.properties.'swingxbuilder.build.classes' ) path ( refid : 'build.classpath' ) } } } target ( jar : 'Create a distribution of the project.' ) { depends ( compile ) // Have to use Ant.jar to disambiguate fromt he target called jar. Ant.jar ( destfile : Ant.project.properties.'swingxbuilder.dist' + '/' + Ant.project.properties.'swingxbuilder.jar.dist' , basedir : Ant.project.properties.'swingxbuilder.build.classes' , excludes: '*Test.*') { manifest { attribute ( name : 'Built-By' , value : Ant.project.properties.'user/name' ) attribute ( name : 'Extension-Name' , value : 'SwingXBuilder' ) attribute ( name : 'Specification-Title' , value : 'SwingX Builder: building UIs with Groovy' ) attribute ( name : 'Specification-Vendor' , value : 'The Codehaus' ) } zipfileset ( fullpath : 'META-INF/LICENSE.txt' , file : 'LICENSE.txt' ) } } target ( dist : 'Create a zip file containing a full distribution of the project.' ){ depends ( jar ) zip ( destfile : Ant.project.properties.'swingxbuilder.zip.dist' ) { zipfileset ( dir : Ant.project.properties.'swingxbuilder.src.main' , prefix : 'src/' ) zipfileset ( dir : Ant.project.properties.'swingxbuilder.dist' , excludes: '*.zip') zipfileset ( dir : Ant.project.properties.'swingxbuilder.docs' , prefix : 'docs/' ) } } setDefaultTarget ( compile )