org.codehaus.gant
Class GantBuilder

java.lang.Object
  extended by groovy.lang.GroovyObjectSupport
      extended by groovy.util.BuilderSupport
          extended by groovy.util.AntBuilder
              extended by org.codehaus.gant.GantBuilder
All Implemented Interfaces:
groovy.lang.GroovyObject

public class GantBuilder
extends groovy.util.AntBuilder

This class is a sub-class of AntBuilder to provide extra capabilities. In particular, a dry-run capability, and things to help support interaction between Gant and the underlying Project.

Author:
Russel Winder

Constructor Summary
GantBuilder()
          Constructor that uses the default project.
GantBuilder(org.apache.tools.ant.Project project)
          Constructor that specifies which Project to be associated with.
 
Method Summary
 org.apache.tools.ant.BuildLogger getLogger()
          Accessor for the logger associated with the Project.
 java.lang.Object invokeMethod(java.lang.String name, java.lang.Object arguments)
          Invoke a method.
 
Methods inherited from class groovy.util.AntBuilder
buildAttributes, createNode, createNode, createNode, createNode, createProject, doInvokeMethod, getAntProject, getAntXmlContext, getProject, nodeCompleted, setParent, setText
 
Methods inherited from class groovy.util.BuilderSupport
getCurrent, getName, invokeMethod, postNodeCompletion, setClosureDelegate, setCurrent
 
Methods inherited from class groovy.lang.GroovyObjectSupport
getMetaClass, getProperty, setMetaClass, setProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GantBuilder

public GantBuilder()
Constructor that uses the default project.


GantBuilder

public GantBuilder(org.apache.tools.ant.Project project)
Constructor that specifies which Project to be associated with.

If execution is from a command line Gant or call from a Groovy script then the class loader for all objects is a single instance of org.codehaus.groovy.tools.RootLoader, which already has Ant and Groovy jars in the classpath. If, however, execution is from an Ant execution via the Gant Ant Task, then the classloader for the instance is an instance of org.apache.tools.ant.AntClassLoader with Ant and Groovy jars on the classpath BUT the class loader for the Project instance is a simple java.net.URLClassLoader and does not have the necessary jars on the classpath. When using Ant, the Ant jar has been loaded before the Groovy aspects of the classpath have been set up. So we must allow for a specialized constructor (this one) taking a preprepared Project to handle this situation.

Parameters:
project - The Project to be associated with.
Method Detail

invokeMethod

public java.lang.Object invokeMethod(java.lang.String name,
                                     java.lang.Object arguments)
Invoke a method.

Specified by:
invokeMethod in interface groovy.lang.GroovyObject
Overrides:
invokeMethod in class groovy.util.BuilderSupport
Parameters:
name - The name of the method to invoke.
arguments - The parameters to the method call.
Returns:
The value returned by the method call or null if no value is returned.

getLogger

public org.apache.tools.ant.BuildLogger getLogger()
Accessor for the logger associated with the Project.

Returns:
The BuildLogger.

Copyright © 2006–9 The Codehaus. All Rights Reserved.