Reference

Core project related tasks

Ant4Eclipse contains several tasks and conditions that can be used with every eclipse project type. This chapter explains the usage of these tasks and conditions.

<hasNature>

Scope: All Project Types

Description

The hasNature condition is an Ant condition that can be used to check if a project has a specific nature. Natures are used to assign specific behaviour to Eclipse projects. Java projects for example have the nature 'org.eclipse.jdt.core.javanature'.

The hasNature condition can be used with ant's native condition and waitfor tasks (see Condition Task). It can also be used with the if-task from the ant-contrib project to create build steps that check whether a project has some specific nature.

Arguments

The hasNature datatype 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
nature Name of a Nature that should be checked yes

Example usage

The following example checks if the project with the name 'simple.java.project' has the nature 'org.eclipse.jdt.core.javanature':

<antcontrib:if>
    <ant4eclipse:hasNature workspacedirectory="${workspace}"
                           projectname="simple.java.project"
                           nature="org.eclipse.jdt.core.javanature" />
   <antcontrib:then>
     ...
   </antcontrib:then>
 </antcontrib:if>

<hasBuildCommand>

Scope: All Project Types

Description

The hasBuildCommand condition is an Ant condition that can be used to check if an Eclipse project has a specific build command. An Eclipse project can have several build command assigned to it. Those build commands are normally executed after a file has been saved (incremental build) or when a full build is initiated (Project -> Clean...) (manual build). A typical java project contains the org.eclipse.jdt.core.javabuilder which invokes the default Eclipse compiler on java sources.

If you would like to write build steps that depend on specific build commands, you can use the hasBuildCommand condition which checks if a project has a specified buildCommand. The hasBuildCommand-condition can be used with ant's native condition and waitfor tasks (see Condition Task). It can also be used with the if-task from the ant-contrib project to create build steps that check whether some specific build commands exist or not.

Arguments

The hasBuildCommand datatype 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
buildCommand Name of the build command that should be checked yes

Example usage

The following example checks if the project with the name 'simple.java.project' has the build command 'org.eclipse.jdt.core.javabuilder':

<antcontrib:if>
  <ant4eclipse:hasBuildCommand workspacedirectory="${workspace}"
                               projectname="simple.java.project"
                               buildcommand="org.eclipse.jdt.core.javabuilder" />
  <antcontrib:then>
    ...
  </antcontrib:then>
</antcontrib:if>

<executeBuildCommands>

Scope: All Project Types

Description

The executeBuildCommands task allows you to iterate over one or more build commands that are defined in your eclipse project.

Arguments

The executeBuildCommands 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

Example usage

The following example iterates over all build commands defined in the eclipse project 'simple.java.project':

<ant4eclipse:executeBuildCommands workspacedirectory="${workspace}"
			          projectname="simple.java.project">
 
	<org.eclipse.jdt.core.javabuilder>
		...
	</org.eclipse.jdt.core.javabuilder>
</ant4eclipse:executeBuildCommands>

<getProjectDirectory>

Scope: All Project Types

Description

Returns the project directory for a given eclipse project. Since ant4eclipse supports the usage of linked projects, it is necessary in some case to resolve the 'real' path of a project.

Arguments

The getProjectDirectory 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
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)

Example usage

The following example resolves the absolute path of the the project with the name 'simple.java.project':

<ant4eclipse:getProjectDirectory workspacedirectory="${workspace}"
                                 projectname="simple.java.project"
	                         property="test" />

<workspaceDefinition>

Scope: All Project Types

Description

The workspaceDefinition type allows you define a workspace with a custom workspace layout. In eclipse a workspace always has a flat layout (Workspace -> Projects), but many users store there eclipse projects in a hierarchical way within the source code repository. Ant4eclipse directly supports the usage of custom workspace layouts through this datatype.

Many thanks to Mark Riley for submitting the initial patch!

Arguments

The workspaceDefinition datatype provides the following arguments:

Argument Description Required
id The identifier of the workspace definition yes

Nested Elements

To define a custom workspace layout, you can use one or more nested Directory Sets.

Example usage

The following example defines a workspace that contains projects that can be found in any sub-directory (recursively) of the directory 'D:/tmp':

  <ant4eclipse:workspaceDefinition id="myWorkspace">
    <dirset dir="D:/tmp">
      <include name="**"/>
    </dirset>
  </ant4eclipse:workspaceDefinition>

You can use the workspace definition within the ant4eclipse task by using the 'workspaceId' attribute insead of the 'workspaceDirectory' attribute.

<linkedResourceVariable>

Scope: All Project Types

Description

The linkedResourceVariable datatype is an Ant datatype that allows you to specify an environment specific path for a linked resource. Within the eclipse IDE these variables are defined in the preferences dialog (Window -> Preferences..., General -> Workspace -> Linked Resources).

Arguments

The linkedResourceVariable type provides the following arguments:

Argument Description Required
name The name of the linked resource path variable as specified in the eclipse preferences. yes
location The location of the linked resource. yes

Usage examples

<ant4eclipse:linkedResourceVariable name="myLinkedResourcesDirectory" location="D:/location" />

Core project set related tasks

Describes the usage of the core project set related tasks.

<executeProjectSet>

Scope: All Project Types

Description

The executeProjectSet task allows you iterate over a set of projects. The project set can be defined using a (comma separated) list of projects or a team project set file.

With the nested forEachProject element you can execute tasks for each project that is defined in the project set. The build order of the contained projects are computed automatically.

Arguments

The executeProjectSet 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
projectNames comma separated list of project names either 'projectNames' or 'teamProjectSet' has to be specified
teamProjectSet name of an eclipse team project set file either 'projectNames' or 'teamProjectSet' 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 '\')
allWorkspaceProjects If set to true all projects in the workspace will be added to the set of projects. Otherwise only those projects are taken into account that are defined either in a team project set file or in the projectNames attribute. either 'allProject' or 'teamProjectSet' or 'projectNames' has to be specified
resolveBuildOrder If set to true the build order of the specified projects will be resolved. no (default: true)
projectReferenceTypes Projects can have references of different types. With the projectReferenceTypes you can define, which kind of reference should be taken into account while computing the build order. Currently the following values are possible: jdt, platform. no (default: all available reference types)
prefix the prefix for all scoped properties and references no (default: executeProjectSet)

Nested Elements

To iterate over the projects defined in the executeProjectSet task, 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:

  • forEachProject: executed for each project

Scoped properties

Several properties and references are "passed in", so you can access them within the forEachProject element. The following scoped properties are available:

Property Description
<prefix>.project.name The name of the project
<prefix>.project.directory Absolute path of the project directory
<prefix>.<project nature name> true (this property is set for each project nature the project contains)

Scoped references

The following scoped references are available:

Reference Description
<prefix>.project.directory.path The project directory as an ant path

Example usage

Working with project set files

The following example shows how to iterate over a project set defined by a team project set file (projectSet.psf):

<ant4eclipse:executeProjectSet workspace="${workspace}"
		               teamprojectset="projectSet.psf" >
 
  <ant4eclipse:forEachProject>
    <echo>${executeProjectSet.project.name}</echo>
  </ant4eclipse:forEachProject>
 
