Save This Page
Home » apache-ant-1.8.1 » org.apache.tools » ant » [javadoc | source]
org.apache.tools.ant
public class: Project [javadoc | source]
java.lang.Object
   org.apache.tools.ant.Project

All Implemented Interfaces:
    ResourceFactory

Central representation of an Ant project. This class defines an Ant project with all of its targets, tasks and various other properties. 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 referred to using abstract path names which are translated to native system file paths at runtime.
Field Summary
public static final  int MSG_ERR    Message priority of "error". 
public static final  int MSG_WARN    Message priority of "warning". 
public static final  int MSG_INFO    Message priority of "information". 
public static final  int MSG_VERBOSE    Message priority of "verbose". 
public static final  int MSG_DEBUG    Message priority of "debug". 
public static final  String JAVA_1_0    Version constant for Java 1.0 .
     
    public static final  String JAVA_1_1    Version constant for Java 1.1 .
       
      public static final  String JAVA_1_2    Version constant for Java 1.2 .
         
        public static final  String JAVA_1_3    Version constant for Java 1.3 .
           
          public static final  String JAVA_1_4    Version constant for Java 1.4 .
             
            public static final  String TOKEN_START    Default filter start token. 
            public static final  String TOKEN_END    Default filter end token. 
            Constructor:
             public Project() 
            Method from org.apache.tools.ant.Project Summary:
            addBuildListener,   addDataTypeDefinition,   addFilter,   addIdReference,   addOrReplaceTarget,   addOrReplaceTarget,   addReference,   addTarget,   addTarget,   addTaskDefinition,   checkTaskClass,   copyFile,   copyFile,   copyFile,   copyFile,   copyFile,   copyFile,   copyFile,   copyFile,   copyInheritedProperties,   copyUserProperties,   createClassLoader,   createClassLoader,   createDataType,   createSubProject,   createTask,   defaultInput,   demuxFlush,   demuxInput,   demuxOutput,   executeSortedTargets,   executeTarget,   executeTargets,   fireBuildFinished,   fireBuildStarted,   fireMessageLogged,   fireMessageLogged,   fireMessageLogged,   fireMessageLogged,   fireMessageLogged,   fireMessageLogged,   fireSubBuildFinished,   fireSubBuildStarted,   fireTargetFinished,   fireTargetStarted,   fireTaskFinished,   fireTaskStarted,   getBaseDir,   getBuildListeners,   getCopyOfDataTypeDefinitions,   getCopyOfReferences,   getCopyOfTargets,   getCopyOfTaskDefinitions,   getCoreLoader,   getDataTypeDefinitions,   getDefaultInputStream,   getDefaultTarget,   getDescription,   getElementName,   getExecutor,   getFilters,   getGlobalFilterSet,   getInheritedProperties,   getInputHandler,   getJavaVersion,   getName,   getProject,   getProperties,   getProperty,   getReference,   getReferences,   getResource,   getTargets,   getTaskDefinitions,   getThreadTask,   getUserProperties,   getUserProperty,   hasReference,   inheritIDReferences,   init,   initProperties,   initSubProject,   isKeepGoingMode,   log,   log,   log,   log,   log,   log,   log,   registerThreadTask,   removeBuildListener,   replaceProperties,   resolveFile,   resolveFile,   setBaseDir,   setBasedir,   setCoreLoader,   setDefault,   setDefaultInputStream,   setDefaultTarget,   setDescription,   setExecutor,   setFileLastModified,   setInheritedProperty,   setInputHandler,   setJavaVersionProperty,   setKeepGoingMode,   setName,   setNewProperty,   setProjectReference,   setProperty,   setSystemProperties,   setUserProperty,   toBoolean,   topoSort,   topoSort,   topoSort,   translatePath
            Methods from java.lang.Object:
            clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
            Method from org.apache.tools.ant.Project Detail:
             public  void addBuildListener(BuildListener listener) 
              Add a build listener to the list. This listener will be notified of build events for this project.
             public  void addDataTypeDefinition(String typeName,
                Class typeClass) 
              Add a new datatype definition. Attempting to override an existing definition with an equivalent one (i.e. with the same classname) results in a verbose log message. Attempting to override an existing definition with a different one results in a warning log message, but the definition is changed.
             public  void addFilter(String token,
                String value) 
            Deprecated! since - 1.4.x. Use getGlobalFilterSet().addFilter(token,value)

              Add a filter to the set of global filters.
             public  void addIdReference(String id,
                Object value) 
              Add an id reference. Used for broken build files.
             public  void addOrReplaceTarget(Target target) 
              Add a target to the project, or replaces one with the same name.
             public  void addOrReplaceTarget(String targetName,
                Target target) 
              Add a target to the project, or replaces one with the same name.
             public  void addReference(String referenceName,
                Object value) 
              Add a reference to the project.
             public  void addTarget(Target target) throws BuildException 
              Add a new target to the project.
             public  void addTarget(String targetName,
                Target target) throws BuildException 
              Add a new target to the project.
             public  void addTaskDefinition(String taskName,
                Class taskClass) throws BuildException 
              Add a new task definition to the project. Attempting to override an existing definition with an equivalent one (i.e. with the same classname) results in a verbose log message. Attempting to override an existing definition with a different one results in a warning log message and invalidates any tasks which have already been created with the old definition.
             public  void checkTaskClass(Class taskClass) throws BuildException 
              Check whether or not a class is suitable for serving as Ant task. Ant task implementation classes must be public, concrete, and have a no-arg constructor.
             public  void copyFile(String sourceFile,
                String destFile) throws IOException 
            Deprecated! since - 1.4.x

              Convenience method to copy a file from a source to a destination. No filtering is performed.
             public  void copyFile(File sourceFile,
                File destFile) throws IOException 
            Deprecated! since - 1.4.x

              Convenience method to copy a file from a source to a destination. No filtering is performed.
             public  void copyFile(String sourceFile,
                String destFile,
                boolean filtering) throws IOException 
            Deprecated! since - 1.4.x

              Convenience method to copy a file from a source to a destination specifying if token filtering should be used.
             public  void copyFile(File sourceFile,
                File destFile,
                boolean filtering) throws IOException 
            Deprecated! since - 1.4.x

              Convenience method to copy a file from a source to a destination specifying if token filtering should be used.
             public  void copyFile(String sourceFile,
                String destFile,
                boolean filtering,
                boolean overwrite) throws IOException 
            Deprecated! since - 1.4.x

              Convenience method to copy a file from a source to a destination specifying if token filtering should be used and if source files may overwrite newer destination files.
             public  void copyFile(File sourceFile,
                File destFile,
                boolean filtering,
                boolean overwrite) throws IOException 
            Deprecated! since - 1.4.x

              Convenience method to copy a file from a source to a destination specifying if token filtering should be used and if source files may overwrite newer destination files.
             public  void copyFile(String sourceFile,
                String destFile,
                boolean filtering,
                boolean overwrite,
                boolean preserveLastModified) throws IOException 
            Deprecated! since - 1.4.x

              Convenience method to copy a file from a source to a destination specifying if token filtering should be used, if source files may overwrite newer destination files, and if the last modified time of the resulting file should be set to that of the source file.
             public  void copyFile(File sourceFile,
                File destFile,
                boolean filtering,
                boolean overwrite,
                boolean preserveLastModified) throws IOException 
            Deprecated! since - 1.4.x

              Convenience method to copy a file from a source to a destination specifying if token filtering should be used, if source files may overwrite newer destination files, and if the last modified time of the resulting file should be set to that of the source file.
             public  void copyInheritedProperties(Project other) 
              Copy all user properties that have not been set on the command line or a GUI tool from this instance to the Project instance given as the argument.

              To copy all "user" properties, you will also have to call copyUserProperties .

             public  void copyUserProperties(Project other) 
              Copy all user properties that have been set on the command line or a GUI tool from this instance to the Project instance given as the argument.

              To copy all "user" properties, you will also have to call copyInheritedProperties .

             public AntClassLoader createClassLoader(Path path) 
              Factory method to create a class loader for loading classes from a given path.
             public AntClassLoader createClassLoader(ClassLoader parent,
                Path path) 
              Factory method to create a class loader for loading classes from a given path.
             public Object createDataType(String typeName) throws BuildException 
              Create a new instance of a data type.
             public Project createSubProject() 
              Create and initialize a subproject. By default the subproject will be of the same type as its parent. If a no-arg constructor is unavailable, the Project class will be used.
             public Task createTask(String taskType) throws BuildException 
              Create a new instance of a task, adding it to a list of created tasks for later invalidation. This causes all tasks to be remembered until the containing project is removed
             public int defaultInput(byte[] buffer,
                int offset,
                int length) throws IOException 
              Read data from the default input stream. If no default has been specified, System.in is used.
             public  void demuxFlush(String output,
                boolean isError) 
              Demultiplex flush operations so that each task receives the appropriate messages. If the current thread is not currently executing a task, the message is logged directly.
             public int demuxInput(byte[] buffer,
                int offset,
                int length) throws IOException 
              Demux an input request to the correct task.
             public  void demuxOutput(String output,
                boolean isWarning) 
              Demultiplex output so that each task receives the appropriate messages. If the current thread is not currently executing a task, the message is logged directly.
             public  void executeSortedTargets(Vector sortedTargets) throws BuildException 
              Execute a Vector of sorted targets.
             public  void executeTarget(String targetName) throws BuildException 
              Execute the specified target and any targets it depends on.
             public  void executeTargets(Vector names) throws BuildException 
              Execute the specified sequence of targets, and the targets they depend on.
             public  void fireBuildFinished(Throwable exception) 
              Send a "build finished" event to the build listeners for this project.
             public  void fireBuildStarted() 
              Send a "build started" event to the build listeners for this project.
             protected  void fireMessageLogged(Project project,
                String message,
                int priority) 
              Send a "message logged" project level event to the build listeners for this project.
             protected  void fireMessageLogged(Target target,
                String message,
                int priority) 
              Send a "message logged" target level event to the build listeners for this project.
             protected  void fireMessageLogged(Task task,
                String message,
                int priority) 
              Send a "message logged" task level event to the build listeners for this project.
             protected  void fireMessageLogged(Project project,
                String message,
                Throwable throwable,
                int priority) 
              Send a "message logged" project level event to the build listeners for this project.
             protected  void fireMessageLogged(Target target,
                String message,
                Throwable throwable,
                int priority) 
              Send a "message logged" target level event to the build listeners for this project.
             protected  void fireMessageLogged(Task task,
                String message,
                Throwable throwable,
                int priority) 
              Send a "message logged" task level event to the build listeners for this project.
             public  void fireSubBuildFinished(Throwable exception) 
              Send a "subbuild finished" event to the build listeners for this project.
             public  void fireSubBuildStarted() 
              Send a "subbuild started" event to the build listeners for this project.
             protected  void fireTargetFinished(Target target,
                Throwable exception) 
              Send a "target finished" event to the build listeners for this project.
             protected  void fireTargetStarted(Target target) 
              Send a "target started" event to the build listeners for this project.
             protected  void fireTaskFinished(Task task,
                Throwable exception) 
              Send a "task finished" event to the build listeners for this project.
             protected  void fireTaskStarted(Task task) 
              Send a "task started" event to the build listeners for this project.
             public File getBaseDir() 
              Return the base directory of the project as a file object.
             public Vector getBuildListeners() 
              Return a copy of the list of build listeners for the project.
             public Map getCopyOfDataTypeDefinitions() 
              Return the current datatype definition map. The returned map is a copy pf the "live" definitions.
             public Map getCopyOfReferences() 
              Return a map of the references in the project (String to Object). The returned hashtable is a copy of the "live" references.
             public Map getCopyOfTargets() 
              Return the map of targets. The returned map is a copy of the "live" targets.
             public Map getCopyOfTaskDefinitions() 
              Return the current task definition map. The returned map is a copy of the "live" definitions.
             public ClassLoader getCoreLoader() 
              Return the core classloader to use for this project. This may be null, indicating that the parent classloader should be used.
             public Hashtable getDataTypeDefinitions() 
              Return the current datatype definition hashtable. The returned hashtable is "live" and so should not be modified.
             public InputStream getDefaultInputStream() 
              Get this project's input stream.
             public String getDefaultTarget() 
              Return the name of the default target of the project.
             public String getDescription() 
              Return the project description, if one has been set.
             public String getElementName(Object element) 
              Return a description of the type of the given element, with special handling for instances of tasks and data types.

              This is useful for logging purposes.

             public Executor getExecutor() 
              Get this Project's Executor (setting it if necessary).
             public Hashtable getFilters() 
            Deprecated! since - 1.4.x Use getGlobalFilterSet().getFilterHash().

              Return a hashtable of global filters, mapping tokens to values.
             public FilterSet getGlobalFilterSet() 
              Return the set of global filters.
             public Hashtable getInheritedProperties() 
              Return a copy of the inherited property hashtable.
             public InputHandler getInputHandler() 
              Retrieve the current input handler.
             public static String getJavaVersion() 
            Deprecated! since - 1.5.x. Use org.apache.tools.ant.util.JavaEnvUtils instead.

              Return the version of Java this class is running under.
             public String getName() 
              Return the project name, if one has been set.
             public static Project getProject(Object o) 
              Get the Project instance associated with the specified object.
             public Hashtable getProperties() 
              Return a copy of the properties table.
             public String getProperty(String propertyName) 
              Return the value of a property, if it is set.
             public Object getReference(String key) 
              Look up a reference by its key (ID).
             public Hashtable getReferences() 
              Return a map of the references in the project (String to Object). The returned hashtable is "live" and so must not be modified.
             public Resource getResource(String name) 
              Resolve the file relative to the project's basedir and return it as a FileResource.
             public Hashtable getTargets() 
              Return the hashtable of targets. The returned hashtable is "live" and so should not be modified.
             public Hashtable getTaskDefinitions() 
              Return the current task definition hashtable. The returned hashtable is "live" and so should not be modified.
             public Task getThreadTask(Thread thread) 
              Get the current task associated with a thread, if any.
             public Hashtable getUserProperties() 
              Return a copy of the user property hashtable.
             public String getUserProperty(String propertyName) 
              Return the value of a user property, if it is set.
             public boolean hasReference(String key) 
              Does the project know this reference?
             public  void inheritIDReferences(Project parent) 
              Inherit the id references.
             public  void init() throws BuildException 
              Initialise the project. This involves setting the default task definitions and loading the system properties.
             public  void initProperties() throws BuildException 
              Initializes the properties.
             public  void initSubProject(Project subProject) 
              Initialize a subproject.
             public boolean isKeepGoingMode() 
              Return the keep-going mode. If the keepGoing settor/getter methods are used in conjunction with the ant.executor.class property, they will have no effect.
             public  void log(String message) 
              Write a message to the log with the default log level of MSG_INFO .
             public  void log(String message,
                int msgLevel) 
              Write a project level message to the log with the given log level.
             public  void log(String message,
                Throwable throwable,
                int msgLevel) 
              Write a project level message to the log with the given log level.
             public  void log(Task task,
                String message,
                int msgLevel) 
              Write a task level message to the log with the given log level.
             public  void log(Target target,
                String message,
                int msgLevel) 
              Write a target level message to the log with the given log level.
             public  void log(Task task,
                String message,
                Throwable throwable,
                int msgLevel) 
              Write a task level message to the log with the given log level.
             public  void log(Target target,
                String message,
                Throwable throwable,
                int msgLevel) 
              Write a target level message to the log with the given log level.
             public  void registerThreadTask(Thread thread,
                Task task) 
              Register a task as the current task for a thread. If the task is null, the thread's entry is removed.
             public  void removeBuildListener(BuildListener listener) 
              Remove a build listener from the list. This listener will no longer be notified of build events for this project.
             public String replaceProperties(String value) throws BuildException 
              Replace ${} style constructions in the given value with the string value of the corresponding data types.
             public File resolveFile(String fileName) 
              Return the canonical form of a filename.

              If the specified file name is relative it is resolved with respect to the project's base directory.

             public File resolveFile(String fileName,
                File rootDir) 
            Deprecated! since - 1.4.x

              Return the canonical form of a filename.

              If the specified file name is relative it is resolved with respect to the given root directory.

             public  void setBaseDir(File baseDir) throws BuildException 
              Set the base directory for the project, checking that the given file exists and is a directory.
             public  void setBasedir(String baseD) throws BuildException 
              Set the base directory for the project, checking that the given filename exists and is a directory.
             public  void setCoreLoader(ClassLoader coreLoader) 
              Set the core classloader for the project. If a null classloader is specified, the parent classloader should be used.
             public  void setDefault(String defaultTarget) 
              Set the default target of the project.
             public  void setDefaultInputStream(InputStream defaultInputStream) 
              Set the default System input stream. Normally this stream is set to System.in. This inputStream is used when no task input redirection is being performed.
             public  void setDefaultTarget(String defaultTarget) 
            Deprecated! since - 1.5.x. Use setDefault.

              Set the default target of the project.
             public  void setDescription(String description) 
              Set the project description.
             public  void setExecutor(Executor e) 
              Set the Executor instance for this Project.
             public  void setFileLastModified(File file,
                long time) throws BuildException 
            Deprecated! since - 1.4.x

              Call File.setLastModified(long time) on Java above 1.1, and logs a warning on Java 1.1.
             public  void setInheritedProperty(String name,
                String value) 
              Set a user property, which cannot be overwritten by set/unset property calls. Any previous value is overwritten. Also marks these properties as properties that have not come from the command line.
             public  void setInputHandler(InputHandler handler) 
              Set the input handler.
             public  void setJavaVersionProperty() throws BuildException 
              Set the ant.java.version property and tests for unsupported JVM versions. If the version is supported, verbose log messages are generated to record the Java version and operating system name.
             public  void setKeepGoingMode(boolean keepGoingMode) 
              Set "keep-going" mode. In this mode Ant will try to execute as many targets as possible. All targets that do not depend on failed target(s) will be executed. If the keepGoing settor/getter methods are used in conjunction with the ant.executor.class property, they will have no effect.
             public  void setName(String name) 
              Set the name of the project, also setting the user property ant.project.name.
             public  void setNewProperty(String name,
                String value) 
              Set a property if no value currently exists. If the property exists already, a message is logged and the method returns with no other effect.
             public final  void setProjectReference(Object obj) 
              Set a reference to this Project on the parameterized object. Need to set the project before other set/add elements are called.
             public  void setProperty(String name,
                String value) 
              Set a property. Any existing property of the same name is overwritten, unless it is a user property.
             public  void setSystemProperties() 
              Add all system properties which aren't already defined as user properties to the project properties.
             public  void setUserProperty(String name,
                String value) 
              Set a user property, which cannot be overwritten by set/unset property calls. Any previous value is overwritten.
             public static boolean toBoolean(String s) 
              Return the boolean equivalent of a string, which is considered true if either "on", "true", or "yes" is found, ignoring case.
             public final Vector topoSort(String root,
                Hashtable targetTable) throws BuildException 
              Topologically sort a set of targets. Equivalent to calling topoSort(new String[] {root}, targets, true).
             public final Vector topoSort(String root,
                Hashtable targetTable,
                boolean returnAll) throws BuildException 
              Topologically sort a set of targets. Equivalent to calling topoSort(new String[] {root}, targets, returnAll).
             public final Vector topoSort(String[] root,
                Hashtable targetTable,
                boolean returnAll) throws BuildException 
              Topologically sort a set of targets.
             public static String translatePath(String toProcess) 
            Deprecated! since - 1.7 Use FileUtils.translatePath instead.

              Translate a path into its native (platform specific) format.

              This method uses PathTokenizer 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.