net.sourceforge.cruisecontrol.builders
Class AntBuilder

java.lang.Object
  extended by net.sourceforge.cruisecontrol.util.PerDayScheduleItem
      extended by net.sourceforge.cruisecontrol.Builder
          extended by net.sourceforge.cruisecontrol.builders.AntBuilder
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable

public class AntBuilder
extends Builder

we often see builds that fail because the previous build is still holding on to some resource. we can avoid this by just building in a different process which will completely die after every build.

See Also:
Serialized Form

Nested Class Summary
 class AntBuilder.JVMArg
           
 class AntBuilder.Lib
           
 class AntBuilder.Listener
           
 
Field Summary
protected static java.lang.String DEFAULT_LOGGER
           
 
Fields inherited from class net.sourceforge.cruisecontrol.util.PerDayScheduleItem
INVALID_NAME_OF_DAY, NOT_SET
 
Constructor Summary
AntBuilder()
           
 
Method Summary
 org.jdom.Element build(java.util.Map buildProperties, Progress progressIn)
          build and return the results via xml.
 org.jdom.Element buildWithTarget(java.util.Map properties, java.lang.String buildTarget, Progress progress)
          Execute a build with the given target.
 java.lang.Object createJVMArg()
           
 java.lang.Object createLib()
           
 java.lang.Object createListener()
           
 Property createProperty()
           
protected  java.lang.String findAntScript(boolean isWindows)
           
protected static org.jdom.Element getAntLogAsElement(java.io.File file)
           
 java.lang.String getLoggerClassName()
           
 java.lang.String getProgressLoggerLib()
           
protected  java.lang.String getSystemClassPath()
           
 void setAntHome(java.lang.String antHome)
          If set CC will use the platform specific script provided by Ant
 void setAntScript(java.lang.String antScript)
          Sets the Script file to be invoked (in place of calling the Ant class directly).
 void setAntWorkingDir(java.lang.String dir)
          Set the working directory where Ant will be invoked.
 void setBuildFile(java.lang.String buildFile)
          Sets the name of the build file that Ant will use.
 void setKeepGoing(boolean keepGoing)
           
 void setLoggerClassName(java.lang.String string)
           
 void setProgressLoggerLib(java.lang.String progressLoggerLib)
           
 void setPropertyfile(java.lang.String propertyfile)
           
 void setSaveLogDir(java.lang.String dir)
          Set the location to which the ant log will be saved before Cruise Control merges the file into its log.
 void setShowAntOutput(boolean showAntOutput)
          Sets whether Ant will use the custom AntOutputLogger as a listener.
 void setTarget(java.lang.String target)
          Set the Ant target(s) to invoke.
 void setTempFile(java.lang.String tempFileName)
          Set the name of the temporary file used to capture output.
 void setTimeout(long timeout)
           
 void setUseDebug(boolean debug)
           
 void setUseLogger(boolean useLogger)
          Sets whether Ant will use the custom loggers.
 void setUseQuiet(boolean quiet)
           
 void validate()
           
 
Methods inherited from class net.sourceforge.cruisecontrol.Builder
compareTo, getGroup, getMultiple, getShowProgress, getTime, isValidDay, setGroup, setMultiple, setShowProgress, setTime
 
Methods inherited from class net.sourceforge.cruisecontrol.util.PerDayScheduleItem
getDay, setDay
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_LOGGER

protected static final java.lang.String DEFAULT_LOGGER
See Also:
Constant Field Values
Constructor Detail

AntBuilder

public AntBuilder()
Method Detail

validate

public void validate()
              throws CruiseControlException
Overrides:
validate in class Builder
Throws:
CruiseControlException

build

public org.jdom.Element build(java.util.Map buildProperties,
                              Progress progressIn)
                       throws CruiseControlException
build and return the results via xml. debug status can be determined from log4j category once we get all the logging in place.

Specified by:
build in class Builder
Parameters:
buildProperties - build properties
progressIn - callback to provide progress updates
Returns:
the log resulting from executing the build
Throws:
CruiseControlException - if something breaks