</ant4eclipse:executeProjectSet>

The following example only iterates over the java projects of the team project set:

<ant4eclipse:executeProjectSet workspaceDirectory="${workspace}"
		               teamprojectset="projectSet.psf" >
 
  <ant4eclipse:forEachProject filter="(executeProjectSet.org.eclipse.jdt.core.javanature=*)" >
    <echo>${executeProjectSet.project.name}</echo>
  </ant4eclipse:forEachProject>
 
</ant4eclipse:executeProjectSet>

Defining a project set by a list of project names

The following example shows how to iterate over a project set defined by all projects defined in the workspace:

<ant4eclipse:executeProjectSet workspaceDirectory="${workspace}"
		               projectNames="simpleProject, secondProject" >
 
  <ant4eclipse:forEachProject>
    <echo>${executeProjectSet.project.name}</echo>
  </ant4eclipse:forEachProject>
 
</ant4eclipse:executeProjectSet>

Choosing all projects within a workspace

The following example shows how to iterate over a project set defined by all projects defined in the workspace.

<ant4eclipse:executeProjectSet workspaceDirectory="${workspace}"
		               allWorkspaceProjects="true" >
 
  <ant4eclipse:forEachProject>
    <echo>${executeProjectSet.project.name}</echo>
  </ant4eclipse:forEachProject>
 
</ant4eclipse:executeProjectSet>

<getBuildOrder>

Scope: All Project Types

Description

The getBuildOrder task computes the order in which projects of a workspace must be built. The task requires either a Team Project Set file containing the projects or a property with a list of project names to be computed. The project set resp. the project names must contain all needed projects. If a project that is referenced by a project listed in the project set or in projectNames is not included, the task will fail. All projects that are needed to compute the build order must exist in the workspace, otherwise the task will fail.

Arguments

The getBuildOrder 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
buildOrderProperty The name of a property that will hold the computed build order yes
teamProjectSet The location of a team project set file that contains the projects either 'allProject' or 'teamProjectSet' or 'projectNames' has to be specified
projectNames A list with names of projects that should be ordered either 'allProject' or 'teamProjectSet' or 'projectNames' has to be specified
allWorkspaceProjects If set to true the build order of all projects in the workspace will be computed. Otherwiseonly those projects are taken into account that are defined either in a team project set file or in the projectNames attribute. either 'allProject' or 'teamProjectSet' or 'projectNames' has to be specified
projectReferenceTypes Projects can have references of different types. With the projectReferenceTypes you can define, which kind of reference should be taken into account while computing the build order. Currently the following values are possible: jdt, platform. no (default: all available reference types)

Example usage

The following example computes the build order of all the projects contained in the team project set projectSet.psf:

<getBuildOrder workspace="${workspaceDir}"
               teamprojectset="projectSet.psf"
               buildOrderProperty="test" />

<cvsGetProjectSet>

Scope: All Project Types

Description

Use the cvsGetProjectSet task to automatically check out all projects defined in a team project set. The cvsGetProjectSet requires the name of a Team Project Set file and a destination directory into which the projects will be checked out. Furthermore you need to specify a username and a password for CVS. Ant4eclipse then checks out all projects listed in the file in the version / from the branch that is mentioned in the file.

Arguments

The cvsGetProjectSet 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
projectset Project Set File that defines the projects to be checked out yes
cvsUser User for CVS-connection yes
cvsPwd Password for CVS-connection yes
command Determine whether the project set should be checked out, updated or exported. You can use one of the following values:
  • checkout: Checks out the complete projects from CVS (cvs co)
  • update: Updates the projects: receive/remove changed files only (cvs update)
  • export: Like checkout, but removes the CVS directories, so the checked out projects have no connection to CVS anymore (cvs export)
yes

Example usage

The following example shows how to checkout projects defined in a team project set:

<cvsGetProjectSet cvsUser="myCvsUserId"
                  cvsPwd="myCvsPassword"
                  command="checkout"
                  projectSet="myProjectSet.psf"
                  workspace="${workspace.dir}" />

<svnGetProjectSet>

Scope: All Project Types

Description

Use the svnGetProjectSet task to automatically check out all projects defined in a subversion-based team project set. The svnGetProjectSet requires the name of a Team Project Set file and a destination directory into which the projects will be checked out. Furthermore you may need to specify a username and a password for SVN, that depends on your repository. Ant4eclipse will check out all projects listed in the file in the version / from the branch that is speciified in the file.

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
projectset Project Set File that defines the projects to be
checked out
yes
username User for SVN-connection no
password Password for SVN-connection no
command Determine whether the project set should be checked
out, updated or exported
yes (one of: checkout, export or update)
javahl Determines whether the svn-Task should try to use the (native) javahl library no (defaults to 'true')
javasvn Determines whether the svn-Task should try to use the pure-java SVN binding (svnkit) no (defaults to 'true')
dateFormatter formatter definition used to format/parse dates (e.g. when revision is specified as date). no
dateTimeZone time zone used to format/parse dates (e.g. when revision is specified as date). no

The svnGetProjectSet-Tasks takes a command argument that detemines how a project will be received from the CVS repository:

  • checkout: Checks out the complete projects from SVN (svn checkout)
  • update: Updates the projects: receive/remove changed files only (svn checkout)
  • export: Like checkout, but removes the .SVN directories, so the checked out projects have no connection to SVN anymore (svn export)

Setup

  1. In order to use the svnGetProjectSet task you must have svn-ant installed, which can be obtained from http://subclipse.tigris.org/svnant.html. Ant4Eclipse is built and tested against the 1.1.0-RC2 version of svn-ant.
  2. You'll need to have the jar files shipped with svn-ant in one of your Ant lib-directories (i.e. a directory you'll point ant with "-lib" to). Note: You can not use the classpath elements in the taskdef (see below) for svn-ant since that results in a ClassCastException due to Classloader mismatch.
  3. You'll need to add a taskdef element to your build file to make Ant (and Ant4Eclipse) aware of the svn-Task (that is used internally by Ant4Eclipse): &lt;taskdef resource="org/tigris/subversion/svnant/svnantlib.xml"/&gt;

Providers

The svnGetProjectSetTask has been tested with PSF-files exported by the Subclipse and the Subversive plugins. If you'll discover any problems with a PSF file please send us the PSF file and information which plugin you used to export it (including the plugin's version!)

Examples

The following example shows how to checkout projects defined in a team project set. Note that it is required to have ant4eclipse.jar as well as the jars from the svn-ant-Project in your classpath (see "Setup" above):

<project name="..." default="...">
 
  <!-- define Ant4Eclipse tasks -->
  <taskdef uri="antlib:org.ant4eclipse" resource="org/ant4eclipse/antlib.xml" />
 
  <!-- define svnant tasks -->
  <taskdef resource="org/tigris/subversion/svnant/svnantlib.xml" />
 
  <target name="checkout-psf">
    <!-- Check out the contents of "myProjectSet.psf" into the directory "${workspace.dir}" -->
    <ant4eclipse:svnGetProjectSet username="myCvsUserId"
                                  password="myCvsPassword"
                                  command="checkout"
                                  projectSet="myProjectSet.psf"
                                  workspace="${workspace.dir}">
 
  </target>
</project>

JDT related tasks & macros

<executeJdtProject>

Scope: JDT projects

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 directory
  • forEachOutputDirectory: executed for each output directory
  • forProject: executed once
  • forEachRuntimeClasspathEntry: 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>

<getJdtClassPath>

Scope: JDT projects

Description

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.

Arguments

The getJdtClassPath 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
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 simple.java.project to the property classpath. All entries are separated by the default path separator (as defined in java.io.File.separator). 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}"
                             projectName="simple.java.project"
		             property="classpath"
                             pathSeparator=";" >

You can also export a classpath to an ant path:

<ant4eclipse:getJdtClassPath pathId="classpath"
                             workspace="${workspace}"
                             projectName="simple.java.project" />

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

<ant4eclipse:getJdtClassPath property="classpath"
                             workspace="${workspace}"
                             projectName="myProject"
                             pathSeparator=";"
                             relative="true"/>

<getJdtSourcePath>

Scope: JDT projects

Description

The getJdtSourcePath 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

The getJdtClassPath 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
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)
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)

Example usage

Resolving the source path to an ant path
The following example shows how to resolve the source path of an eclipse JDT project to an ant path:

<ant4eclipse:getJdtSourcePath pathId="sourcepath"
                              workspacedirectory="${workspace}" 
                              projectName="simple.java.project" />

Resolving the source path to an ant property
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 class path 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 attribute to explicitly specify a character that is used to separate the entries of the source path.

<ant4eclipse:getJdtSourcePath property="sourcepath"
                              workspacedirectory="${workspace}" 
                              projectName="simple.java.project" />

Resolving relative pathes: 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.

<ant4eclipse:getJdtSourcePath property="sourcepath"
                              workspacedirectory="${workspace}" 
                              projectName="simple.java.project"
                              relative="true" />

<getJdtOutputPath>

Scope: JDT projects

Description

The getJdtOutputPath task resolves the output folders of an eclipse project. The output 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

The getJdtOutputPath 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
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)
resolve Determines what kind of output folder should be resolved. If set to defaultFolder, the default output location will be returned. If set to forSourceFolder, the output folder for a specified source folder will be returned. If set to all, all output folders will be returned. no (default: defaultFolder)
sourceFolder If resolve is set to 'forSourceFolder', you must also specify a source folder. If this source folder has its own out folder, it will be returned. Otherwise the default output folder will be returned. no (yes, if 'resolve' is set to 'forSourceFolder')
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)

Example usage

Resolving the default output folder to a path
The following example resolves the default output path of the project simple.java.project to a path with the id defaultoutpath:

<ant4eclipse:getJdtOutputPath workspacedirectory="${workspace}"
                              projectName="simple.java.project"
		              pathId="defaultoutpath" />

Resolving the default output folder to a property
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:

<ant4eclipse:getJdtOutputPath workspacedirectory="${workspace}"
                              projectName="simple.java.project"
		              property="defaultoutpath" />

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.

Resolving a specific output folder to a property
The following example shows how to resolve the output folder for a specific source folder (e.g. 'src2'):

<ant4eclipse:getJdtOutputPath workspacedirectory="${workspace}"
                              projectName="simple.java.project"
		              property="outpath" 
                              resolve="forSourceFolder"
		              sourceFolder="src2" />

<installedJREs>

Scope: JDT projects

Description

The installedJREs type allows you to define several Java Runtime Environments (JREs) that are available in your build environment. Ant4Eclipse uses these definitions to resolve the so called Java System Library that is part of each JDT-based project. To define a JRE, you just have to provide a name and the path to the JRE. Ant4Eclipse automatically detects the version of the defined JRE as well as the corresponding JARs. It is also possible to define a default JRE. If you haven't chosen a specific JRE in the build path of your project, the default JRE will be taken.

Note: Please make sure that your JREs have the same names as defined in your eclipse IDE (Window->Preferences..., Java->Installed JREs). Otherwise Ant4Eclipse may is not able to resolve the JRE System Library of a given project.

Arguments

The installedJREs datatype provides the following arguments:

Argument Description Required
default The id of a jre that should be used as the default JRE no

Nested Elements

A JRE must be defined using the nested jre element that allows the following arguments:

Argument Description Required
id The name of the JRE as specified within the Eclipse preferences. yes
location The filesystem location of the corresponding JRE root directory. yes
extDirs The filesystem location of the java.ext.dirs. This parameter is only used if no fileset with JARs has been specified. no
endorsedDirs The filesystem location of the java.endorsed.dirs. This parameter is only used if no fileset with JARs has been specified. no

Example usage

Let's say you're generally using the following VM's in your Eclipse environment (the VM's are configured within Eclipse under Preferences->Java->Installed JREs):

  • JRE 1.4 named as JDK_1_4 (C:\jdks\jdk1.4.2)
  • JRE 1.5 named as JDK_1_5 (C:\jdks\jdk1.5.0)
  • JRE 1.6 named as JDK_1_6 (C:\jdks\jdk1.6.0)

Now you have JRE 1.4 as the default one but some projects do require 1.5 or 1.6. This can be configured using the following setup:

<ant4eclipse:installedJREs default="JDK_1_4">
    <jre id="JDK_1_4" location="C:\jdks\jdk1.4.2"/>
    <jre id="JDK_1_5" location="C:\jdks\jdk1.5.0"/>
    <jre id="JDK_1_6" location="C:\jdks\jdk1.6.0"/>
  </ant4eclipse:installedJREs>

That would make the JDKs JDK_1_5 and JDK_1_6 available for projects that have the corresponding org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/<id> entry in their .classpath file and JDK_1_4 available for projects that
have the org.eclipse.jdt.launching.JRE_CONTAINER on their classpath.

<userLibraries>

Scope: JDT projects

Description

The userLibraries type allows you to define pathes from an eclipse user librariies configuration. This is necessary if you use user libraries in a class path that must be resolved by ant4eclipse.

This type reads an exported user libraries definition file and creates an appropriate path instance for each defined library, containing all pathes of the library. The created path instances gets an id assigned that follows the naming schema 'org.eclipse.jdt.USER_LIBRARY/name of the library'.

To use this type, you first have to export the userdefined libraries from eclipse: to do so, use the Export..."-Feature in the preference dialog ("Window->Preferences...", then "Java->Build Path->User Libraries"). The exported file can easily included in your buildfile by using this type.

This way these entries can be resolved and used by the other Ant4Eclipse tasks.

Arguments

The userLibraries datatype provides the following arguments:

Argument Description Required
userlibraries Location of an eclipse userlibraries export file. yes

Example usage

To import user libraries file 'myUserLibraries.xml' that has been exported by eclipse previously:

<ant4eclipse:userLibraries userlibraries="${basedir}/../myUserLibraries.xml"/>

<buildJdtProject>

Scope: JDT Projects

Description

This macro builds an Eclipse Java (JDT) project. It reads all informations needed to build the project (classpath, project directory structure, compiler settings etc) from the standard eclipse configuration files like .classpath and .settings-files. The project is compiled using the Eclipse java compiler.

Important: This task is implemented as an Ant macro. To use this task, you have to import the file 'a4e-jdt-macros.xml' in your build file.

Arguments

The buildPlugin 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 that you want to build yes
targetPlatformId The id of the target platform. no, only in case your project (or one of it's dependencies) is a PDE plug-in project
defaultCompilerOptionsFile The location of a properties file that contains the settings for the eclipse compiler. This settings will be used if no project-specific settings file is available.  This option also allows to handle an exported eclipse preferences file. no
targetLevel The language level of the generated bytecode (e.g. 1.4 or 1.5) no
sourceLevel The language level of the source files (e.g. 1.4 or 1.5) no, defaults to the specified targetLevel
useEcj Enables or disables the use of the ecj compiler as the backend. no, default to true

A note on compiler settings: You should either use defaultCompilerOptionsFile or targetLevel/sourceLevel. If you both the defaultCompilerOptionsFile takes precedence over the targetLevel/sourceLevel-argument.

Lifecycle hooks

To allow the user of ant4eclipse to add additional build steps to the build process, the buildJdtProject macro defines the following lifecycle hooks that are implement as macro elements.

Build phase Description Required
initialize Initialize build state, e.g. set properties or create directories. no
generate-sources Generate any source code for inclusion in compilation. no
generate-resources Generate resources for inclusion in the package. no
pre-compile Execute additional steps before compilation. no
post-compile Post-process the generated files from compilation, for example to do bytecode enhancement on Java classes.. no
finish Finish the build process. This can be used to take further actions, like packaging the project no

Scoped properties

The following scoped properties are available within the lifecycle hooks:

Property Description Build phase
buildJdtProject.project.name The name of the project All phases
buildJdtProject.project.directory Absolute path of the project directory All phases
buildJdtProject.<project nature name> true (this property is set for each project nature the project contains) All phases
buildJdtProject.boot.classpath The boot class path of the used JRE. All phases
buildJdtProject.classpath.relative.runtime The runtime class path of the JDT project, relative to the workspace location. All phases
buildJdtProject.classpath.absolute.runtime The absolute runtime class path of the JDT project. All phases
buildJdtProject.classpath.relative.compiletime The compile time class path of the JDT project, relative to the workspace location. All phases
buildJdtProject.classpath.absolute.compiletime The absolute compile time class path of the JDT project. All phases
buildJdtProject.default.output.directory The absolute path of the default ouput directory. All phases
buildJdtProject.default.output.directory.name The name of the default ouput directory. All phases
buildJdtProject.source.directories The source directories (only set if the project contains source directories) All phases

Scoped references

The following scoped references are available:

Reference Description Build phase
buildJdtProject.project.directory.path The project directory as an ant path All phases
buildJdtProject.boot.classpath.path The boot class path of the used JRE. All phases
buildJdtProject.classpath.relative.runtime.path The runtime class path of the JDT project, relative to the workspace location. All phases
buildJdtProject.classpath.absolute.runtime.path The absolute runtime class path of the JDT project. All phases
buildJdtProject.classpath.relative.compiletime.path The compile time class path of the JDT project, relative to the workspace location. All phases
buildJdtProject.classpath.absolute.compiletime.path The absolute compile time class path of the JDT project. All phases
buildJdtProject.default.output.directory.path The absolute path of the default ouput directory. All phases
buildJdtProject.source.directories.path The source directories (only set if the project contains source directories) All phases

Example usage

The following example builds the jdt project with the project name 'example-project'. It will use the java version 1.5 if there is no project specific compiler settings file inside the project:

<buildJdtProject workspaceDirectory="${workspaceDirectory}" 
  projectName="example-project"
  targetLevel="1.5"/>

This example uses the jdtProjectFileSet in the finish phase to build a jar containing the project's classes that have been built:

<buildJdtProject workspaceDirectory="${workspaceDirectory}" 
  projectName="example-project"
  targetLevel="1.5">
  <finish>
    <jar destfile="c:/example-project.jar">
      <ant4eclipse:jdtProjectFileSet
        workspaceDirectory="${workspaceDirectory}"
        projectName="${buildJdtProject.project.name}"/>
    </jar>
  </finish>		
</buildJdtProject>

<jdtClassPathLibrary>

Scope: JDT projects

Description

The jdtClassPathLibrary datatype can be used to define class path libraries (aka class path containers).

Note: Registering class path libraries manually should be used as the last resort to define class path libraries.

Arguments

The jdtClassPathLibrary datatype provides the following arguments:

Argument Description Required
name name of the class path library yes

Nested Elements

You can use any file resource collection to define a class path library. Please take a look at ant's documentation for further information about file resource collections.

Example usage

The following example defines a class path library named 'myClassPathLibrary':

<ant4eclipse:jdtClassPathLibrary name="myClassPathLibrary">
  <fileset dir="D:/test" />
</ant4eclipse:jdtClassPathLibrary >

The following examples defines the class path library 'org.eclipse.jdt.junit.JUNIT_CONTAINER/3':

<ant4eclipse:jdtClassPathLibrary name="org.eclipse.jdt.junit.JUNIT_CONTAINER/3">
  <fileset dir="C:/eclipse-3.5/plugins/org.junit_3.8.2.v20090203-1005"/>
</ant4eclipse:jdtClassPathLibrary >

<jdtClassPathVariable>

Scope: JDT projects

Description

The jdtClassPathVariable type allows you to define class path variables. The definition of class path variables is necessary if you want to resolve a JDT project with a class path variable entry.

A class path variable can be added to a project's class path. It can be used to define the location of a JAR file or a directory that isn't part of the workspace.

Arguments

The jdtClassPathVariable type provides the following arguments:

Argument Description Required
name The name of the class path variable as specified in the eclipse preferences. yes if file is not set
path The path to the folder or the jar file. yes if file is not set
file A properties file which consists classpath variables where the key is the name and the path is the value. no

Usage examples

<ant4eclipse:jdtClassPathVariable name="ECLIPSE_HOME" path="/usr/eclipse34" />
<ant4eclipse:jdtClassPathVariable name="MY_VAR" path="/my/path" />
<ant4eclipse:jdtClassPathVariable name="MY_VAR_2" path="/my/path/myjar.jar" />

<jdtProjectFileSet>

Scope: JDT Projects

Description

The jdtProjectFileSet works like the 'regular' Ant FileSet. It lists all resources from all source and/or output folders of a jdt project. It can be used whereever Ant supports a Resource Collection, for example in the jar or copy tasks.

Arguments

The jdtProjectFileSet type defines the following attributes:

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
includeOutputFolders Determines whether the contents of the project's output folder(s) should be included in the FileSet no (defaults to true)
includeSourceFolders Determines whether the contents of the project's sourcefolder(s) should be included in the FileSet no (defaults to false)
defaultexcludes Indicates whether Ant's default excludes should be used or not (yes | no); default excludes are used when omitted. no
includes comma- or space-separated list of patterns of files that must be included; all files are included when omitted. no
excludes comma- or space-separated list of patterns of files that must be excluded; no files (except default excludes) are excluded when omitted. no

Nested Elements

The jdtProjectFileSet supports include and exclude sub-elements that can be used to specify which resources should (not) be included in the result. Both sub-elements support a name attribute that must be set to the pattern.

Example usage

The following code creates a jar file that contains the contents of all output folders of a project

<jar destfile="r:/my-project.jar">
  <ant4eclipse:jdtProjectFileSet workspaceDirectory="${workspaceDirectory}" 
    projectName="my-project"/>
</jar>

This examples creates a source jar of a project:

<jar destfile="r:/my-project-sources.jar">
  <ant4eclipse:jdtProjectFileSet workspaceDirectory="${workspaceDirectory}" 
    projectName="my-project" includeSourceFolders="true" includeOutputFolders="false"/>
</jar>

Copies all non-java resources from both source and output folders of a project:

<copy todir="c:/resources">
  <ant4eclipse:jdtProjectFileSet workspaceDirectory="${workspaceDirectory}" 
    projectName="my-project" includeSourceFolders="true" includeOutputFolders="true">
    <exclude name="**/*.java"/>
  </ant4eclipse>
</copy>

The ECJ compiler adapter

Scope: JDT projects

Ant4Eclipse provides it's own compiler adapter that allows you to use the eclipse compiler for Java (ECJ) within the ant <javac> task.

Advantages

Using the ECJ has many advantages over using the standard javac from the underlying JDK:

Enabling the ECJ compiler adapter (classic way)

To enable the ECJ, you have to set the Ant4Eclipse ECJ compiler adapter. This can be done by either setting the global build.compiler property, which will affect all <javac> tasks throughout the build, or by setting the compiler attribute, specific to the current <javac> task. The value to enable the Ant4Eclipse EcjCompilerAdapter is org.ant4eclipse.jdt.ecj.EcjCompilerAdapter.

The following example shows how to enable the Ant4Eclipse ECJ compiler adapter:

<javac destdir="${default.output.directory}"
       compiler="org.ant4eclipse.jdt.ecj.EcjCompilerAdapter" >
  ...
</javac>

Enabling the ECJ compiler adapter (modern way)

Alternatively you can make use of the jdtCompiler which is just an extension of the javac task simply allowing to switch between the javac and ecj compiler backend.

The following example shows how to enable the Ant4Eclipse ECJ compiler adapter:

<jdtCompiler destdir="${default.output.directory}" useecj="true">
  ...
</jdtCompiler>

Setting compiler options

The compiler options can be set in several ways.

Setting javac attributes

Setting JDT compiler option files

THe JDT compiler options file can be found at
workspace\.metadata\.plugins\org.eclipse.core.runtime\.settings\org.eclipse.jdt.core.prefs or
project\.settings\org.eclipse.jdt.core.prefs. You can set the compiler option files using the compilerarg element:

<javac destdir="${buildPlugin.default.output.directory}"
      compiler="org.ant4eclipse.jdt.ecj.EcjCompilerAdapter" >
      ...
  <compilerarg value="compiler.options.file=my/project/path/.settings/org.eclipse.jdt.core.prefs"
            compiler="org.ant4eclipse.jdt.ecj.EcjCompilerAdapter" /> 
</javac>

<javac destdir="${buildPlugin.default.output.directory}"
      compiler="org.ant4eclipse.jdt.ecj.EcjCompilerAdapter" >
      ...
  <compilerarg value="default.compiler.options.file=my/path/org.eclipse.jdt.core.prefs"
            compiler="org.ant4eclipse.jdt.ecj.EcjCompilerAdapter" /> 
</javac>

Example usage

<javac destdir="${default.output.directory}"
      compiler="org.ant4eclipse.jdt.ecj.EcjCompilerAdapter" >
  <src refid="source.directories.path" />
  <bootclasspath refid="boot.classpath.path" />
  <classpath refid="classpath.absolute.compiletime.path" />
</javac>

PDE related tasks & macros

<buildPlugin>

Scope: PDE Projects

Description

This macro builds an eclipse plug-in project. It reads the information from the MANIFEST and the build.properties file and builds the plugin according to these settings.

Important: This task is implemented as an Ant macro. To use this task, you have to import the file 'a4e-pde-macros.xml' in your build file.

Arguments

The buildPlugin 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 Either projectName or featureId (and optional featureVersion) has to be set
targetPlatformId The id of the target platform. yes
platformConfigurationId The id of the platform configuration (for cross platform builds). no
destination Name of the directory that will contain the plugin after building (same as the 'Destination directory' in the PDE-Export wizard in Eclipse). The plugin will be built in to <destination>/plugins/<Bundle-SymbolicName>_<Bundle-Version>.jar. yes
packageAsJar If set to true the plugin will be packaged as a jar file. Otherwise it will be an exploded directory. no (default: true)
buildSourceJar If set to true an additional source plugin will be created for the specified plugin project. no (default: true)
defaultCompilerOptionsFile Absolute path to an eclipsed compiler options file that is used as the default compiler options file if no project specific file exists. no
newBundleVersion If the newBundleVersion attribute is set, the resulting bundles has this version instead of the one definied in the plug-in project's manifest. no
clean Indicates that the output folder of the plugin project should be cleaned prior building. no (default: true)
useEcj Enables or disables the use of the ecj compiler as the backend. no, default to true

Lifecycle hooks

To allow the user of ant4eclipse to add additional build steps to the plug-in build, the buildPlugin macro defines the following lifecycle hooks that are implement as macro elements.

Build phase Description Required
validate Validate the project is correct and all necessary information is available. no
initialize Initialize build state, e.g. set properties or create directories. no
generate-sources Generate any source code for inclusion in compilation. no
generate-resources Generate resources for inclusion in the package. no
pre-compile Execute additional steps before compilation. Note: This lifecycle hook is only available if the executed plug-in project is a java project. no
post-compile Post-process the generated files from compilation, for example to do bytecode enhancement on Java classes. Note: This lifecycle hook is only available if the executed plug-in project is a java project. no
pre-package-library Execute additonal steps before packaging a library. no
post-package-library Execute additonal steps after packaging a library. no
prepare-package Copy the final package from the destination to aremote repository or whatever. no
deploy Perform any operations necessary to prepare a package before the actual packaging. no

Scoped properties

The following scoped properties are available within the lifecycle hooks:

Property Description Build phase
buildPlugin.project.name The name of the project All phases
buildPlugin.project.directory Absolute path of the project directory All phases
buildPlugin.<project nature name> true (this property is set for each project nature the project contains) All phases
buildPlugin.boot.classpath The boot class path of the used JRE. pre-compile, post-compile
buildPlugin.classpath.relative.runtime The runtime class path of the JDT project, relative to the workspace location. pre-compile, post-compile
buildPlugin.classpath.absolute.runtime The absolute runtime class path of the JDT project. pre-compile, post-compile
buildPlugin.classpath.relative.compiletime The compile time class path of the JDT project, relative to the workspace location. pre-compile, post-compile
buildPlugin.classpath.absolute.compiletime The absolute compile time class path of the JDT project. pre-compile, post-compile
buildPlugin.default.output.directory The absolute path of the default ouput directory. pre-compile, post-compile
buildPlugin.default.output.directory.name The name of the default ouput directory. pre-compile, post-compile
buildPlugin.source.directories The source directories (only set if the project contains source directories) pre-compile, post-compile

Scoped references

The following scoped references are available:

Reference Description Build phase
buildPlugin.project.directory.path The project directory as an ant path All phases
buildPlugin.boot.classpath.path The boot class path of the used JRE. pre-compile, post-compile
buildPlugin.classpath.relative.runtime.path The runtime class path of the JDT project, relative to the workspace location. pre-compile, post-compile
buildPlugin.classpath.absolute.runtime.path The absolute runtime class path of the JDT project. pre-compile, post-compile
buildPlugin.classpath.relative.compiletime.path The compile time class path of the JDT project, relative to the workspace location. pre-compile, post-compile
buildPlugin.classpath.absolute.compiletime.path The absolute compile time class path of the JDT project. pre-compile, post-compile
buildPlugin.default.output.directory.path The absolute path of the default ouput directory. pre-compile, post-compile
buildPlugin.source.directories.path The source directories (only set if the project contains source directories) pre-compile, post-compile

Example usage

The following example builds the plug-in project with the project name 'example-bundle'. The built bundle will reside in 'd:/plugins/plugins'.

<buildPlugin workspace="${workspace}"
             projectName="example-bundle"
             targetPlatformId="target.platform"
             destination="d:/plugins" />

The next example shows how to add additional build steps to the build process.
<buildPlugin workspace="${workspace}"
             projectName="example-bundle"
             targetPlatformId="target.platform"
             destination="d:/plugins" >
 
  <generate-sources>
    <!-- add additional build steps here... -->
  </generate-sources>
 
  <post-compile>
    <!-- add additional build steps here... -->
  </post-compile>
 
</buildPlugin>

<buildFeature>

Scope: PDE Projects

Description

This macro builds an eclipse feature project. It reads the information from the file feature.xml and builds the feature according to these settings.

Important: This task is implemented as an Ant macro. To use this task, you have to import the file 'a4e-pde-macros.xml' in your build file.

Arguments

The buildFeature 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 Either projectName or featureId (and optional featureVersion) has to be set
featureId The id of the feature Either projectName or featureId (and optional featureVersion) has to be set
featureVersion The version of the feature Either projectName or featureId (and optional featureVersion) has to be set (default: 0.0.0).
targetPlatformId The id of the target platform. yes
platformConfigurationId The id of the platform configuration (for cross platform builds). no
destination Name of the directory that will contain the plugin after building (same as the 'Destination directory' in the PDE-Export wizardin Eclipse). The plugin will be built in to <destination>/plugins/<Bundle-SymbolicName>_<Bundle-Version>.jar. yes
clearDestination If set to true the content of the destination directory will be deleted before building the feature. no (default: false)
skipBuildFeature If set to true the feature itself will not be built. In this case the macro only builds the defined plugins. no (default: false)
packageAsJar If set to true the feature will be packaged as a jar file. no (default: true)
packagePluginsAsJar If set to true the contained plug-ins will be packaged as jar files. no (default: true)
packagePluginSourcesAsJar If set to true the sources of the contained plug-ins will be build and packaged as jar files. no (default: true)
defaultCompilerOptionsFile Absolute path to an eclipsed compiler options file that is used as the default compiler options file if no project specific file exists. no
cleanPluginBuild Indicates that the output folders of the nested plugin projects should be cleaned prior building. no (default: true)
useEcj Enables or disables the use of the ecj compiler as the backend. no, default to true

Example usage

The following example builds the feature project with the project name 'test.feature'. The built feature will reside in 'd:/plugins'.

<buildFeature workspaceDirectory="${workspace}"
              projectName="test.feature"
              targetplatformid="target.platform"
              destination="d:/plugins" />

<buildProduct>

Scope: PDE Projects

Description

This macro builds a complete eclipse product. This incorporates the build process for each feature/plugin declared by this product.

Important: This task is implemented as an Ant macro. To use this task, you have to import the file 'a4e-pde-macros.xml' in your build file.

Arguments

The buildProduct 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
productfile The location of the product definition file. yes
targetPlatformId The id of the target platform. yes
platformConfigurationId The id of the platform configuration (for cross platform builds). no
destination Name of the directory that will contain the completely built rcp application. yes
packageAsJar If set to true the features/plugins will be packaged as a jar file. Otherwise they will be created as exploded directories. no (default: false)
defaultCompilerOptionsFile Absolute path to an eclipsed compiler options file that is used as the default compiler options file if no project specific file exists. no
os The operating system to create the build for. Must be one of the following values: win32,solaris,macosx,linux. no (default: win32)
clearDestination If set to true the destination directory will be cleaned up before the build actually takes place. no (default: false)
commandline If set to true the commandline version of the rcp will be built. This is only relevant for win32 builds. no (default: false)
packageSources If set to true source bundles will be created, too. no (default: true)
useEcj Enables or disables the use of the ecj compiler as the backend. no, default to true

Lifecycle hooks

To allow the user of ant4eclipse to add additional build steps to the product build, the buildProduct macro defines the following lifecycle hooks that are implement as macro elements. The scope information identifies the properties which are available within this macro define (check out the executeProduct task description for detailed information).

Build phase Description Required Scope
validate Validate the project is correct and all necessary information is available. no forProduct
deploy Perform any operations necessary to prepare a package before the actual packaging. no forProduct

Example usage

The following example builds a product with the project. The built product will be stored into 'd:/my-rcp'.

<buildProduct 
  workspaceDirectory="${workspace}"
  productfile="d:/my-rcp.product"
  targetPlatformId="eclipse-3.4"
  destination="d:/my-rcp" 
  clearDestination="true"
  os="win32"
/>

The next example shows how to add additional build steps to the build process.

<buildProduct 
  workspaceDirectory="${workspace}"
  productfile="d:/my-rcp.product"
  targetPlatformId="eclipse-3.4"
  destination="d:/my-rcp" 
  clearDestination="true"
  os="win32"
>
 
  <deploy>
    <!-- sometimes we just want to add some documentation -->
    <mkdir dir="d:/my-rcp/docs"/>
    <copy todir="d:/my-rcp/docs">
      <fileset dir="V:/my-rcp/docs" includes="**/*"/>
    </copy>
  </deploy>
</buildProduct>

<targetPlatform>

Scope: PDE Projects

Description

The targetPlatform type can be used to define a PDE target platform. Target platforms are used when working with plugin and feature projects. They define locations where binary, plugins can be found (e.g. an existing eclipse installation).

A target platform may consist of more than one directory. A directory listed in the targetPlatform type has to be the parent directory of the plugins directory that contains the plugins (e.g. if you would like to include the plugins of your eclipse distribution, you would add "c:/eclipse" (or whereever you've installed Eclipse) as a directory and not "c:/eclipse/plugins").

You can use the target platform within the ant4eclipse tasks by refering to it with the target platform id.

Arguments

The targetPlatform type provides the following arguments:

Argument Description Required
id An id that can be used to reference this platform definition later in your buildfile yes

Nested elements

Each directory you want to include in your platform definition must be added using a location element.

Argument Description Required
dir The directory that should be added to your platform definition. Inside this directory there must be
the plugins directory that contain the plugins
yes

Example usage

The following example creates a target platform defintion that consists of one directory. The defintion can be referenced via it's id 'eclipse-3.5':

<project name="..." default="...">
 
  <ant4eclipse:targetPlatform id="eclipse-3.5">
    <location dir="c:/eclipse-3.5" />
    <location dir="d:/addtionalLocation" />
  </ant4eclipse:targetPlatform> 
 
 </project>

<executePluginProject>

Scope: PDE projects

Description

The executePluginProject task allows you to iterate over the plug-in libraries defined in a PDE project.

Arguments

The executePluginProject 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:

  • forPluginLibrary: executed for each plug-in library
  • forProject: executed once

Scoped Properties

Several properties and references are "passed in", so you can access them within the forPluginLibrary or forProject elements. You can access the following scoped properties:

Property Availability Description
<prefix>.bundle.version all elements The specified version of the bundle (e.g. 1.0.0.qualifier).
<prefix>.bundle.resolved.version all elements The resolved version of the bundle (e.g. 1.0.0.200906121533).
<prefix>.build.properties.binary.includes all elements The list of all included files and directories for a binary build (as specified in the build.properties).
<prefix>.build.properties.binary.excludes all elements The list of all excluded files and directories for a binary build (as specified in the build.properties).
<prefix>.library.name forEachLibrary The name of the current library.
<prefix>.library.isSelf forEachLibrary true if this is the 'self' library, false otherwise.

Example usage

The following example shows the usage of the executePluginProject task:

<ant4eclipse:executePluginProject workspaceDirectory="${workspaceDirectory}"
                                  projectName="${projectName}" >
 
  <!-- execute once for the project -->
  <ant4eclipse:forProject>
    ...
  </ant4eclipse:forProject>
 
  <!-- execute for each library (except the 'self' library) -->
  <ant4eclipse:forEachPluginLibrary filter="(library.isSelf=false)">
    ...
  </ant4eclipse:forEachPluginLibrary>
 
  <!-- execute for each library (only for the 'self' library) -->
  <ant4eclipse:forEachPluginLibrary filter="(library.isSelf=true)">
    ...
  </ant4eclipse:forEachPluginLibrary>
 
</ant4eclipse:executePluginProject>

<executePluginLibrary>

Scope: PDE projects

Description

The executePluginLibrary allows you to iterate over the source and output entries of plug-in libraries defined in the build.properties file of a PDE project.

Arguments

The executePluginLibrary 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 (PDE) eclipse project yes
libraryName Name of library 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 entries specified in the build.properties file, you can define one or more nested elements. Those elements can contain several task calls, similar to an ant target element. The following elements are defined:

  • forEachSourceDirectory: executed for each source directory
  • forEachOutputDirectory: executed for each output directory
  • ForLibrary: executed once for the library

Scoped Properties

Several properties and references are "passed in", so you can access them within the forEachSourceDirectory, forEachOutputDirectory
or ForLibrary elements. You can access the following scoped properties:

Property Availability Description
<prefix>.library.name all elements The name of the current library.
<prefix>.library.isSelf all elements true if this is the 'self' library, false otherwise.
<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 forEachOutputDirectory The absolute path of the current ouput directory.
<prefix>.output.directory.name forEachOutputDirectory The name of the current ouput directory.
<prefix>.project.name all elements The name of the project
<prefix>.project.directory all elements Absolute path of the project directory
<prefix>.<project nature name> all elements true (this property is set for each project nature the project contains)

Example usage

The following example shows the usage of the executePluginProject task:

<ant4eclipse:executePluginLibrary workspace="${workspaceDirectory}"
		                  projectname="${project.name}"
		                  libraryname="${library.name}">
 
  <!-- execute for each output directory -->
  <ant4eclipse:forEachOutputDirectory>
    ...
  </ant4eclipse:forEachOutputDirectory>
 
  <!-- execute for each source directory -->
  <ant4eclipse:forEachSourceDirectory>
    ...
  </ant4eclipse:forEachSourceDirectory>
 
</ant4eclipse:executePluginLibrary>

<pdeProjectFileSet>

Scope: PDE Projects

Description

The pdeProjectFileSet type can be used to define plug-in project relative file sets.

Note: The bundle root ('.') will be resolved to a directory with the name '@dot'.

Arguments

The pdeProjectFileSet type defines the following attributes:

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
includes Comma-separated list of patterns of files that must be included; no files are included when omitted. no
excludes Comma-separated list of patterns of files that must be excluded; no files (except default excludes) are excluded when omitted. no
defaultexcludes Indicates whether default excludes should be used or not (yes | no); default excludes are used when omitted. no
casesensitive Must the include and exclude patterns be treated in a case sensitive way? Defaults to true. no

Example usage

<copy todir="${destination}"
      overwrite="true">
 
  <ant4eclipse:pdeProjectFileSet workspace="${workspaceDirectory}"
                                 projectname="${project.name}"
                                 includes="META-INF,.,OSGI-INF"
                                 excludes="META-INF/todos.txt" />
</copy>

<executeFeature>

<platformConfiguration>

Scope: PDE Projects

Description

The platformConfiguration type can be used to define a PDE platform configuration. Platform configurations are used in conjunction with target platforms. They define the system platform to resolve a given target platform for. As the default the system configuration of the machine where the ant4eclipse build is running is used. If you want to execute cross-platform build, you have to specify the platform configuration explicitly.

You can use the platform configuration within the ant4eclipse tasks by refering to it with the platform configuration id.

Arguments

The platformConfiguration type provides the following arguments:

Argument Description Required
id An id that can be used to reference this platform definition later in your buildfile yes
windowingSystem the windowing system (e.g. 'win32', 'gtk') yes
operatingSystem the operating system (e.g. 'win32', 'linux') yes
architecture the architecture (e.g. 'x86') yes

Example usage

The following example creates a platform configuration. The defintion can be referenced via it's id 'win32.win32.x86':

<project name="..." default="...">
 
  <ant4eclipse:platformConfiguration id="win32.win32.x86"
                                     windowingSystem="win32"
                                     operatingSystem="win32"
                                     architecture="x86" />
 
</project>

<executeProduct>

Scope: PDE projects

Description

The executeProduct task allows you to iterate over all plug-ins and features specified within a product file. This build process is probably the most comfortable way to build an eclipse release since you only need to supply a product description.

Arguments

The executeProduct 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
product The path of the product description file as exported by Eclipse yes
os The operating system used for the build. Must be one of the following values: win32,macosx,solaris,linux yes
targetPlatformId The Id of a previously declared target platform. yes

Nested Elements

To iterate over source or output folders specified in a 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:

  • forProduct: executes for a product
  • forEachFeature: executes for each feature
  • forEachPlugin: executes for each plugin

Scoped Properties

Several properties and references are "passed in", so you can access them within these scoped elements. Following scoped properties are available:

Property Availability Description
<prefix>.product.id all elements The id of the product (e.g. myapp.product).
<prefix>.product.name all elements The name of the product (e.g. ultimate application).
<prefix>.product.basedonfeatures all elements A boolean value indicating whether the product is based on features or not.
<prefix>.product.applicationid all elements The id of the application which is established by the build.
<prefix>.product.launchername all elements The name which has been configured for the launcher.
<prefix>.product.version all elements The version information of the product. Will be 0.0.0 if none has been configured.
<prefix>.product.vmargs all elements The vm arguments selected for the build. Empty if none are provided.
<prefix>.product.programargs all elements The program arguments selected for the build. Empty if none are provided.
<prefix>.product.configini all elements The path of the config.ini file which has to be used for the product. Empty when none has been specified. The file may not exist !
<prefix>.product.guiexe all elements The path to the executable used to launch the gui of the eclipse rcp.
<prefix>.product.cmdexe all elements The path to the executable used to launch the commandline of the eclipse rcp.
<prefix>.feature.id forEachFeature The id of the feature currently iterated.
<prefix>.feature.version forEachFeature The version of the feature currently iterated.
<prefix>.plugin.id forEachPlugin The id of the plugin currently iterated.
<prefix>.plugin.isSource forEachPlugin A boolean value indicating whether the plugin is part of the workspace (is source) or not.

Example usage

The following example shows the usage of the executeProduct task:

<ant4eclipse:executeProduct 
  workspaceDirectory="${workspaceDirectory}"
  product="my.product" 
  os="win32"
  targetPlatformId="K:/my-platform"
>
 
  <!-- execute once for the product -->
  <ant4eclipse:forProduct>
    ...
  </ant4eclipse:forProduct>
 
  <!-- execute for each included feature -->
  <ant4eclipse:forEachFeature>
    ...
  </ant4eclipse:forEachFeature>
 
  <!-- execute for each included plugin -->
  <ant4eclipse:forEachPlugin>
    ...
  </ant4eclipse:forEachPlugin>
 
</ant4eclipse:executeProduct>

<patchFeatureManifest>

Python related tasks and macros

<getPythonPath>

Scope: Python projects

Description

The getPythonPath task resolves the python path of an eclipse project. This task reads and parses the python related project artefacts in order to access these pathes. The pythonpath can be resolved to ant's path type or to a string property. The pythonpath can be resolved in a relative (to the given workspace) or absolute manner. In case the pythonpath is resolved to a path type, it can be referenced using the ref-id attribute wherever a pythonpath must be used.

Arguments

The getPythonPath 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
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)
ignoreruntime Boolean value that determines whether a runtime has to be set or not. If set to true you must register a python runtime first. no (default: false)

Example usage

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

  <ant4eclipse:getPythonPath 
    workspaceDirectory="${workspace}"
    projectName="simple.python.project"
    property="pythonpath"
    ignoreruntime="true"
    pathSeparator=";"
  />

You can also export a pythonpath to an ant path:

  <ant4eclipse:getPythonPath 
    pathId="pythonpath"
    workspaceDirectory="${workspace}"
    ignoreruntime="true"
    projectName="simple.python.project" 
  />

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

  <ant4eclipse:getPythonPath 
    property="pythonpath"
    workspaceDirectory="${workspace}"
    projectName="myProject"
    pathSeparator=";"
    ignoreruntime="true"
    relative="true"
  />

<getPythonSourcePath>

Scope: Python projects

Description

The getPythonSourcePath task resolves the source folders of an eclipse python 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

The getPythonClassPath 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
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)
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)

