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>