org.apache.tools.ant
Class Project

java.lang.Object
  |
  +--org.apache.tools.ant.Project

public class Project
extends java.lang.Object

Central representation of an Ant project. This class defines a Ant project with all of it's targets and tasks. It also provides the mechanism to kick off a build using a particular target name.

This class also encapsulates methods which allow Files to be refered to using abstract path names which are translated to native system file paths at runtime as well as defining various project properties.

Author:
duncan@x180.com

Field Summary
static java.lang.String JAVA_1_0
           
static java.lang.String JAVA_1_1
           
static java.lang.String JAVA_1_2
           
static java.lang.String JAVA_1_3
           
static java.lang.String JAVA_1_4
           
static int MSG_DEBUG
           
static int MSG_ERR
           
static int MSG_INFO
           
static int MSG_VERBOSE
           
static int MSG_WARN
           
static java.lang.String TOKEN_END
           
static java.lang.String TOKEN_START
           
 
Constructor Summary
Project()
           
 
Method Summary
 void addBuildListener(BuildListener listener)
           
 void addDataTypeDefinition(java.lang.String typeName, java.lang.Class typeClass)
           
 void addFilter(java.lang.String token, java.lang.String value)
          Deprecated.  
 void addOrReplaceTarget(java.lang.String targetName, Target target)
           
 void addOrReplaceTarget(Target target)
           
 void addReference(java.lang.String name, java.lang.Object value)
           
 void addTarget(java.lang.String targetName, Target target)
          This call expects to add a new Target.
 void addTarget(Target target)
          This call expects to add a new Target.
 void addTaskDefinition(java.lang.String taskName, java.lang.Class taskClass)
           
 void copyFile(java.io.File sourceFile, java.io.File destFile)
          Deprecated.  
 void copyFile(java.io.File sourceFile, java.io.File destFile, boolean filtering)
          Deprecated.  
 void copyFile(java.io.File sourceFile, java.io.File destFile, boolean filtering, boolean overwrite)
          Deprecated.  
 void copyFile(java.io.File sourceFile, java.io.File destFile, boolean filtering, boolean overwrite, boolean preserveLastModified)
          Deprecated.  
 void copyFile(java.lang.String sourceFile, java.lang.String destFile)
          Deprecated.  
 void copyFile(java.lang.String sourceFile, java.lang.String destFile, boolean filtering)
          Deprecated.  
 void copyFile(java.lang.String sourceFile, java.lang.String destFile, boolean filtering, boolean overwrite)
          Deprecated.  
 void copyFile(java.lang.String sourceFile, java.lang.String destFile, boolean filtering, boolean overwrite, boolean preserveLastModified)
          Deprecated.  
 java.lang.Object createDataType(java.lang.String typeName)
           
 Task createTask(java.lang.String taskType)
           
 void demuxOutput(java.lang.String line, boolean isError)
           
 void executeTarget(java.lang.String targetName)
           
 void executeTargets(java.util.Vector targetNames)
           
protected  void fireBuildFinished(java.lang.Throwable exception)
           
protected  void fireBuildStarted()
           
protected  void fireMessageLogged(Project project, java.lang.String message, int priority)
           
protected  void fireMessageLogged(Target target, java.lang.String message, int priority)
           
protected  void fireMessageLogged(Task task, java.lang.String message, int priority)
           
protected  void fireTargetFinished(Target target, java.lang.Throwable exception)
           
protected  void fireTargetStarted(Target target)
           
protected  void fireTaskFinished(Task task, java.lang.Throwable exception)
           
protected  void fireTaskStarted(Task task)
           
 java.io.File getBaseDir()
           
 java.util.Vector getBuildListeners()
           
 java.lang.ClassLoader getCoreLoader()
           
 java.util.Hashtable getDataTypeDefinitions()
           
 java.lang.String getDefaultTarget()
           
 java.lang.String getDescription()
           
 java.util.Hashtable getFilters()
          Deprecated.  
 FilterSet getGlobalFilterSet()
           
static java.lang.String getJavaVersion()
           
 java.lang.String getName()
           
 java.util.Hashtable getProperties()
           
 java.lang.String getProperty(java.lang.String name)
           
 java.util.Hashtable getReferences()
           
 java.util.Hashtable getTargets()
           
 java.util.Hashtable getTaskDefinitions()
           
 java.util.Hashtable getUserProperties()
           
 java.lang.String getUserProperty(java.lang.String name)
           
 void init()
          Initialise the project.
 void log(java.lang.String msg)
           
 void log(java.lang.String msg, int msgLevel)
           
 void log(Target target, java.lang.String msg, int msgLevel)
           
 void log(Task task, java.lang.String msg, int msgLevel)
           
 void removeBuildListener(BuildListener listener)
           
 java.io.File resolveFile(java.lang.String fileName)
           
 java.io.File resolveFile(java.lang.String fileName, java.io.File rootDir)
          Deprecated.  
 void setBaseDir(java.io.File baseDir)
           
 void setBasedir(java.lang.String baseD)
           
 void setCoreLoader(java.lang.ClassLoader coreLoader)
           
 void setDefault(java.lang.String defaultTarget)
           
 void setDefaultTarget(java.lang.String defaultTarget)
           
 void setDescription(java.lang.String description)
           
 void setFileLastModified(java.io.File file, long time)
          Deprecated.  
 void setJavaVersionProperty()
           
 void setName(java.lang.String name)
           
 void setProperty(java.lang.String name, java.lang.String value)
           
 void setSystemProperties()
           
 void setUserProperty(java.lang.String name, java.lang.String value)
           
