<getSourcepath>
Description
The getSourcepath task resolves the source folders of an Eclipse
project. The source folders can be resolved to Ant's
Path-type or to a string property. The path can be
resolved in a relative (to the given workspace) or absolute
manner.
Arguments
Note: You can specify either the path to the project (using the
project argument) or you can specify the path to the
workspace (workspace argument) and the name of the
project (projectName argument).
| Argument | Description | Required |
|---|---|---|
| project | Path to the project for which the output path should be build | either the project or the combination of workspace and projectName has to be specified |
| workspace | Path to the workspace containing the projects | |
| projectName | Name of the project inside of the workspace for which the output path should be build | |
| initialiseWorkspace | Set to 'true' if your workspace contains projects which have project names that differ from the names of their project folders and the workspace doesn't contain a .metadata directory. | no (default: false) |
| pathId | The reference id for the path that will be created | either the pathId or the property has to be specified |
| property | The name of the property that will hold the resolved path | either the pathId or the property has to be specified |
| relative | Determines whether the resolved path should contain relative paths (to the given workspace) or absolute paths | no (default: false) |
| pathSeparator | The pathSeparator string is used to separate the filenames in the property | no (default: on UNIX systems, this character is
':'; on Microsoft Windows systems it is
';'.) |
| allowMultipleFolders | Must set to true to allow multiple source
folders. If allowMultipleFolders is
false and the result contains multiple
folders, an BuildException is thrown. |
no (default: false) |
| variablesRef | The ID of an ant property set. This property set will be used to resolve Eclipse variables. This allows to prefer a specific set of properties rather than using the ant properties in general. | no |
Examples:
The following example shows how to use the getSourcepath task:
If you don't want to have the path as a
path object but rather as a string
Property, you can use the
property parameter instead of the
pathId argument. If you export the classpath to a
Property, all its entries are separated by the operating systems
default path separator (as defined in
java.io.File.separator). You can use the
pathSeparator argument to explicitly specify a character that
is used to separate the entries of the classpath.
The entries of the paths are absolute paths by default. You can use the boolean
relative argument to receive a path that consists of pathentries that
are relative to the project directory.
Eclipse projects can contain multiple source and output folders. To build such projects, first retrieve a property that contains all source folders via the getSourcepath-task. Now you can iterate over the entries and resolve the corresponding output locations via the getOutputpath-task.
Notice that the sources will be build in order their appearance in the underlying .classpath file. This may leads to compile failures, if a sourcefolder is build before a required sourcefolder has been build (e.g. test-src before src)!
See also: getOutputpath