<getEclipseClasspath>
Description
The getEclipseClasspath task resolves the complete Classpath of an
Eclipse project. This task reads and parses the
.classpath file from the underlying eclipse project
and constructs an Ant path object. The classpath can
be resolved to Ant's Classpath-type or to a string
property. The classpath can be resolved in a relative (to the given
workspace) or absolute manner. In case the classpath is resolved to
a Classpath-type, it can be referenced using the
ref-id attribute wherever a Classpath
must be used.
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
';'.) |
| runtime | Boolean value that determines whether the classpath should be interpreted as a runtime classpath. If set to true, it will comprise all entries of dependent projects. Otherwise it will comprise only the exported entries of dependent projects. | no (default: false) |
| targetPlatformLocation | Only required if you want to build plugin projects. Full path to the target platform location that contains all the plugins against which the workspace plugins will be compiled. It has to point to the directory that contains the 'plugin'-directory (e.g. c:\eclipse) | no (default: false). If you want to resolve a classpath from a plugin project, the target location must be set. |
| dirSeparator | Allows to specify the separator of directory elements. | no (Default: File.separator) |
| 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 |
Parameters specified as nested elements
targetPlatform
If your classpath contains plugins and you want to define a target platform that has more than one directory you have to use
the targetPlatform element. See
targetPlatform reference for more information on how to use the target platform type
Classpath of plugin projects
While it it possible to resolve a classpath of a project that either is a plugin project or that
references a plugin project, it's not recommended to use the getEclipseClasspath task in this case.
Since it's not possible to specify the (access) restrictions that are defined in the various OSGi headers in the MANIFEST file
(export-package, import-package, require-bundle and others) on a "regular" classpath, as returned by getEclipseClasspath, you
won't ever get a "correct" classpath in the meaning of the OSGi specification. If you want to build your plugins should have a look
at the buildPlugin-task that is able to resolve the classpath according to the specification.
Examples
The following example resolves a classpath to an ant path that can be used later in your build script:
You can also export a classpath to an ant property. If you do
so, 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:
You can use the boolean relative argument to
receive a classpath that consists of pathentries that are
relative to the specified workspace:
You can also specify whether to create a runtime
classpath or not. The getEclipseClasspath task
creates a compile-time classpath by default. This
classpath contains the entries of the project passed to the
task and the entries that are marked as exported in
Eclipse' Build Path settings only. If you set
runtime to true, the classpath will
contain all entries from the referenced projects.
With the settings of the following example, you could create a
jar-file with a Manifest-File containing a
Class-Path attribute, that references your whole
classpath: