Description
The executeJdtProject
task allows you to iterate over an eclipse JDT project and execute ant tasks, e.g. for each source folder or for each output folder. Although it is possible to access the eclipse project information with the getJdtClassPath
, getJdtSourcePath
and getJdtSourcePath
tasks, the recommended way of building JDT projects with ant4eclipse is to use the executeJdtProject
task.
With the executeJdtProject
task you can iterate over each source or output folder, or you can execute ant tasks once for the jdt project. Within forXYZ
subelements, project information are available through several (ant) properties and references that are "passed in" automatically.
Arguments
The executeJdtProject
task provides the following arguments:
Argument | Description | Required |
---|---|---|
workspaceDirectory | Absolute path of the workspace directory | Either 'workspaceDirectory' or 'workspaceId' has to be specified |
workspaceId | The identifier of a defined workspace (see <workspaceDefinition>) | Either 'workspaceDirectory' or 'workspaceId' has to be specified |
projectName | Name of the eclipse project | yes |
pathSeparator | The system-dependent path-separator character. This character is used to separate filenames in a sequence of files. | no (default: On UNIX systems, this character is ':' ; on Microsoft Windows systems it is ';' ) |
dirSeparator | The system-dependent default name-separator character. | no (default: On UNIX systems the value of this field is '/' ; on Microsoft Windows systems it is '\' ) |
prefix | The prefix for all scoped references and properties. | no (default: executeJdtProject) |
Nested Elements
To iterate over source or output folders specified in a JDT project, you can define one or more nested elements. Those elements can contain several task calls, similar to a target element. The following elements are defined:
forEachSourceDirectory
: executed for each source directoryforEachOutputDirectory
: executed for each output directoryforProject
: executed onceforEachRuntimeClasspathEntry
: executed for each resolved runtime classpath entry of the project. This element supports the attribute 'reverse' that can be set to true to iterate over the classpath from its bottom to top (i.e. last entry first)
Scoped Properties
Several properties and references are "passed in", so you can access them within the forEachSourceDirectory
, forEachOutputDirectory
or forProject
elements. The following scoped properties are available:
Property | Availability | Description |
---|---|---|
<prefix>.boot.classpath | all elements | The boot class path of the used JRE. |
<prefix>.classpath.relative.runtime | all elements | The runtime class path of the JDT project, relative to the workspace location. |
<prefix>.classpath.absolute.runtime | all elements | The absolute runtime class path of the JDT project. |
<prefix>.classpath.relative.compiletime | all elements | The compile time class path of the JDT project, relative to the workspace location. |
<prefix>.classpath.absolute.compiletime | all elements | The absolute compile time class path of the JDT project. |
<prefix>.default.output.directory | all elements | The absolute path of the default ouput directory. |
<prefix>.default.output.directory.name | all elements | The name of the default ouput directory. |
<prefix>.source.directories | all elements | The source directories (only set if the project contains source directories) |
<prefix>.source.directory | forEachSourceDirectory | The absolute path of the current source directory. |
<prefix>.source.directory.name | forEachSourceDirectory | The name of the current source directory. |
<prefix>.output.directory | forEachSourceDirectory, forEachOutputDirectory | The absoulte path of the current ouput directory. |
<prefix>.output.directory.name | forEachSourceDirectory, forEachOutputDirectory | The name of the current ouput directory. |
<prefix>.classpathEntry.absolute | forEachRuntimeClasspathEntry | The absolute path of this classpath entry |
<prefix>.classpathEntry.name | forEachRuntimeClasspathEntry | The filename of the entry (i.e. the last part of it's path) |
<prefix>.classpathEntry.isExisting | forEachRuntimeClasspathEntry | true if the entry points to an exisiting resource. Otherwise false. |
<prefix>.classpathEntry.isFile | forEachRuntimeClasspathEntry | true if the entry points to an exisiting file in the filesystem. Otherwise false. |
<prefix>.classpathEntry.isFolder | forEachRuntimeClasspathEntry | true if the entry points to an exisiting folder in the filesystem. Otherwise false. |
<prefix>.classpathEntry.isProjectRelative | forEachRuntimeClasspathEntry | true if the entry points to a resource which is located within the project. Otherwise false. |
Scoped References
The following scoped references are available:
Reference | Availability | Description |
---|---|---|
<prefix>.boot.classpath.path | all elements | The boot class path of the used JRE. |
<prefix>.classpath.relative.runtime.path | all elements | The runtime class path of the JDT project, relative to the workspace location. |
<prefix>.classpath.absolute.runtime.path | all elements | The absolute runtime class path of the JDT project. |
<prefix>.classpath.relative.compiletime.path | all elements | The compile time class path of the JDT project, relative to the workspace location. |
<prefix>.classpath.absolute.compiletime.path | all elements | The absolute compile time class path of the JDT project. |
<prefix>.default.output.directory.path | all elements | The absolute path of the default ouput directory. | <prefix>.source.directories.path | all elements | The source directories (only set if the project contains source directories) |
<prefix>.source.directory.path | forEachSourceDirectory | The absolute path of the current source directory. |
<prefix>.output.directory.path | forEachSourceDirectory, forEachOutputDirectory | The absoulte path of the current ouput directory. |
<prefix>.classpathEntry.fileSet | forEachRuntimeClasspathEntry | The current classpath entry as an Ant FileSet |
Example usage
The following example 'executes' a jdt project and echoes the path information for each source directory contained in the project.
<ant4eclipse:executeJdtProject workspace="${workspaceDir}" projectName="${projectName}" > <!-- echo information for project --> <ant4eclipse:forProject> <echo>Executing project '${projectName}'...</echo> <echo>Boot class path: ${executeJdtProject.boot.classpath}</echo> <echo>Relative runtime class path: ${executeJdtProject.classpath.relative.runtime}</echo> <echo>Absolute runtime class path: ${executeJdtProject.classpath.absolute.runtime}</echo> <echo>Relative compiletime class path: ${executeJdtProject.classpath.relative.compiletime}</echo> <echo>Absolue compiletime class path: ${executeJdtProject.classpath.absolute.compiletime}</echo> <echo>Default output directory: ${executeJdtProject.default.output.directory}</echo> </ant4eclipse:forProject> <!-- echo information for each source directory --> <ant4eclipse:forEachSourceDirectory> <echo>Source folder: ${executeJdtProject.source.directory}</echo> <echo>Output folder: ${executeJdtProject.output.directory}</echo> </ant4eclipse:forEachSourceDirectory> </ant4eclipse:executeJdtProject>
- Printer-friendly version
- Login or register to post comments