Skip to Content


Scope: JDT projects


The getJdtClassPath task resolves the class path of an eclipse project. This task reads and parses the .classpath file from the underlying eclipse project. The classpath can be resolved to ant's path 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 path type, it can be referenced using the ref-id attribute wherever a class path must be used.


The getJdtClassPath task provides the following arguments:

Argument Description Required
workspaceDirectory Absolute path of the workspace directory yes
projectName Name of the eclipse project yes
property The name of the property that will hold the resolved path either 'pathId' or 'property' has to be specified
pathId The reference id for the path that will be created either 'pathId' or 'property' has to be specified
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 '\')
relative Determines whether the result path should be resolved relative to the given workspace or absolute no (default: false)
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)

Example usage

The following example resolves the class path of the project to the property classpath. All entries are separated by the default path separator (as defined in You can use the pathSeparator attribute to explicitly specify a character that is used to separate the entries of the classpath::

<ant4eclipse:getJdtClassPath workspacedirectory="${workspace}"
                             pathSeparator=";" >

You can also export a classpath to an ant path:

<ant4eclipse:getJdtClassPath pathId="classpath"
                             projectName="" />

You can use the relative attribute to request a classpath that consists of path entries relative to the specified workspace:

<ant4eclipse:getJdtClassPath property="classpath"