Package org.apache.tools.ant


Class AntClassLoader

public class AntClassLoader

Inheritance Information

Extends: java.lang.ClassLoader

Description

This class is used to load a class in Ant if that class exists within a classpath different from the one used to start Ant.

A helper method (forceLoadClass) allows classes to be loaded from the system classpath of the machine running Ant.

Constructors

 public  AntClassLoader  (Project project, Path classpath) 

When constructing a new classloader, you must specify both the Ant project it should be associated with and the classpath from which it will load classes.

 public  AntClassLoader  (Project project, Path classpath,                       boolean systemFirst) 

The alternate constructor for an AntClassLoader takes a true or false flag indicating whether the system classpath should also be used. This information is helpful if the classloader needs to access classes (or dependencies to classes) loaded in your system path (for example, JUnit).

Methods

 public void  setIsolated  (boolean isolated) 

This method forces Ant to look only in this classloader s classpath (as opposed to also including the base classloader or other loaded classloaders). If isolated mode is turned on, then any classes referenced and not found in this classloader will throw a java.lang.classNotFoundException.

 public void  addSystemPackageRoot  (java.lang.String packageRoot) 

This method adds a new directory (or Java package) to the default path for the system path classloader. Any subdirectories will also be included.

 public void  addLoaderPackageRoot  (java.lang.String packageRoot) 

This method adds a new directory (or Java package) to the default path for this classloader. Any subdirectories will also be included.

 public java.lang.Class  forceLoadClass  (java.lang.String classname) 

This method loads this classloader even if that class is available on the system classpath. Any future class loaded by this object will be loaded using this classloader. If those classes are not available in its classpath, they will throw a java.lang.ClassNotFoundException.

 public java.lang.Class  forceLoadSystemClass  (java.lang.String classname) 

This method loads a class but defers to the system classloader. You use this method to ensure that any objects created by the class will be compatible with the system loader.

 public java.io.InputStream  getResourceAsStream  (java.lang.String name) 

You use this class to get an InputStream to a named resource.

 protected java.lang.Class  loadClass  (java.lang.String classname,                                                             boolean resolve) 

This method loads a given class using this classloader. If the requested class does not exist on the system classpath or this loader's classpath, the method will throw a java.lang.ClassNotFoundException.

 public java.lang.Class  findClass  (java.lang.String name) 

This method finds and loads a given class using this classloader. If the requested class does not exist on the system classpath or this loader's classpath, the method will throw a java.lang.ClassNotFoundException.

Class BuildEvent

 public class BuildEvent 

Inheritance Information

Extends: java.util.EventObject

Constructors

 public  BuildEvent  (Project project) public  BuildEvent  (Target target) public  BuildEvent  (Task task) 

Methods

 public void  setMessage  (java.lang.String message, int priority) 

This method sets the default logging message for this event.

 public void  setException  (java.lang.Throwable exception) 

This method specifies a custom exception you want this event to throw.

 public Project  getProject  () 

This method returns the Project that fired this event.

 public Target  getTarget  () 

This method returns the Target that fired this event.

 public Task  getTask  () 

This method returns the Task that fired this event.

 public java.lang.String  getMessage  () 

This method returns the logging message.

 public int  getPriority  () 

This method returns the priority value associated with the logging message.

 public java.lang.Throwable  getException  () 

This method returns the exception that was thrown, as a Throwable. This field will be set only for taskFinished, targetFinished, and buildFinished events.

Interface BuildListener

 public Interface BuildListener 

Inheritance Information

Extends: java.util.EventListener

Description

Classes that implement this interface will be notified of events happening in a build.

Methods

 public void  buildStarted  (BuildEvent event) 

This method is called before any events are started.

 public void  buildFinished  (BuildEvent event) 

This method is called after the last target has finished. It will still be called if an error occurs during the build.

 public void  targetStarted  (BuildEvent event) 

This method is called before the target s execution is started.

 public void  targetFinished  (BuildEvent event) 