buildWithTarget

public org.jdom.Element buildWithTarget(java.util.Map properties,
                                        java.lang.String buildTarget,
                                        Progress progress)
                                 throws CruiseControlException
Description copied from class: Builder
Execute a build with the given target.

Specified by:
buildWithTarget in class Builder
Parameters:
properties - build properties
buildTarget - the build target to call, overrides target defined in config
progress - callback to provide progress updates
Returns:
the log resulting from executing the build
Throws:
CruiseControlException - if something breaks

setSaveLogDir

public void setSaveLogDir(java.lang.String dir)
Set the location to which the ant log will be saved before Cruise Control merges the file into its log.

Parameters:
dir - the absolute path to the directory where the ant log will be saved or relative path to where you started CruiseControl

setAntWorkingDir

public void setAntWorkingDir(java.lang.String dir)
Set the working directory where Ant will be invoked. This parameter gets set in the XML file via the antWorkingDir attribute. The directory can be relative (to the cruisecontrol current working directory) or absolute.

Parameters:
dir - the directory to make the current working directory.

setAntScript

public void setAntScript(java.lang.String antScript)
Sets the Script file to be invoked (in place of calling the Ant class directly). This is a platform dependent script file.

Parameters:
antScript - the name of the script file

setAntHome

public void setAntHome(java.lang.String antHome)
If set CC will use the platform specific script provided by Ant

Parameters:
antHome - the path to ANT_HOME

findAntScript

protected java.lang.String findAntScript(boolean isWindows)
                                  throws CruiseControlException
Parameters:
isWindows - if true, running under windows
Returns:
If the anthome attribute is set, then this method returns the correct shell script to use for a specific environment.
Throws:
CruiseControlException - if antHome is not set

setTempFile

public void setTempFile(java.lang.String tempFileName)
Set the name of the temporary file used to capture output.

Parameters:
tempFileName - temp file name

setTarget

public void setTarget(java.lang.String target)
Set the Ant target(s) to invoke.

Parameters:
target - the target(s) name.

setBuildFile

public void setBuildFile(java.lang.String buildFile)
Sets the name of the build file that Ant will use. The Ant default is build.xml, use this to override it.

Parameters:
buildFile - the name of the build file.

setUseLogger

public void setUseLogger(boolean useLogger)
Sets whether Ant will use the custom loggers.

Parameters:
useLogger - if true, use custom logger

setShowAntOutput

public void setShowAntOutput(boolean showAntOutput)
Sets whether Ant will use the custom AntOutputLogger as a listener.

Parameters:
showAntOutput - if true, add AntOutputLogger as a listener.

createJVMArg

public java.lang.Object createJVMArg()

createLib

public java.lang.Object createLib()

createListener

public java.lang.Object createListener()

createProperty

public Property createProperty()

getSystemClassPath

protected java.lang.String getSystemClassPath()

getAntLogAsElement

protected static org.jdom.Element getAntLogAsElement(java.io.File file)
                                              throws CruiseControlException
Throws:
CruiseControlException

setUseDebug

public void setUseDebug(boolean debug)

setUseQuiet

public void setUseQuiet(boolean quiet)

setKeepGoing

public void setKeepGoing(boolean keepGoing)

getLoggerClassName

public java.lang.String getLoggerClassName()

setLoggerClassName

public void setLoggerClassName(java.lang.String string)

setTimeout

public void setTimeout(long timeout)
Parameters:
timeout - The timeout to set.

setPropertyfile

public void setPropertyfile(java.lang.String propertyfile)
Parameters:
propertyfile - The propertyfile to set.

setProgressLoggerLib

public void setProgressLoggerLib(java.lang.String progressLoggerLib)
Parameters:
progressLoggerLib - The path (including filename) to the jar file (cruisecontrol-antprogresslogger.jar) containing the AntProgressLogger/Listener classes.

getProgressLoggerLib

public java.lang.String getProgressLoggerLib()
Returns:
The path (including filename) to the jar file (cruisecontrol-antprogresslogger.jar) containing the AntProgressLogger/Listener classes.