Example usage

Resolving the source path to an ant path

The following example shows how to resolve the source path of an eclipse python project to an ant path:

  <ant4eclipse:getPythonSourcePath 
    pathId="sourcepath"
    workspaceDirectory="${workspace}" 
    projectName="simple.python.project" 
  />

Resolving the source path to an ant property

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 source path 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 attribute to explicitly specify a character that is used to separate the entries of the source path.

  <ant4eclipse:getPythonSourcePath 
    property="sourcepath"
    workspaceDirectory="${workspace}" 
    projectName="simple.python.project" 
  />

Resolving relative pathes

The entries of the paths are absolute paths by default. You can use the boolean relative argument to receive a path that consists of path entries that are relative to the project directory.

  <ant4eclipse:getPythonSourcePath 
    property="sourcepath"
    workspaceDirectory="${workspace}" 
    projectName="simple.source.project"
    relative="true" 
  />

<pythonContainer>

Scope: Python projects

Description

The pythonContainer type allows to declare python installations where each installation obviously provides an interpreter and a library (the runtime environment).

Arguments

The pythonContainer task provides the following arguments:

Argument Description Required
default The id of the python installation that shall be used as the default. no (Defaults to the first listed installation).

Each installation will be declared using a separate child element pyre within that container element:

Argument Description Required
id The id allowing to identify the installation. yes
location The location to the root of a python installation. yes
sitePackages Boolean value allowing to decide whether site packages (located within the directory site-packages) shall be considered part of the pythonpath or not. no (Default: true)