This method is called after the target has finished. It will still be called if an error occurs during the execution of the target.

 public void  taskStarted  (BuildEvent event) 

This method is called before the task s execution is started.

 public void  taskFinished  (BuildEvent event) 

This method is called after the task has finished. It will still be called if an error occurs during the execution of the task.

 public void  messageLogged  (BuildEvent event) 

This method is executed whenever a message is logged.

Interface BuildLogger

 public Interface BuldLogger 

Inheritance Information

Extends: BuildListener

Description

Ant uses this interface to log the output from the build. A build logger is very much like a build listener with permission to write to the Ant log, which is usually System.out (unless redirected by the -logfile option).

Methods

 public void  setMessageOutputLevel  (int level) 

This method sets the msgOutputLevel for this logger. Any messages with a level less than or equal to the given level will be logged. The constants for the message levels are in Project.java. The order of the levels, from least verbose to most verbose, is MSG_ERR, MSG_WARN, MSG_INFO, MSG_VERBOSE, MSG_DEBUG.

 public void  setOutputPrintStream  (PrintStream output) 

This method sets the output stream this logger will use.

 public void  setEmacsMode  (boolean emacsMode) 

This method sets this logger to produce emacs-compatible output.

 public void  setErrorPrintStream  (java.io.PrintStream err) 

This method sets the output stream this logger will use for errors.

Class DefaultLogger

 public class DefaultLogger 

Inheritance Information

Extends: java.lang.Object

Implements: BuildLogger

Description

This class writes a build event to a PrintStream. Note that DefaultLogger only writes which targets are being executed and any messages that are logged.

Fields

 protected java.io.PrintStream  out  protected java.io.PrintStream  err  protected int  msgOutputLevel  protected static java.lang.String  lSep  protected boolean  emacsMode  

Methods

 public void  setMessageOutputLevel  (int level) 

This method sets the msgOutputLevel for this logger. Any messages with a level less than or equal to the given level will be logged. The constants for the message levels are in Project.java. The order of the levels, from least verbose to most verbose, is MSG_ERR, MSG_WARN, MSG_INFO, MSG_VERBOSE, MSG_DEBUG.

 public void  setOutputPrintStream  (java.io.PrintStream output) 

This method sets the output stream this logger will use. It is specified by setOutputPrintStream in interface BuildLogger.

 public void  setErrorPrintStream  (java.io.PrintStream err) 

This method sets the output stream this logger will use for errors. It is specified by setErrorPrintStream in interface BuildLogger.

 public void  setEmacsMode  (boolean emacsMode) 

This method sets this logger to produce emacs-compatible output. It is specified by setEmacsMode in interface BuildLogger.

 public void  buildStarted  (BuildEvent event) 

This method executes before any targets are started. It is specified by buildStarted in interface BuildListener.

 public void  buildFinished  (BuildEvent event) 

This method executes after all other activity in the build and prints the build s success status and any errors. It is specified by buildFinished in interface BuildListener.

 public void  targetStarted  (BuildEvent event) 

This method executes when a target is started. It is specified by targetStarted in interface BuildListener.

 public void  targetFinished  (BuildEvent event) 

This method executes when a target is complete, whether errors occurred or not.

 public void  taskStarted  (BuildEvent event) 

This method executes when a task is started.

 public void  taskFinished  (BuildEvent event) 

This method executes when a task has finished, whether errors occurred or not.

 public void  messageLogged  (BuildEvent event) 

This method executes when a message is logged.

Class DesirableFilter

 public class DesirableFilter 

Inheritance Information

Extends: java.lang.Object

Implements: java.io.FilenameFilter

Description

This class is designed to filter filenames to determine their desirability.

Methods

 public boolean accept(java.io.File dir, java.lang.String name) 

This method tests the given filename to determine whether it's desirable. It helps tasks filter temporary files and files used by Concurrent Versioning System (CVS). It is specified by accept in interface java.io.FilenameFilter.

