Package groovy.ant
Class AntBuilder
java.lang.Object
groovy.lang.GroovyObjectSupport
groovy.util.BuilderSupport
groovy.ant.AntBuilder
- All Implemented Interfaces:
GroovyObject
Allows Ant tasks to
be used with a Groovy builder-style markup. Requires that
ant.jar is on your classpath which will
happen automatically if you are using the Groovy distribution but will be up
to you to organize if you are embedding Groovy. If you wish to use the
optional tasks
you will need to add one or more additional jars from the ant distribution to
your classpath - see the library
dependencies for more details.-
Constructor Summary
ConstructorsConstructorDescriptionCreates anAntBuilderbacked by a freshly initialized Ant project.AntBuilder(org.apache.tools.ant.Project project) Creates anAntBuilderbacked by the supplied project.AntBuilder(org.apache.tools.ant.Project project, org.apache.tools.ant.Target owningTarget) Creates anAntBuilderbacked by the supplied project and owning target.AntBuilder(org.apache.tools.ant.Task parentTask) Creates anAntBuilderthat shares the context of the supplied parent task. -
Method Summary
Modifier and TypeMethodDescriptionprotected static AttributesbuildAttributes(Map attributes) Builds anAttributesfrom aMapprotected ObjectcreateNode(Object tagName) Creates a node with no attributes or body text.protected ObjectcreateNode(Object name, Object value) Creates a node and applies inline text to it.protected ObjectcreateNode(Object name, Map attributes) Creates a node from the supplied name and attributes.protected ObjectcreateNode(Object name, Map attributes, Object value) Creates a node, applies attributes, and then applies inline text to it.protected static org.apache.tools.ant.Projectprotected ObjectdoInvokeMethod(String methodName, Object name, Object args) We don't want to return the node as created increateNode(Object, Map, Object)but the one made ready bynodeCompleted(Object, Object)org.apache.tools.ant.ProjectReturns the underlying Ant project instance.org.apache.tools.ant.helper.AntXMLContextGets the xml context of Ant used while creating tasksorg.apache.tools.ant.Project# Gets the Ant project in which the tasks are executedbooleanWhether stdin, stdout, stderr streams are saved.protected voidnodeCompleted(Object parent, Object node) Determines, when the ANT Task that is represented by the "node" should perform.protected voidAnt child nodes are attached by Ant's own configuration machinery, so this hook is intentionally a no-op.voidsetSaveStreams(boolean saveStreams) Indicates that we save stdin, stdout, stderr and replace them while AntBuilder is executing tasks with streams that funnel the normal streams into Ant's logs.protected voidApplies nested text content to the current Ant task.Methods inherited from class groovy.util.BuilderSupport
getCurrent, getName, invokeMethod, invokeMethod, postNodeCompletion, setClosureDelegate, setCurrentMethods inherited from class groovy.lang.GroovyObjectSupport
getMetaClass, setMetaClassMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface groovy.lang.GroovyObject
getProperty, setProperty
-
Constructor Details
-
AntBuilder
public AntBuilder()Creates anAntBuilderbacked by a freshly initialized Ant project. -
AntBuilder
public AntBuilder(org.apache.tools.ant.Project project) Creates anAntBuilderbacked by the supplied project.- Parameters:
project- the project used to create and execute Ant tasks
-
AntBuilder
public AntBuilder(org.apache.tools.ant.Project project, org.apache.tools.ant.Target owningTarget) Creates anAntBuilderbacked by the supplied project and owning target.- Parameters:
project- the project used to create and execute Ant tasksowningTarget- the target that should collect top-level tasks
-
AntBuilder
public AntBuilder(org.apache.tools.ant.Task parentTask) Creates anAntBuilderthat shares the context of the supplied parent task.- Parameters:
parentTask- the Ant task whose project and owning target should be reused
-
-
Method Details
-
getProject
public org.apache.tools.ant.Project getProject()# Gets the Ant project in which the tasks are executed- Returns:
- the project
-
getAntXmlContext
public org.apache.tools.ant.helper.AntXMLContext getAntXmlContext()Gets the xml context of Ant used while creating tasks- Returns:
- the Ant xml context
-
isSaveStreams
public boolean isSaveStreams()Whether stdin, stdout, stderr streams are saved.- Returns:
- true if we are saving streams
- See Also:
-
setSaveStreams
public void setSaveStreams(boolean saveStreams) Indicates that we save stdin, stdout, stderr and replace them while AntBuilder is executing tasks with streams that funnel the normal streams into Ant's logs.- Parameters:
saveStreams- set to false to disable this behavior
-
createProject
protected static org.apache.tools.ant.Project createProject()- Returns:
- Factory method to create new Project instances
-
setParent
Ant child nodes are attached by Ant's own configuration machinery, so this hook is intentionally a no-op.- Specified by:
setParentin classBuilderSupport- Parameters:
parent- the logical parent nodechild- the logical child node
-
doInvokeMethod
We don't want to return the node as created increateNode(Object, Map, Object)but the one made ready bynodeCompleted(Object, Object)- Overrides:
doInvokeMethodin classBuilderSupport- Parameters:
methodName- the original method namename- the mapped node nameargs- the invocation arguments- Returns:
- the created node, or a replacement from
BuilderSupport.postNodeCompletion(Object, Object) - See Also:
-
nodeCompleted
Determines, when the ANT Task that is represented by the "node" should perform. Node must be an ANT Task or no "perform" is called. If node is an ANT Task, it performs right after complete construction. If node is nested in a TaskContainer, calling "perform" is delegated to that TaskContainer.- Overrides:
nodeCompletedin classBuilderSupport- Parameters:
parent- note: null when node is rootnode- the node that now has all its children applied
-
createNode
Creates a node with no attributes or body text.- Specified by:
createNodein classBuilderSupport- Parameters:
tagName- the requested node name- Returns:
- the created Ant proxy
-
createNode
Creates a node and applies inline text to it.- Specified by:
createNodein classBuilderSupport- Parameters:
name- the requested node namevalue- the inline text value- Returns:
- the created Ant proxy
-
createNode
Creates a node, applies attributes, and then applies inline text to it.- Specified by:
createNodein classBuilderSupport- Parameters:
name- the requested node nameattributes- the node attributesvalue- the inline text value- Returns:
- the created Ant proxy
-
buildAttributes
Builds anAttributesfrom aMap- Parameters:
attributes- the attributes to wrap- Returns:
- the wrapped attributes
-
createNode
Creates a node from the supplied name and attributes.- Specified by:
createNodein classBuilderSupport- Parameters:
name- the requested node nameattributes- the attributes to apply- Returns:
- the created Ant proxy or target
-
setText
Applies nested text content to the current Ant task.- Parameters:
task- the current Ant task proxytext- the text content to apply
-
getAntProject
public org.apache.tools.ant.Project getAntProject()Returns the underlying Ant project instance.- Returns:
- the project backing this builder
-