static boolean toBoolean(java.lang.String s)
          returns the boolean equivalent of a string, which is considered true if either "on", "true", or "yes" is found, ignoring case.
 java.util.Vector topoSort(java.lang.String root, java.util.Hashtable targets)
          Topologically sort a set of Targets.
static java.lang.String translatePath(java.lang.String to_process)
          Translate a path into its native (platform specific) format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MSG_ERR

public static final int MSG_ERR

MSG_WARN

public static final int MSG_WARN

MSG_INFO

public static final int MSG_INFO

MSG_VERBOSE

public static final int MSG_VERBOSE

MSG_DEBUG

public static final int MSG_DEBUG

JAVA_1_0

public static final java.lang.String JAVA_1_0

JAVA_1_1

public static final java.lang.String JAVA_1_1

JAVA_1_2

public static final java.lang.String JAVA_1_2

JAVA_1_3

public static final java.lang.String JAVA_1_3

JAVA_1_4

public static final java.lang.String JAVA_1_4

TOKEN_START

public static final java.lang.String TOKEN_START

TOKEN_END

public static final java.lang.String TOKEN_END
Constructor Detail

Project

public Project()
Method Detail

init

public void init()
          throws BuildException
Initialise the project. This involves setting the default task definitions and loading the system properties.

setCoreLoader

public void setCoreLoader(java.lang.ClassLoader coreLoader)

getCoreLoader

public java.lang.ClassLoader getCoreLoader()

addBuildListener

public void addBuildListener(BuildListener listener)

removeBuildListener

public void removeBuildListener(BuildListener listener)

getBuildListeners

public java.util.Vector getBuildListeners()

log

public void log(java.lang.String msg)

log

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

log

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

log

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

getGlobalFilterSet

public FilterSet getGlobalFilterSet()

setProperty

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

setUserProperty

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

getProperty

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

getUserProperty

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

getProperties

public java.util.Hashtable getProperties()

getUserProperties

public java.util.Hashtable getUserProperties()

setDefaultTarget

public void setDefaultTarget(java.lang.String defaultTarget)

getDefaultTarget

public java.lang.String getDefaultTarget()

setDefault

public void setDefault(java.lang.String defaultTarget)

setName

public void setName(java.lang.String name)

getName

public java.lang.String getName()

setDescription

public void setDescription(java.lang.String description)

getDescription

public java.lang.String getDescription()

addFilter

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


getFilters

public java.util.Hashtable getFilters()
Deprecated.  


setBasedir

public void setBasedir(java.lang.String baseD)
                throws BuildException

setBaseDir

public void setBaseDir(java.io.File baseDir)
                throws BuildException

getBaseDir

public java.io.File getBaseDir()

getJavaVersion

public static java.lang.String getJavaVersion()

setJavaVersionProperty

public void setJavaVersionProperty()

setSystemProperties

public void setSystemProperties()

addTaskDefinition

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

getTaskDefinitions

public java.util.Hashtable getTaskDefinitions()

addDataTypeDefinition

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

getDataTypeDefinitions

public java.util.Hashtable getDataTypeDefinitions()

addTarget

public void addTarget(Target target)
This call expects to add a new Target.
Parameters:
target - is the Target to be added to the current Project.
Throws:
BuildException - if the Target already exists in the project.
See Also:
to replace existing Targets.

addTarget

public void addTarget(java.lang.String targetName,
                      Target target)
               throws BuildException
This call expects to add a new Target.
Parameters:
target - is the Target to be added to the current Project.
targetName - is the name to use for the Target
Throws:
BuildException - if the Target already exists in the project.
See Also:
to replace existing Targets.

addOrReplaceTarget

public void addOrReplaceTarget(Target target)
Parameters:
target - is the Target to be added or replaced in the current Project.

addOrReplaceTarget

public void addOrReplaceTarget(java.lang.String targetName,
                               Target target)
Parameters:
target - is the Target to be added/replaced in the current Project.
targetName - is the name to use for the Target

getTargets