Class DirectoryScanner

 public class DirectoryScanner 

Inheritance Information

Implements: FileScanner

Description

This class is designed to scan a directory for specific files and subdirectories.

Fields

 protected static final java.lang.String[]  DEFAULTEXCLUDES  

This field is a string array to hold patterns that should be excluded by default.

 protected java.io.File  basedir  

This field is the base directory from which to scan.

 protected java.lang.String[]  includes  

This field is a string array to hold patterns that should be included by default.

 protected java.lang.String[]  excludes  

This field is a string array to hold patterns that will be excluded.

 protected java.util.Vector  filesIncluded  

This field specifies all files that were found and matched one or more includes, and matched no excludes.

 protected java.util.Vector  filesNotIncluded  

This field specifies the files that were found and matched zero includes.

 protected java.util.Vector  filesExcluded  

This field specifies the files that were found and matched one or more includes, and also matched at least one exclude.

 protected java.util.Vector  dirsIncluded  

This field specifies the directories that were found and matched one or more includes, and matched zero excludes.

 protected java.util.Vector  dirsNotIncluded  

This field specifies the directories that were found and matched zero includes.

 protected java.util.Vector  dirsExcluded  

This field specifies the files that were found and matched one or more includes, and also matched one or more excludes.

 protected boolean  haveSlowResults  

This field is a true or false value indicating whether the vectors holding results were built by a slow scan.

Methods

 protected static boolean  matchPath  (java.lang.String pattern, java.lang.String str) 

This method matches a path(str) against a pattern.

 protected static boolean  match  (java.lang.String pattern,                                                             java.lang.String str) 

This method matches a path(str) against a pattern.

 public void  setBasedir  (java.lang.String basedir) 

This method sets the basedir from which to scan.

 public void  setBasedir  (java.io.File basedir) 

This method sets the basedir from which to scan.

 public java.io.File  getBasedir  () 

This method returns the basedir from which to scan.

 public void  setIncludes  (java.lang.String[] includes) 

This is the setter method for the includes array.

 public void  setExcludes  (java.lang.String[] excludes) 

This is the setter method for the excludes array.

 public void  scan  () 

This method scans the basedir for files that match one or more include patterns and zero exclude patterns.

 protected void  slowScan  () 

This method invokes a scan.

 protected void  scandir  (java.io.File dir, java.lang.String vpath, boolean fast) 

This method scans the passed dir for files and directories. Found files and directories are placed in the respective collections, based on the matching of includes and excludes. When a directory is found, it is scanned recursively.

 protected boolean  isIncluded  (java.lang.String name) 

This method returns true or false if a name matches at least one include pattern.

 protected boolean  couldHoldIncluded  (java.lang.String name) 

This method returns true or false if a name matches the start of at least one include pattern.

 protected boolean  isExcluded  (java.lang.String name) 

This method returns true or false if a name matches at least one exclude pattern.

 public java.lang.String[]  getIncludedFiles  () 

This is the getter method for the included-files array.

 public java.lang.String[]  getNotIncludedFiles  () 

This is the getter method for the not-included-files array.

 public java.lang.String[]  getExcludedFiles  () 

This is the getter method for the excluded-files array.

 public java.lang.String[]  getIncludedDirectories  () 

This is the getter method for the included-directories array.

 public java.lang.String[]  getNotIncludedDirectories  () 

This is the getter method for the not-included-directories array.

 public java.lang.String[]  getExcludedDirectories  () 

This is the getter method for the excluded-directories array.

 public void addDefaultExcludes() 

This method adds the array with default exclusions to the current exclusions set.

Interface FileScanner

 public Interface FileScanner 

Description

This is an interface that describes the actions required by any type of directory scanner.

Methods

 public void addDefaultExcludes() 

This method adds an array with default exclusions to the current exclusions set.

 public java.io.File  getBasedir  () 

