Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.


Code Block
def ant = new AntBuilder()
def taskContainer = ant.parallel(){ // "Parallel" serves as a sample TaskContainer
    ant.echo()                      // "Echo" without message to keep tests silent
// not very elegant, but the easiest way to get the ant internals...
assert taskContainer.dump() =~ /nestedTasks=\[\w+\]/

Compiling and running a Java file:

Code Block
def ant = new AntBuilder()
ant.echo(file:'', '''
class Temp { public static void main(String[] args) { System.out.println("Hello"); }}
ant.javac(srcdir:'.', includes:'', fork:'true')'.', classname:'Temp', fork:'true')
// =>
//    [javac] Compiling 1 source file
//     [java] Hello
//     [echo] Done

Sniffing around ...

Code Block

def ant = new AntBuilder()
SpoofTaskContainer.spoof.length = 0
def PATH = 'task.path'
['spoofcontainer':'SpoofTaskContainer', 'spoof':'SpoofTask'].each{ pair ->
    ant.taskdef(name:pair.key, classname:'groovy.util.'+pair.value, classpathref:PATH)
expectedSpoof =
    "SpoofTaskContainer ctor\n"+
    "SpoofTask ctor\n"+
    "in addTask\n"+
    "begin SpoofTaskContainer execute\n"+
    "begin SpoofTask execute\n"+
    "end SpoofTask execute\n"+
    "end SpoofTaskContainer execute\n"
assertEquals expectedSpoof, SpoofTaskContainer.spoof.toString()