| Java, Eclipse and Web programming Tutorials |
Version 1.3
Copyright © 2008 - 2009 Lars Vogel
22.10.2009
| Revision History | ||
|---|---|---|
| Revision 0.1 | 15.09.2008 | Lars Vogel |
| First draft of article | ||
| Revision 0.2 | 20.11.2008 | Dominik Zapf |
| Added ant description | ||
| Revision 0.3 | 30.11.2008 | Lars Vogel |
| Corrections | ||
| Revision 0.4 | 10.12.2008 | Dominik Zapf |
| Corrections | ||
| Revision 0.5 | 27.12.2008 | Lars Vogel |
| Created separate article for PDE build, fixed description | ||
| Revision 0.6 | 30.12.2008 | Lars Vogel |
| Feature build now works | ||
| Revision 0.7 | 11.01.2009 | Lars Vogel |
| Simplified the build example | ||
| Revision 0.8 | 12.01.2009 | Lars Vogel |
| Minor adjustments | ||
| Revision 0.9 | 27.07.2009 | Lars Vogel |
| Started update to Eclipse 3.5 | ||
| Revision 1.0 | 28.07.2009 | Lars Vogel |
| Update to Eclipse 3.5 | ||
| Revision 1.1 | 05.09.2009 | Lars Vogel |
| Fixed error with location of build.mxl | ||
| Revision 1.2 | 10.09.2009 | Lars Vogel |
| reworked article | ||
| Revision 1.3 | 22.10.2009 | Lars Vogel |
| Removed hard-coded I.TestBuild from build.xml | ||
Table of Contents
PDE/Build is a Apache Ant based build system for Eclipse RCP application and Eclipse plugins. This build system is also called "headless" build because it does not require a running Eclipse UI to create your product.
The PDE build system is part of the Eclipse plugin org.eclipse.pde.build.
This tutorial uses PDE build to create a executable application for an Eclipse RCP project.
The delta pack is required to use PDE/build.
This deltapack contains the platform specific features and plugins which are required for building Eclipse product for all platforms. It also includes binary launchers for all platforms in the feature "org.eclipse.equinox.executable".
The deltapack can be found http://download.eclipse.org/eclipse/downloads/ . Select the release for are interested in, e.g. 3.5 and search on the page for "Delta".
Extract the delta pack to a new directory, I recommend to use eclipse install directory and then "/deltapack/eclipse/". So if you installation directory is c:\eclipse35 then it should look like the following.

The following assumes that you are familiar with Eclipse RCP development, e.g. the creation of plugins, features and products. Check Eclipse RCP Tutorial to learn about RCP development. See Eclipse Feature Project to learn how to create feature projects.
PDE/Build requires features based products. In our example we will create one plugin and then a feature which includes this plugin.
Create a new project "de.vogella.build.ui" using the "RCP application with a view" template. See Eclipse RCP Tutorial for details.
Create a feature project "de.vogella.build.feature" which contains the plugin de.vogella.build.ui. See Eclipse Feature Project
Add the plugin "de.vogella.build.ui" to your feature.

Also add the "org.eclipse.rcp" to "Included Feature".