This method gets the basedir to use for scanning.

 public java.lang.String[]  getExcludedDirectories  () 

This method gets the names of the directories that matched one or more of the include patterns and also matched one or more of the exclude patterns.

 public java.lang.String[]  getExcludedFiles  () 

This method gets the names of the files that matched one or more of the include patterns and matched also one or more of the exclude patterns.

 public java.lang.String[]  getIncludedDirectories  () 

This method gets the names of the directories that matched one or more of the include patterns and matched none of the exclude patterns.

 public java.lang.String[]  getIncludedFiles  () 

This method gets the names of the files that matched one or more of the include patterns and matched zero of the exclude patterns.

 public java.lang.String[]  getNotIncludedDirectories  () 

This method gets the names of the directories that matched zero of the include patterns.

 public java.lang.String[]  getNotIncludedFiles  () 

This method gets the names of the files that matched zero of the include patterns.

 public void  scan  () 

This method scans the basedir for files that match one or more include patterns and zero exclude patterns.

 public void  setBasedir  (java.lang.String basedir) 

This method sets the basedir from which to scan, given a String.

 public void  setBasedir  (java.io.File basedir) 

This method sets the basedir from which to scan, given a file.

 public void  setExcludes  (java.lang.String[] excludes) 

This method sets the array of exclude patterns.

 public void  setIncludes  (java.lang.String[] includes) 

This method sets the array of include patterns.

Class IntrospectionHelper

 public class IntrospectionHelper 

Description

IntrospectionHelper collects the methods a task or nested element holds to set or create attributes or elements.

Methods

 public static IntrospectionHelper  getHelper  (java.lang.Class c) 

This method implemente the FactoryMethod design pattern for helper objects.

 public void  setAttribute  (Project p,  java.lang.Object element,                          java.lang.String attributeName,                          java.lang.String value) 

This method sets the named attribute to the given value.

 public void  addText  (java.lang.Object element, java.lang.String text) 

This method adds PCDATA areas.

 public java.lang.Object  createElement  (java.lang.Object element,                                   java.lang.String elementName) 

This method creates a nested element with the given name.

 public java.lang.Class  getElementType  (java.lang.String elementName) 

This method returns the type of the nested element with the given name.

 public java.lang.Class  getAttributeType  (java.lang.String attributeName) 

This method returns the type of an attribute with the given name.

 public boolean supportsCharacters() 

This method returns a true or false value indicating whether the introspected class supports PCDATA.

 public java.util.Enumeration  getAttributes  () 

This is the getter method for an Enumeration of all attributes supported by the introspected class.

 public java.util.Enumeration  getNestedElements  () 

This is the getter method for an Enumeration of all nested elements supported by the introspected class.

Class Main

 public class Main 

Description

This class acts as the command-line entry point into Ant and assembles and executes an Ant project.

Field

 public static final java.lang.String  DEFAULT_BUILD_FILENAME  

This field is the default name of the buildfile.

Methods

 protected  Main  (jatva.lang.String[] args) public static void  main  (java.lang.String[] args) 

This method executes a build using either a given target or the default target.

Class PathTokenizer

 public class PathTokenizer 

Description

A PathTokenizer returns the components that make up a path. The path can use either colons (:) or semicolons (;) as path separators and slashes (/) or backslashes (\) as file separators.

Constructor

 public  PathTokenizer  (java.lang.String path) 

Methods

 public boolean  hasMoreTokens  () 

This method returns true or false indicating whether the string has more tokens.

 public java.lang.String  nextToken  () 

This method returns the next token.

Class Project

 public class Project 

Inheritance Information

Extends: java.lang.Object

Description

The Project class is the main focus of an Ant project and represents the build XML file. This class defines a Ant project with all of its targets and tasks. It also has the ability to execute a build given a specific target name.

Project has a single parameterless constructor, so it can be instantiated with the following syntax:

 Project proj = new Project(); 