Currently the following types of python are supported:

Example usage

  <ant4eclipse:pythonContainer default="cpython-2.5">
    <ant4eclipse:pyre id="cpython-2.5" location="/usr/lib/python/cpython/2.5"/>
    <ant4eclipse:pyre id="cpython-2.6" location="/usr/lib/python/cpython/2.6"/>
  </ant4eclipse:pythonContainer>

<pythonDoc>

Scope: Python projects

Description

The pythonDoc task allows to extract api documentation from python source code. Rather than using the internal documentation tools from python this task uses Epydoc which produces a much nicer document structure. This package is bundled as a library of this ant task so it's not necessary to explicitly perform any kind of installation.

Arguments

The pythonDoc task provides the following arguments:

Argument Description Required
sourcedir A directory containing the python source code. yes
destdir The location where the generated api documentation will be stored to. yes
runtime The id of a python runtime used to generate the documentation with. yes

Example usage

Simple generation of python documentation:

  <ant4eclipse:pythonContainer default="cpython-2.5">
    <ant4eclipse:pyre id="cpython-2.5" location="/usr/lib/cpython/2.5"/>
    <ant4eclipse:pyre id="cpython-2.6" location="/usr/lib/cpython/2.6"/>
  </ant4eclipse:pythonContainer>
 
  <ant4eclipse:pythonDoc 
    runtime="cpython-2.6"
    sourcedir="/users/kasimir/python/sample1/sources"
    destdir="/users/kasimir/python/sample1/apidoc"
  />