public java.util.Hashtable getTargets()

createTask

public Task createTask(java.lang.String taskType)
                throws BuildException

createDataType

public java.lang.Object createDataType(java.lang.String typeName)
                                throws BuildException

executeTargets

public void executeTargets(java.util.Vector targetNames)
                    throws BuildException

demuxOutput

public void demuxOutput(java.lang.String line,
                        boolean isError)

executeTarget

public void executeTarget(java.lang.String targetName)
                   throws BuildException

resolveFile

public java.io.File resolveFile(java.lang.String fileName,
                                java.io.File rootDir)
Deprecated.  

Return the canonical form of fileName as an absolute path.

If fileName is a relative file name, resolve it relative to rootDir.


resolveFile

public java.io.File resolveFile(java.lang.String fileName)

translatePath

public static java.lang.String translatePath(java.lang.String to_process)
Translate a path into its native (platform specific) format.

This method uses the PathTokenizer class to separate the input path into its components. This handles DOS style paths in a relatively sensible way. The file separators are then converted to their platform specific versions.

Parameters:
to_process - the path to be converted
Returns:
the native version of to_process or an empty string if to_process is null or empty

copyFile

public void copyFile(java.lang.String sourceFile,
                     java.lang.String destFile)
              throws java.io.IOException
Deprecated.  

Convienence method to copy a file from a source to a destination. No filtering is performed.
Throws:
java.io.IOException -  

copyFile

public void copyFile(java.lang.String sourceFile,
                     java.lang.String destFile,
                     boolean filtering)
              throws java.io.IOException
Deprecated.  

Convienence method to copy a file from a source to a destination specifying if token filtering must be used.
Throws:
java.io.IOException -  

copyFile

public void copyFile(java.lang.String sourceFile,
                     java.lang.String destFile,
                     boolean filtering,
                     boolean overwrite)
              throws java.io.IOException
Deprecated.  

Convienence method to copy a file from a source to a destination specifying if token filtering must be used and if source files may overwrite newer destination files.
Throws:
java.io.IOException -  

copyFile

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

Convienence method to copy a file from a source to a destination specifying if token filtering must be used, if source files may overwrite newer destination files and the last modified time of destFile file should be made equal to the last modified time of sourceFile.
Throws:
java.io.IOException -  

copyFile

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

Convienence method to copy a file from a source to a destination. No filtering is performed.
Throws:
java.io.IOException -  

copyFile

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

Convienence method to copy a file from a source to a destination specifying if token filtering must be used.
Throws:
java.io.IOException -  

copyFile

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

Convienence method to copy a file from a source to a destination specifying if token filtering must be used and if source files may overwrite newer destination files.
Throws:
java.io.IOException -  

copyFile

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

Convienence method to copy a file from a source to a destination specifying if token filtering must be used, if source files may overwrite newer destination files and the last modified time of destFile file should be made equal to the last modified time of sourceFile.
Throws:
java.io.IOException -  

setFileLastModified

public void setFileLastModified(java.io.File file,
                                long time)
                         throws BuildException
Deprecated.  

Calls File.setLastModified(long time) in a Java 1.1 compatible way.

toBoolean

public static boolean toBoolean(java.lang.String s)
returns the boolean equivalent of a string, which is considered true if either "on", "true", or "yes" is found, ignoring case.

topoSort

public final java.util.Vector topoSort(java.lang.String root,
                                       java.util.Hashtable targets)
                                throws BuildException
Topologically sort a set of Targets.
Parameters:
root - is the (String) name of the root Target. The sort is created in such a way that the sequence of Targets uptil the root target is the minimum possible such sequence.
targets - is a Hashtable representing a "name to Target" mapping
Returns:
a Vector of Strings with the names of the targets in sorted order.
Throws:
BuildException - if there is a cyclic dependency among the Targets, or if a Target does not exist.

addReference

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

getReferences

public java.util.Hashtable getReferences()

fireBuildStarted

protected void fireBuildStarted()

fireBuildFinished

protected void fireBuildFinished(java.lang.Throwable exception)

fireTargetStarted

protected void fireTargetStarted(Target target)

fireTargetFinished

protected void fireTargetFinished(Target target,
                                  java.lang.Throwable exception)

fireTaskStarted

protected void fireTaskStarted(Task task)

fireTaskFinished

protected void fireTaskFinished(Task task,
                                java.lang.Throwable exception)

fireMessageLogged

protected void fireMessageLogged(Project project,
                                 java.lang.String message,
                                 int priority)

fireMessageLogged

protected void fireMessageLogged(Target target,
                                 java.lang.String message,
                                 int priority)

fireMessageLogged

protected void fireMessageLogged(Task task,
                                 java.lang.String message,
                                 int priority)


Copyright © 1999-2002 Apache Software Foundation. All Rights Reserved.