Programmatically, the Project class can be used to create an object that will automatically run a set of Ant tasks.

Methods

 public void  init  () 

This method initializes the project. This process involves setting the default task definitions and loading the system properties.

 public void log(java.lang.String msg) 

This method writes the given message to the log.

 public void log(java.lang.String msg,int msgLevel) 

This method writes the given message to the log at the given message level.

 public void  log  (Task task, java.lang.String msg,  int msgLevel) 

This method writes the given message to the log for the given task at the given message level.

 public void  log  (Target target, java.lang.String msg, int msgLevel) 

This method writes the given message to the log for the given target at the given message level.

 public void  setProperty  (java.lang.String name, java.lang.String value) 

This is the setter method for a property in an Ant project given the name and value. For example:

 <property name="phase3.src.dir"        value="../phase3/src"/> 

sets a property called phase3.src.dir to the String value ../phase3/src" .

 public void  setUserProperty  (String name, String value) 

This is the setter method for the UserProperty, given a name and value.

 public java.lang.String  getProperty  (java.lang.String name) 

This is the getter method for a property with the given name.

 public java.lang.String  getUserProperty  (java.lang.String name) 

This is the getter method for a UserProperty with the given name.

 public java.util.Hashtable  getProperties  () 

This method gets a hashtable of the properties belonging to the project.

 public java.util.Hashtable  getUserProperties  () 

This method gets a hashtable of the UserProperties belonging to the project.

 public void  setDefaultTarget  (java.lang.String defaultTarget) 

This method sets the default target for a project.

 public java.lang.String  getDefaultTarget  () 

This method returns a String representation for the default target for a project.

 public void  setDefault  (java.lang.String defaultTarget) 

This method sets the default target for a project.

 public void  setName  (java.lang.String name) 

This method sets the name for a project.

 public java.lang.String  getName  () 

This method gets the name of the project.

 public void  addFilter  (java.lang.String token,  java.lang.String value) 

This method adds a filter to the given project.

 public java.util.Hashtable  getFilters  () 

This method returns a hashtable of the filters belonging to the project.

 public void  setBasedir  (java.lang.String baseD) 

This method sets the baseDir property of the project to a file resolved to the given String.

 public void  setBasedir  (java.io.File basedir) 

This method sets the baseDir property of the project to a file resolved to the given file.

 public java.io.File  getBasedir  () 

This method returns a file representation of the project s baseDir property.

 public static java.lang.String  getJavaVersion  () 

This method returns the Java version property of the project.

 public void setJavaVersionProperty() 

This method sets the Java version property of the project.

 public void  addTaskDefinition  (java.lang.String taskName,                               java.lang.Class taskClass) 

This method adds a task to the project based on the name and class parameters.

 public java.util.Hashtable  getTaskDefinitions  () 

This method returns a hashtable of the TaskDefinitions belonging to the project.

 public void  addDataTypeDefinition  (java.lang.String typeName,                                   java.lang.Class typeClass) 

This method adds a DataTypeDefinition to the collection belonging to the project.

 public java.util.Hashtable  getDataTypeDefinitions  () 

This method gets a hashtable of the DataTypeDefinitions belonging to the project.

 public void  addTarget  (Target target) 

This method adds a target to the project, matching the parameter.

 public void  addTarget  (java.lang.String targetName, Target target) 

This method adds a target to the project, matching the parameter.

 public void  addOrReplaceTarget  (Target target) 

This method adds a target to the project, matching the parameter, or replaces it if it already exists.

 public void  addOrReplaceTarget  (java.lang.String targetName, Target target) 

This method adds a target to the project, matching the parameters, or replaces it if it already exists.

 public java.util.Hashtable  getTargets  () 

This method returns a hashtable of the Target objects belonging to the project.

 public Task  createTask  (java.lang.String taskType) 

This method returns a new task of the given task type within the scope of the project.

 public void  executeTargets  (java.util.Vector targetNames) 

