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
protected  Target currentTarget
           
protected  Task currentTask
           
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 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 addFilter(java.lang.String token, java.lang.String value)
           
 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)
          Convienence method to copy a file from a source to a destination.
 void copyFile(java.io.File sourceFile, java.io.File destFile, boolean filtering)
          Convienence method to copy a file from a source to a destination specifying if token filtering must be used.
 void copyFile(java.lang.String sourceFile, java.lang.String destFile)
          Convienence method to copy a file from a source to a destination.
 void copyFile(java.lang.String sourceFile, java.lang.String destFile, boolean filtering)
          Convienence method to copy a file from a source to a destination specifying if token filtering must be used.
 BuildEvent createBuildEvent()
           
 BuildEvent createBuildEvent(java.lang.String msg, int priority)
           
 BuildEvent createBuildEvent(java.lang.Throwable exception)
           
 Task createTask(java.lang.String taskType)
           
 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(java.lang.String message, int priority)
           
protected  void fireTargetFinished(java.lang.Throwable exception)
           
protected  void fireTargetStarted()
           
protected  void fireTaskFinished(java.lang.Throwable exception)
           
protected  void fireTaskStarted()
           
 java.io.File getBaseDir()
           
 java.util.Vector getBuildListeners()
           
 java.lang.String getDefaultTarget()
           
 java.util.Hashtable getFilters()
           
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 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(java.lang.String msg, java.lang.String tag, int msgLevel)
           
 void removeBuildListener(BuildListener listener)
           
 java.io.File resolveFile(java.lang.String fileName)
           
 void setBaseDir(java.io.File baseDir)
           
 void setBasedir(java.lang.String baseD)
           
 void setDefault(java.lang.String defaultTarget)
           
 void setDefaultTarget(java.lang.String defaultTarget)
           
 void setName(java.lang.String name)
           
 void setProperty(java.lang.String name, java.lang.String value)
           
 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.lang.String translatePath(java.lang.String to_process)
          Translate a path into its native (platform specific) path.
 
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

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

TOKEN_START

public static final java.lang.String TOKEN_START

TOKEN_END

public static final java.lang.String TOKEN_END

currentTarget

protected Target currentTarget

currentTask

protected Task currentTask
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.

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(java.lang.String msg,
                java.lang.String tag,
                int msgLevel)

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()

addFilter

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

getFilters

public java.util.Hashtable getFilters()

setBasedir

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

setBaseDir

public void setBaseDir(java.io.File baseDir)

getBaseDir

public java.io.File getBaseDir()

getJavaVersion

public static java.lang.String getJavaVersion()

addTaskDefinition

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

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

executeTargets

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

executeTarget

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

resolveFile

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

translatePath

public java.lang.String translatePath(java.lang.String to_process)
Translate a path into its native (platform specific) path. This should be extremely fast, code is borrowed from ECS project.

All it does is translate the : into ; and / into \ if needed. In other words, it isn't perfect.


copyFile

public void copyFile(java.lang.String sourceFile,
                     java.lang.String destFile)
              throws java.io.IOException
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
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)
              throws java.io.IOException
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
Convienence method to copy a file from a source to a destination specifying if token filtering must be used.
Throws:
java.io.IOException -  

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.

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()

fireTargetFinished

protected void fireTargetFinished(java.lang.Throwable exception)

fireTaskStarted

protected void fireTaskStarted()

fireTaskFinished

protected void fireTaskFinished(java.lang.Throwable exception)

fireMessageLogged

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

createBuildEvent

public BuildEvent createBuildEvent()

createBuildEvent

public BuildEvent createBuildEvent(java.lang.String msg,
                                   int priority)

createBuildEvent

public BuildEvent createBuildEvent(java.lang.Throwable exception)


Copyright © 2000 Apache Software Foundation. All Rights Reserved.