Create a product called "hellorcp.product" in "de.vogella.build.ui". See Create a Eclipse product for information.
Make sure your product runs correctly can can be exported manually via the "Export Product export wizard" in the product. If the manually exported product runs you are ready for the next step in creating a automatic product build.
PDE Build requires the following configuration files:
build.properties
build.xml - ant build script
Create a separate project for your build. Create therefore a general project "de.vogella.build.script" by File -> New -> Project -> General -> Project (not using any template / reference).
Create the file "build.properties". This file define settings for the build process.
Table 1.
| Element | Description |
|---|---|
| product | the product your are building, e.g. /de.vogella.build.ui/hellorcp.product |
| configs | The platform you are building for, e.g. Windows |
| JavaSE-1.6 | This example uses Java 1.6 |
Here is the build.properties for this example
###############################################################################
# Copyright (c) 2003, 2006 IBM Corporation and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#
# Contributors:
# IBM Corporation - initial API and implementation
###############################################################################
product=/de.vogella.build.ui/hellorcp.product
runPackager=true
p2.gathering=true
p2.metadata.repo=file:${builder}/repository
p2.artifact.repo=file:${builder}/repository
#Set the name of the archive that will result from the product build.
#archiveNamePrefix=
# The prefix that will be used in the generated archive.
archivePrefix=yourproduct
# The location underwhich all of the build output will be collected.
collectingFolder=${archivePrefix}
# The list of {os, ws, arch} configurations to build. This
# value is a '&' separated list of ',' separate triples. For example,
# configs=win32,win32,x86 & linux,motif,x86
# By default the value is *,*,*
configs = win32, win32, x86
#configs=win32, win32, x86 & \
# linux, gtk, ppc &\
# linux, gtk, x86 & \
# linux, gtk, x86_64 & \
# linux, motif, x86 & \
# solaris, motif, sparc & \
# solaris, gtk, sparc & \
# aix, motif, ppc & \
# hpux, motif, PA_RISC & \
# macosx, carbon, ppc
#Allow cycles involving at most one bundle that needs to be compiled with the rest being binary bundles.
allowBinaryCycles = true
# Type of build. Used in naming the build output. Typically this value is
# one of I, N, M, S, ...
buildType=I
# ID of the build. Used in naming the build output.
buildId=TestBuild
# Label for the build. Used in naming the build output
buildLabel=${buildType}.${buildId}
# Timestamp for the build. Used in naming the build output
timestamp=007
#this property indicates whether the resolution should be done in development mode (i.e. ignore multiple bundles with singletons)
resolution.devMode=false
skipBase=true
skipMaps=true
skipFetch=true
############# JAVA COMPILER OPTIONS ##############
# For this example:
# We specify the JRE locations for CDC-1.1/Foundation-1.1 and J2SE-1.5
# because these are the required execution environments defined for the
# bundles in the example.
# The location of the Java jars to compile against. Typically the rt.jar for your JDK/JRE
#bootclasspath=${java.home}/lib/rt.jar
# If using an IBM VM, use
#bootclasspath=${java.home}/lib/core.jar;${java.home}/lib/vm.jar
# specific JRE locations to compile against. These values are used to compile bundles specifying a
# Bundle-RequiredExecutionEnvironment. Uncomment and set values for environments that you support
#CDC-1.0/Foundation-1.0= /path/to/rt.jar
CDC-1.1/Foundation-1.1=${java.home}/lib/rt.jar
#OSGi/Minimum-1.0=
#OSGi/Minimum-1.1=
#JRE-1.1=
#J2SE-1.2=
#J2SE-1.3=
#J2SE-1.4=
#J2SE-1.5=${java.home}/lib/rt.jar
JavaSE-1.6=${java.home}/lib/rt.jar
#PersonalJava-1.1=
#PersonalJava-1.2=
#CDC-1.0/PersonalBasis-1.0=
#CDC-1.0/PersonalJava-1.0=
#CDC-1.1/PersonalBasis-1.1=
#CDC-1.1/PersonalJava-1.1=
# Specify the output format of the compiler log when eclipse jdt is used
logExtension=.log
# Whether or not to include debug info in the output jars
javacDebugInfo=false
# Whether or not to fail the build if there are compiler errors
javacFailOnError=true
# Enable or disable verbose mode of the compiler
javacVerbose=true
# Extra arguments for the compiler. These are specific to the java compiler being used.
#compilerArg=
# Default value for the version of the source code. This value is used when compiling plug-ins that do not set the Bundle-RequiredExecutionEnvironment or set javacSource in build.properties
#javacSource=1.3
# Default value for the version of the byte code targeted. This value is used when compiling plug-ins that do not set the Bundle-RequiredExecutionEnvironment or set javacTarget in build.properties.
#javacTarget=1.1
Create the following ant build file "build.xml".
<project default="main">
<property file="build.properties"/>
<target name="main">
<property name="baseLocation" value="${eclipse.home}"/>
<!-- by default, check for deltapack co-located with eclipse -->
<property name="deltapack" value="${eclipse.home}/deltapack/eclipse"/>
<!-- Check that we have a deltapack -->
<available property="haveDeltaPack" file="${deltapack}"/>
<fail unless="haveDeltaPack" message="The deltapack is required to build this product. Please edit buildProduct.xml or set the "deltapack" property." />
<property name="builder" value="${basedir}" />
<property name="buildDirectory" value="${basedir}/buildDirectory"/>
<property name="pluginPath" value="${basedir}/..${path.separator}${deltapack}" />
<property name="buildTempFolder" value="${buildDirectory}" />
<ant antfile="${eclipse.pdebuild.scripts}/productBuild/productBuild.xml" />
<move todir="${basedir}">
<fileset dir="${buildDirectory}/${buildLabel}" includes="*.zip"/>
</move>
<!-- refresh the workspace -->
<eclipse.convertPath fileSystemPath="${basedir}" property="resourcePath"/>
<eclipse.refreshLocal resource="${resourcePath}" depth="infinite"/>
</target>
</project>
The result should look like the following:

Right-click the build.xml in Eclipse and choose Run as --> External Tools Configuration. Create a runtime configuration and make sure that you select "Run in the same JRE as the workspace". This will make sure that the variables, e.g. eclipse_home in file buildProduct.xml are set.

Thank you for practicing with this tutorial.
Please note that I maintain this website in my private time. If you like the information I'm providing please help me by donating.For questions and discussion around this article please use the www.vogella.de Google Group. Also if you note an error in this article please post the error and if possible the correction to the Group.
I believe the following is a very good guideline for asking questions in general and also for the Google group How To Ask Questions The Smart Way.
http://www.vogella.de/code/codeeclipse.html Source Code of Examples
http://wiki.eclipse.org/Equinox/p2/Publisher P2 publisher
http://aniefer.blogspot.com/ Blog from PDE Build developer Andrew Niefer
http://aniefer.blogspot.com/2009/03/building-p2-rcp-products-in-eclipse.html Andrew Niefer's example for PDE build for RCP applications
http://wiki.eclipse.org/Equinox/p2/Adding_Self-Update_to_an_RCP_Application Adding p2 Update to an Eclipse RCP application
http://download.eclipse.org/eclipse/downloads/ Download site from Eclipse containing also the Delta Packs
www.eclipse.org/pde/pde-build Eclipse PDE/Build