This method calls execute() on each target within the given collection.

 public void  executeTarget  (java.lang.String targetName) 

This method calls execute() on the given target.

 public static java.lang.String  translatePath  (java.lang.String to_process) 

This method translates a path into its native (platform-specific) format using a PathTokenizer.

 public void  copyFile  (java.lang.String sourceFile,                      java.lang.String destFile) 

This is a convenience method to copy a file from a source to a destination without filtering.

 public void  copyFile  (java.lang.String sourceFile,                      java.lang.String destFile, boolean filtering) 

This is a convenience method to copy a file from a source to a destination given a Boolean to indicate whether token filtering must be used.

 public void  copyFile  (java.lang.String sourceFile,                      java.lang.String destFile,                              boolean filtering, boolean overwrite) 

This is a convenience method to copy a file from a source to a destination given Booleans to indicate whether token filtering must be used and whether source files may overwrite newer destination files.

 public void  copyFile  (java.lang.String sourceFile,                      java.lang.String destFile,                          boolean filtering, boolean overwrite,                          boolean preserveLastModified) 

This is a convenience method to copy a file from a source to a destination given Booleans to indicate whether token filtering must be used, whether source files may overwrite newer destination files, and whether the last modified time of destFile file should be made equal to the last modified time of sourceFile.

 public void  copyFile  (java.io.File sourceFile, java.io.File destFile) 

This is a convenience method to copy a file from a source to a destination without filtering.

 public void  copyFile  (java.io.File sourceFile,                      java.io.File destFile,                          boolean filtering) 

This is a convenience method to copy a file from a source to a destination given a Boolean to indicate whether token filtering must be used.

 public void  copyFile  (java.io.File sourceFile,                      java.io.File destFile,                          boolean filtering, boolean overwrite) 

This is a convenience method to copy a file from a source to a destination given Booleans to indicate whether token filtering must be used and whether source files may overwrite newer destination files.

 public void  copyFile  (java.io.File sourceFile,                      java.io.File destFile,                              boolean filtering, boolean overwrite,                          boolean preserveLastModified) 

This is a convenience method to copy a file from a source to a destination given Booleans to indicate whether token filtering must be used, whether source files may overwrite newer destination files, and whether the last modified time of destFile file should be made equal to the last modified time of sourceFile.

 public static boolean  toBoolean  (java.lang.String s) 

This method returns the Boolean equivalent of a String, which is considered true if "on", "true", or "yes" is found, ignoring case.

 public void  runTarget  (Target target) public final java.util.Vector  topoSort  (java.lang.String root,                                                java.util.Hashtable targets) 

This method returns a Vector that is a topologically sorted set of targets given a root (the [String] name of the root target). The sort is created in such a way that the sequence of targets until the root target is the minimum possible such sequence.

 public void  addReference  (java.lang.String name, java.lang.Object value) 

This method adds a reference to the project, given a name and value.

 public java.util.Hashtable  getReferences  () 

This method returns a hashtable of the Reference objects belonging to the project.

Class ProjectHelper

 public class ProjectHelper 

Description

ProjectHelper will configure a project (complete with targets and tasks) based on an XML buildfile.

Methods

 public static void  configureProject  (Project project,                                     java.io.File buildFile) 

This method configures the project with the contents of the given XML file.

 public static void  configure  (java.lang.Object target,               org.xml.sax.AttributeList attrs, Project project) public static void  addText  (java.lang.Object target, char[] buf,                            int start, int end) 

This method adds the contents of #PCDATA(buf) sections to an element from start to end.

 public static void  addText  (java.lang.Object target,                            java.lang.String text) 

This method adds the contents of #PCDATA(target) sections to an element.

 public static String  replaceProperties  (Project project,                           String value, Hashtable keys) 

This method replaces the property at ${NAME} with the given value.

Class RuntimeConfigurable

 public class RuntimeConfigurable 

Description

