Automating Builds with PDE BUILD
Last Updated: June16, 2005
Preparing Build Configuration Files
This
document describes how to automate the building of Eclipse-based features and
their plug-ins using script generators in the org.eclipse.pde.build plug-in in
Eclipse 3.2 stream SDK.
Either an existing Eclipse 3.2 stream SDK or the org.eclipse.releng.basebuilder project on dev.eclipse.org:/home/eclipse can be used in this automated build process. The org.eclipse.releng.basebuilder project contains the minimal set of plug-ins extracted from the latest stable Eclipse 3.2 stream SDK build (a milestone or release) needed to run applications and custom Ant tasks in org.eclipse.ant.core, org.eclipse.pde.build, org.eclipse.pde, and org.eclipse.help.base. This project is used by the Eclipse release engineering team to build Eclipse itself.
It is assumed the reader is starting with a set
of pre-existing features and plug-ins, their build.properties, and has a working
knowledge of Apache Ant. In this document, features, plug-ins and fragments are
also referred to as "elements". The word "distribution" is
used to describe the end result of building a feature, a functional unit comprised
of one or more groupings of plug-ins. The result of building a feature results
in a zip or tar.gz file which contains the binary version of the feature and it's
plug-ins. If the feature contains nested features (i.e. <includes> elements),
the nested features will be built recursively and included in the distribution.
For example, the Eclipse SDK distributions are built from the org.eclipse.sdk
feature which is comprised of features org.eclipse.rcp, org.eclipse.rcp.source,
org.eclipse.platform, org.eclipse.platform.source, org.eclipse.jdt, org.eclipse.jdt.source,
org.eclipse.pde, org.eclipse.pde.source and the org.eclipse.sdk plug-in. The distribution
built from the org.eclipse.sdk feature will therefore contain the binary version
of the org.eclipse.sdk feature and its one plug-in plus the binary versions of
its eight nested features and all their plug-ins.
Commit feature and plug-in projects to CVS repository
Since Eclipse 3.0, PDE Build allows a very flexible organization of feature, plug-in and fragment projects in a CVS repository where:
This flexibility was not present for the Eclipse process
prior to version 3.0 which is one reason for the very flat organization of projects
in the dev.eclipse.org:/home/eclipse repository. It is recommended that this flat
structure not be used as an example. Rather, using a structure similar
to the one used for the Equinox
or Stellation
project should be considered where all files and directories for a given product
are stored under a single directory or module at the cvs root level:
<cvs
root>
/org.eclipse.equinox
/plugins
/all
plug-ins at this level
Once the source for all elements is committed to a repository, the next step consists of recording the location and access method for each feature, plug-in and fragment in one or more map files.
A .map file is a java property file which contains
mappings of elements to their CVS locations and access methods. Map files are
used by PDE Build early in the build process to generate Ant scripts which use
the Ant <cvs> task to export source to a directory. This is described further
below.
Map file entries use the following format:
feature|fragment|plugin@element.Id=<cvs tag>,<access method>:<cvs
user>@<cvs repository>,<cvs password>[,<repository path>
(no starting slash) ]
The <repository path> is only required
when the module (or directory) containing the source for the element does not
match the element.Id or if the directory is not at the root of the repository.
A map file entry must exist for each feature being built, it's <plugin>
elements and it's <includes> elements (ie. nested features and their plug-ins).
Adding a plug-in or fragment to a feature therefore requires updating the map
files with the new element.
Map File Entry Examples
One
or more map files can be used to list the elements. The map files can be kept
under version control. Some examples of map file projects include org.eclipse.releng,
org.eclipse.gef.releng,
org.eclipse.ve.releng.
Generating source features and plug-ins at build time
Source features and plug-ins can be
generated at build time by PDE Build. Source features and associated source plug-ins
are typically generated for a development kit distributions (i.e. SDK). It is
also possible to generate a source plug-in only. This is typically the case for
example features or JUnit testing features.
To generate a source feature
and associated source plug-in at build time, you will need to do the following:
To generate a source plug-in only at build time, you will need to do the following:
Preparing Build Configuration Files
The distilled build process consists of the following four steps:
The script which controls the build sequence is the build.xml Ant script in org.eclipse.pde.build. However this script requires two user-implemented build configuration files,build.properties and customTargets.xml. These two files provide the information on the "where and how" to build specific elements.
Templates of these files are provided in the org.eclipse.pde.build/templates directory and examples are available in org.eclipse.releng.eclipsebuilder, org.eclipse.releng.gefbuilder and org.eclipse.ve.releng.builder for building Eclipse, GEF and VE runtimes, respectively.
The build.properties file defines a number of properties that are used as Ant properties at build time and as arguments to script generators in org.eclipse.pde.build to describe how and where to execute the build. The values for properties listed in this file override any values set in the generated build.xml files. See "Generating Ant scripts from the command line" in the PDE Guide in Eclipse 3.2 stream Help for a description of required and optional properties.
customTargets.xml is an Ant script containing targets called by PDE Build scripts to provide the following information:
The table below lists the
targets that are used to provide this information.
Target | Description |
allElements | This
target lists all features that will be packaged into a binary distribution where
each listing comes in the form of an <ant> call to org.eclipse.pde.build/scripts/genericTargets.xml: Example from org.eclipse.releng.eclipsebuilder/jdt/customTargets.xml: <target
name="allElements"> The
genericTargets.xml
script is an Ant script in the org.eclipse.pde.build plug-in containing targets
which call PDE Build custom Ant tasks to generate scripts for the specified elements
at various stages of the build. This script also executes the generated scripts
at various build stages. The target property is set by it's calling script, org.eclipse.pde.build/scripts/build.xml. |
assemble.<element.id>[.config.spec] | For every configuration specified in the build.properties for the distribution (see configs above), a target named "assemble.<element.id>.<config.spec>" is required. If the distribution is not platform-specific, the ".<config.spec>" section of the target name is not required. Providing the target name should
be all that is required unless you wish to give the produced binary distributable
file a name different from the default "<elment-id>-<buildid>-<config.spec>.zip".
In this case, an explicit value for the property "archiveName" should
be specified at the beginning of the target. <target
name="assemble.org.eclipse.jdt"> <target
name="assemble.org.eclipse.jdt.macosx.carbon.ppc"> |
getMapFiles | The
result of executing this target should be to place *.map files in any directory
or subdirectory under ${buildDirectory}/maps. All .map files found here are concatenated
into a single file ${buildDirectory}/directory.txt. Map file projects are typically
kept under version control in a CVS repository. <!--helper targets---> <target name="tagMapFiles"
if="tagMaps"> |
preSetup and postSetup | Used to run operations before
and after retrieving the map files. <target
name="postSetup"> <target name="getBaseEclipse" unless="baseExists"> <!--this
task definition is available in org.eclipse.releng.basebuilder/plugins/org.eclipse.build.tools.
It removes the _ <version>
from all directories specified as a value for the directory attribute. Not
really necessary, but helpful in this
case to avoid having/needing hard-coded versions in GEF javadoc scripts.--> |
preFetch and postFetch | Used to run operations before and after
fetching source for the build. Example from org.eclipse.releng.gefbuilder/sdk.
This example demonstrates how the postFetch target can be used to set the build
timestamp as a value for "0" in about.mappings files. |
preGenerate and postGenerate | Used
to run operations before and after generating build.xml files for features, plug-ins
and fragments. <target name="postGenerate"> <target name="clean" unless="noclean"> |
preProcess and postProcess | Used to run operations before and after compiling the source. |
preAssemble and postAssemble | Used to run operations before and after assembling the binary distributables. |
postBuild | Used
to run operations at the end of the build. Example from org.eclipse.releng.gefbuilder/sdk.
This example demonstrates how the postBuild target (and a helper target) is used
to gather and place the compile logs in the ${buildLabel} directory. These files
are used in the publishing of the GEF build (see below under Publishing the Build
section). <target name="postBuild"> |
Build
machine setup
This build process can be executed on any of the
Eclipse
3.2 Reference Platforms plus the following:
The cvs, zip and unzip executables should be placed on the system path.
On Windows systems, the HOME environement variable should be set to "c:" (no slash) for CVS operations.
The org.eclipse.releng.basebuilder project can be placed in any directory.
To run the build, execute the following command from
../plugins/org.eclipse.pde.build/scripts to build a single distribution:
java
-jar <path>/startup.jar -application org.eclipse.ant.core.antRunner [-buildfile
build.xml] -Dbuilder=<path to directory containing build.properties and customTargets.xml>
[Ant property settings to override those in build.properties]