blob: 664331e569c89bed60679449971553b462352803 [file] [log] [blame]
// A Gant script for building the Groovy system.
//
// Copyright © 2006 Russel Winder <russel@russel.org.uk>
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
// compliance with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the License is
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
// implied. See the License for the specific language governing permissions and limitations under the
// License.
//
// Author : Russel Winder
// $Revision$
// $Date$
sourceDirectory = 'src'
mainSourceDirectory = sourceDirectory + '/main'
testsSourceDirectory = sourceDirectory + '/test'
targetDirectory = 'target'
mainClassesDirectory = targetDirectory + '/classes'
testsClassesDirectory = targetDirectory + '/test-classes'
reportsDirectory = targetDirectory + '/test-reports'
antlrDirectory = mainSourceDirectory + '/org/codehaus/groovy/antlr'
parserDirectory = antlrDirectory + '/parser'
javaVersion = '1.4'
includeTargets << gant.targets.Clean
cleanDirectory << targetDirectory
cleanPattern << [ '**.*~' , parserDirectory + '/Groovy*.*' ]
dependencies = 'dependencies'
Ant.path ( id : dependencies ) {
fileset ( dir : System.properties.'groovy.home' + '/lib' , includes : '*.jar' , excludes : 'gant*.jar,*groovy*.jar' )
}
Ant.taskdef ( name : 'groovyc' , classname : 'org.codehaus.groovy.ant.Groovyc' , classpath : mainClassesDirectory )
task ( ensureAntlr : 'Ensure all the files generated from the Antlr grammar are up to date.' ) {
Ant.mkdir ( dir : parserDirectory )
// Need a way of getting this path in a platform independent way. This is fine fo Ubuntu (and Debian?) but likely fails for all other OSs.
def antAntlrJar = '/usr/share/java/ant-antlr.jar'
Ant.taskdef ( name : 'antlr' , classname : 'org.apache.tools.ant.taskdefs.optional.ANTLR' , classpath : antAntlrJar )
Ant.antlr ( target : antlrDirectory + '/groovy.g' , outputdirectory : parserDirectory ) {
classpath ( refid : dependencies )
}
}
task ( compileMain : 'Compile the Java and Groovy code in the main source.' ) {
depends ( ensureAntlr )
Ant.mkdir ( dir : mainClassesDirectory )
Ant.javac ( srcdir : mainSourceDirectory , destdir : mainClassesDirectory , debug : 'yes' , source : javaVersion , target : javaVersion , classpathref : dependencies , fork : 'true' )
Ant.groovyc ( srcdir : mainSourceDirectory , destdir : mainClassesDirectory ) { // , fork : 'true' ) {
classpath {
pathelement ( location : mainClassesDirectory )
path ( refid : dependencies )
}
}
}
task ( compileTest : 'Compile the Java and Groovy code in the test source.' ) {
depends ( compileMain )
Ant.mkdir ( dir : testsClassesDirectory )
Ant.javac ( srcdir : testsSourceDirectory , destdir : testsClassesDirectory , debug : 'yes' , source : javaVersion , target : javaVersion , excludes : 'UberTestCase*.java' , fork : 'true' ) {
classpath {
pathelement ( location : mainClassesDirectory )
path ( refid : dependencies )
}
}
/*
* Compiling the tests appears to require 128M of heap space. Since the Groovy compiler Ant task doesn't
* yet understand the fork and maxmemory attributes, we have to do things a bit more explicitly so as to
* avoid having to use JAVA_OPTS=-Xmx128M gant on the command line.
*
Ant.groovyc ( srcdir : testsSourceDirectory , destdir : testsClassesDirectory ) { // , fork : 'true', maxmemory : '128M' ) {
classpath {
pathelement ( location : mainClassesDirectory )
pathelement ( location : testsClassesDirectory )
path ( refid : dependencies )
}
}
*/
Ant.java ( classname : 'org.codehaus.groovy.ant.Groovyc' , fork : 'yes' , maxmemory : '128M' ) {
arg ( value : testsClassesDirectory )
arg ( value : testsSourceDirectory )
classpath {
pathelement ( location : mainClassesDirectory )
pathelement ( location : testsClassesDirectory )
path ( refid : dependencies )
}
}
Ant.javac ( srcdir : testsSourceDirectory , destdir : testsClassesDirectory , debug : 'yes' , source : javaVersion , target : javaVersion , includes : 'UberTestCase*.java' , fork : 'true' ) {
classpath {
pathelement ( location : mainClassesDirectory )
pathelement ( location : testsClassesDirectory )
path ( refid : dependencies )
}
}
}
task ( test : 'Test a build.' ) {
depends ( compileTest )
Ant.mkdir ( dir : reportsDirectory )
Ant.junit ( printsummary : 'true' , fork : 'true' , forkmode : 'once' ) {
formatter ( type : 'plain' )
batchtest ( todir : reportsDirectory ) {
fileset ( dir : testsClassesDirectory , includes : 'UberTest*.class' )
}
classpath {
pathelement ( location : mainClassesDirectory )
pathelement ( location : testsClassesDirectory )
path ( refid : dependencies )
}
}
}
task ( 'default' : 'Default action is currently test.' ) { test ( ) }