RuntimeConfigurable is a wrapper class that maintains the attributes of a task and configures it at runtime.

Constructor

 public  RuntimeConfigurable  (java.lang.Object proxy) 

This constructor initializes the element to wrap (proxy).

Methods

 public void  setAttributes  (org.xml.sax.AttributeList attributes) 

This is the setter method for the attributes for the wrapped element.

 public org.xml.sax.AttributeList  getAttributes  () 

This is the getter method for the attributes for the wrapped element.

 public void  addChild  (RuntimeConfigurable child) 

This method adds a child element to the wrapped element.

 public void  addText  (java.lang.String data) 

This method adds characters from #PCDATA(data) areas to the wrapped element.

 public void  addText  (char[] buf,  int start, int end) 

This method adds the contents of #PCDATA(buf) sections to an element.

 public void  maybeConfigure  (Project p) 

This method configures the wrapped element and all children within the given project space unless it has already been done.

Class Target

 public class target 

Inheritance Information

Extends: java.lang.Object

Description

This class implements a collection of work in Ant. A target lives within an Ant project and can contain its own targets and tasks.

Methods

 public void  setProject  (Project project) 

This is the setter method for the parent project.

 public Project  getProject  () 

This is the getter method for the parent project.

 public void  setDepends  (java.lang.String depS) 

This method sets the depends property for the target. For example:

 <target depends="prepare" description="Compile the source tree" name="compile"> 

sets the depends property for the compile target to the entity named Prepare within the project s scope.

 public void  setName  (java.lang.String name) 

This is the setter method for the name attribute.

 public java.lang.String  getName  () 

This is the getter method for the name attribute.

 public void  addTask  (Task task) 

This method adds the given task to the target s definition. For example:

 <target name="prepare" depends="set-version">             <mkdir dir="${build.dir}"/>       </target> 

adds a mkdir(type) task to the target named prepare.

 public Task[]  getTasks  () 

This is the getter method for the current set of tasks to be executed by this target.

 public void  addDependency  (java.lang.String dependency) 

This method adds a dependency attribute to the task.

 public java.util.Enumeration  getDependencies  () 

This method returns a collection of dependencies associated with the target.

 public void  setIf  (java.lang.String property) 

This is the setter method for the If property.

 public void  setUnless  (java.lang.String property) 

This is the setter method for the Unless property.

 public void  setDescription  (java.lang.String description) 

This is the setter method for the Description property.

 public java.lang.String  getDescription  () 

This is the getter method for the Description property.

 public java.lang.String  toString  () 

This method overrides method in String.

 public void  execute  () throws BuildException 

This is the key method when you re using this target. It will call execute() on all tasks within the target.

Class Task

 public class Task 

Inheritance Information

Extends: java.lang.Object

Description

You know that in Ant, a task is defined as a unit of work. A practical example of a task would be to delete a directory or a file, to check the latest version of a class out from a source control system, or to send an email message to your system administrator informing him that a build was successful or that it failed (along with the reasons why). All these tasks are part of the existing Ant framework, but as a developer you may need to create a new task customized to your (or your client s) specific processes and/or needs. For instance, you may want to set up a custom task to make an entry in a database or a spreadsheet, or you may want to restart system services (or restart the Unreal Tournament server that coexists in your production environment). To create a custom task, you create a class that directly or indirectly extends org.apache.tools.ant.Task.

The key method of a given Task object is the execute() method. When you re creating a new task, the execute() method will contain the framework for the job to be performed. When a task is executed, an object of the org.apache.ant.Task class is instantiated and configured and then executes to perform a specific function.

An oversimplified example implementation of a new custom task is listed here:

 package org.apache.tools.ant.taskdefs; import org.apache.tools.ant.*; public class GreetJon extends Task {     public void execute() throws BuildException{         System.out.println("Hello Jon!");     } } 

For each property created in a task, there should be public setter and getter methods. The properties built into the abstract class Task are as follows :

