org.codehaus.gant.ant
Class Gant

java.lang.Object
  extended by org.apache.tools.ant.ProjectComponent
      extended by org.apache.tools.ant.Task
          extended by org.codehaus.gant.ant.Gant
All Implemented Interfaces:
java.lang.Cloneable

public class Gant
extends org.apache.tools.ant.Task

Execute a Gant script.

This Ant task provides a Gant calling capability. The original intention behind this was to support continuous integration systems that do not directly support Gant but only Ant. However it also allows for gradual evolution of an Ant build into a Gant build.

Possible attributes are:

Both of these are optional. The file 'build.gant' and the default target are used by default. An error results if there is no default target and no target is specified.

Definitions, if needed, are specified using nested definition tags, one for each symbol to be defined. Each definition tag takes a compulsory name attribute and an optional value attribute.

Author:
Russel Winder

Nested Class Summary
static class Gant.Definition
          A class representing a nested definition tag.
static class Gant.GantTarget
          A class representing a nested target tag.
 
Field Summary
private  java.util.List<Gant.Definition> definitions
          A list of definitions to be set in the Gant instance.
private  java.lang.String file
          The path to the file to use to drive the Gant build.
private  boolean inheritAll
          Flag determining whether properties are inherited from the parent project.
private  java.util.List<Gant.GantTarget> targets
          A list of targets to be achieved by the Gant instance.
 
Fields inherited from class org.apache.tools.ant.Task
target, taskName, taskType, wrapper
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
description, location, project
 
Constructor Summary
Gant()
           
 
Method Summary
private  void addAlmostAll(org.apache.tools.ant.Project newProject, org.apache.tools.ant.Project oldProject)
          Copy all properties from the given project to the new project -- omitting those that have already been set in the new project as well as properties named basedir or ant.file.
 Gant.Definition createDefinition()
          Create a node to represent a nested definition tag.
 Gant.GantTarget createGantTarget()
          Create a node to represent a nested gantTarget tag.
 void execute()
          Load the file and then execute it.
 void setFile(java.lang.String f)
          Set the name of the build file to use.
 void setInheritAll(boolean value)
          If true, pass all properties to the new Ant project.
 void setTarget(java.lang.String t)
          Set the target to be achieved.
 
Methods inherited from class org.apache.tools.ant.Task
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
clone, getDescription, getLocation, getProject, setDescription, setLocation, setProject
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

file

private java.lang.String file
The path to the file to use to drive the Gant build. The default is build.gant. This path is relative to the basedir of the Ant project if it is set, or the directory in which the job was started if the basedir is not set.


inheritAll

private boolean inheritAll
Flag determining whether properties are inherited from the parent project.


definitions

private final java.util.List<Gant.Definition> definitions
A list of definitions to be set in the Gant instance.


targets

private final java.util.List<Gant.GantTarget> targets
A list of targets to be achieved by the Gant instance.

Constructor Detail

Gant

public Gant()
Method Detail

setFile

public void setFile(java.lang.String f)
Set the name of the build file to use. This path is relative to the basedir of the Ant project if it is set, or the directory in which the job was started if the basedir is not set.

Parameters:
f - The name of the file to be used to drive the build.

setTarget

public void setTarget(java.lang.String t)
Set the target to be achieved.

Parameters:
t - The target to achieve.

createGantTarget

public Gant.GantTarget createGantTarget()
Create a node to represent a nested gantTarget tag.

Returns:
a new GantTarget instance ready for values to be added.

createDefinition

public Gant.Definition createDefinition()
Create a node to represent a nested definition tag.

Returns:
a new Definition instance ready for values to be added.

setInheritAll

public void setInheritAll(boolean value)
If true, pass all properties to the new Ant project.

Parameters:
value - if true pass all properties to the new Ant project.

execute

public void execute()
             throws org.apache.tools.ant.BuildException
Load the file and then execute it.

Overrides:
execute in class org.apache.tools.ant.Task
Throws:
org.apache.tools.ant.BuildException

addAlmostAll

private void addAlmostAll(org.apache.tools.ant.Project newProject,
                          org.apache.tools.ant.Project oldProject)
Copy all properties from the given project to the new project -- omitting those that have already been set in the new project as well as properties named basedir or ant.file. Inspired by the org.apache.tools.ant.taskdefs.Ant source.

Parameters:
newProject - the Project to copy into.
oldProject - the Project to copy properties from.

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