The only constructor for Task has no parameters, but for practical purposes it will probably be instantiated and initialized within a project using the createTask() method.

It is important to remember that a task usually exists within the scope of both a project and one or more of its child targets.

Methods

 public  Project  getProject() 

This is the getter method for the project to which this task belongs.

 public void  setOwningTarget  (Target target) 

This is the setter method for the owning target object of this task.

 public Target  getOwningTarget  () 

This is the getter method for the owning target object of this task.

 ublic void  setTaskName  (java.lang.String name) 

This is the setter method for the name property to use in logging messages.

 public java.lang.String  getTaskName  () 

This is the getter method for the name property to use in logging messages.

 public void  log  (java.lang.String msg) 

This method logs a message with the default ( INFO ) priority.

 public void  log  (java.lang.String msg, int msgLevel) 

This method logs a message with the given priority.

 public void  setDescription  (java.lang.String desc) 

This is the setter method for the description of the current action.

 public java.lang.String  getDescription  () 

This is the getter method for the description of the current action.

 public void  init  () 

This method is called by the project to let the task initialize properly.

 public void  execute  ()throws BuildException 

This method is called by the project or target to execute the task.

 public Location  getLocation  () 

This method returns the file location where this task was defined.

 public void  setLocation  (Location location) 

This is the setter method for the file location where this task is defined.

 public RuntimeConfigurable  getRuntimeConfigurableWrapper  () 

This is the getter method for the wrapper class for runtime configuration.

 public void  maybeConfigure  () 

This method configures this task, unless it has already been done.

Class TaskAdapter

 public class TaskAdapter 

Inheritance Information

Extends: Task

Description

TaskAdapter uses introspection to adapt a bean (using the Bridge design pattern).

Methods

 public void  execute  () 

This method executes the adapted task.

 public void  setProxy  (java.lang.Object o) 

This is the setter method for the target object class.

 public java.lang.Object  getProxy  () 

This is the getter method for the target object class.

Class UnknownElement

public class UnknownElement

Description

UnknownElement is a class that wraps all information necessary to create a task that did not exist when Ant started.

Constructor

public UnknownElement (java.lang.String elementName)

Methods

 public java.lang.String  getTag  () 

This is the getter method for the corresponding XML tag.

 public void  maybeConfigure  () 

This method configures this task, unless its been done already.

 public void  execute  () 

This method executes when the real task has been configured for the first time.

 public void  addChild  (UnknownElement child) 

This method adds a child element.

 protected void  handleChildren  (java.lang.Object parent, RuntimeConfigurable parentWrapper) 

This method executes children.

Class XmlLogger

 public class XmlLogger 

Inheritance Information

Extends: org.apache.tools.ant.XmlLogger

Implements: BuildListener, java.util.EventListener

Description

XmlLogger creates a file (log.xml) in the current directory with an XML description of what happened during a build.

Constructor

 public  XmlLogger  () 

This constructor initializes a new XmlLogger that logs build events to an XML file.

Methods

 public void  buildStarted  (BuildEvent event) 

This method executes before any targets are started.

 public void  buildFinished  (BuildEvent event) 

This method executes after the last target has finished, whether or not errors occurred.

 public void  targetStarted  (BuildEvent event) 

This method executes when a target is started.

 public void  targetFinished  (BuildEvent event) 

This method executes when a target has finished, whether or not errors occurred.

 public void  taskStarted  (BuildEvent event) 

This method executes when a task is started.

 public void  taskFinished  (BuildEvent event) 

This method executes when a task has finished, whether or not errors occurred.

 public void  messageLogged  (BuildEvent event) 

This method executes whenever a message is logged.




Professional Java Tools for Extreme Programming
Professional Java Tools for Extreme Programming: Ant, XDoclet, JUnit, Cactus, and Maven (Programmer to Programmer)
ISBN: 0764556177
EAN: 2147483647
Year: 2003
Pages: 228

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net