Latest blog: PDE Build for OSGi applications | Impressum
  • Categories



  • Suche





    Build Automation for your Target Platform

    The target platform is an important concept for delivering a well defined product. It should always be a deliberate and dedicated step to change it. The article RCP Target Platform Tips points out some important rules to which I fully agree. I would further suggest to automate the build of the target platform in order to define a process for modifications of the target platform. Developers should only need to define the content of the target platform with feature manifests and ensure that the build has access to the corresponding jar files. The tedious compilation of the target platform itself should be left to the PDE build.

    Target Platform as Build Artifact

    Make your automatic build a two step approach:

    1. Build the target platform. This is a basically only a repackaging of binary plug-ins. The build host (i.e. the Eclipse installation which contains the PDE feature) for the target platform must have access to all the features and/or plug-ins you want to have in your target platform
    2. Build your RCP application. The build host for the RCP application uses the target platform from the first step as its base location (i.e. the property $baseLocation of the PDE build script). This ensures that your build fails early if you add dependencies unintentional

    If you use cruise control for build automation you probably want to set up two projects: one to produce the target platform and another to produce your Application. The latter should depend on the former and will so automatically be triggered after the target platform has been redefined.

    A process for changing the target platform

    This approach defines a simple process for creating the platform. In the simplest case the developer only adds a plug-in to the feature which defines the target platform and checks it in. The build takes care to produce the target platform first and then your application.

    If the developer wants to add a new plug-in or feature, which is not yet part of the target platform's build host, it must be added to the build host. Note that you do not have to take care to minimalize the feature you add to the build host. For example, if you only need the EMF plug-in you can conveniently add the complete EMF SDK to the build host: the packaging process takes care to correctly produce the target platform

    PDE, Pluginbuilder and Repackaging

    Building the target platform is a repackaging step. If you just add a binary plugin (i.e. one which is part of your Eclipse installation or target platform as opposed to your own source plug-ins) to your feature and build it with the regular PDE build script you will be surprised to find an empty build result. You must switch to another build script, package.xml, for the purpose of repackaging, see Eclipse help.

    The following steps show how to set up a Pluginbuilder project for repackaging. At the time being Pluginbuilder does not have GUI support for it. However, the existing build scripts can easily be extended. As a realistic example let's create a target platform consisting of the RCP feature plus a subset of the Platform feature named org.my.platformupdate which enables the update manager in your RCP application.

    1. Create a feature project for org.my.platformupdate, open the Feature Manifest Editor and add the following plugins
      Definition of org.my.platformupdate
    2. Create a new Pluginbuilder project and add org.my.platformupdate to the features you want to build. As mentioned above, this will result in an empty build result which will later be used for the repackaging
      Add Feature in Pluginbuilder editor
    3. Add the following targets to the build.xml file in your Pluginbuilder project
      <target name="-preparePackaging">
      <!-- copy the rcp and platform feature to the packaging input dir -->
      <unzip dest="${buildDirectory}/packaging/temp"
      src="C:/downloads/eclipse-SDK-3.4.1-win32.zip"/>
      <!-- without this directory the generated packaging script fails -->
      <mkdir dir="${buildDirectory}/packaging/temp/win32.win32.x86/eclipse"/>
      <unzip dest="${buildDirectory}/packaging/temp">
      <fileset dir="${buildDirectory}/results"
      includes="org.my.platformupdate**"/>
      </unzip>
      </target>

      <target name="package" depends="-properties,-prepare.build.host,-preparePackaging">
      <java classname="org.eclipse.equinox.launcher.Main" fork="true"
      failonerror="true" errorproperty="build.stderr">
      <arg value="-ws" />
      <arg value="${ws}" />
      <arg value="-os" />
      <arg value="${os}" />
      <arg value="-application" />
      <arg value="org.eclipse.ant.core.antRunner" />
      <arg value="-buildfile" />
      <arg value="${scriptdir}/package.xml" />
      <arg value="main" />
      <arg value="-data" />
      <arg value="${buildDirectory}/workspace" />
      <arg value="${verboseAnt}"/>
      <jvmarg value="-Dbasews=${ws}" />
      <jvmarg value="-Dbaseos=${os}" />
      <jvmarg value="-Dbasearch=${arch}" />
      <jvmarg value="-DbuildDirectory=${buildDirectory}"/>
      <jvmarg value="-DbuildResultsDirectory=${buildDirectory}/results"/>
      <jvmarg value="-DeclipseDir=${eclipseDir}"/>
      <jvmarg value="-DbuildHome=${buildHome}"/>
      <jvmarg value="-DbuildId=${version.full}" />
      <jvmarg value="-DpackagingInfo=${buildHome}/packager" />
      <classpath>
      <pathelement location="${equinoxjar}" />
      </classpath>
      </java>
      </target>

      <target name="buildAndPackage">
      <antcall target="main"/>
      <antcall target="package"/>
      </target>
    4. Create a folder named package at the root of the project and copy the packaging template files from ${eclipseDir}/plugins/org.eclipse.pde.build_<version>. Modify them as follows:

      packager.properties

      #The directory used as a base for the all process
      baseDirectory = ${buildDirectory}/packaging

      # A comma separated list of feature ids that will be part of the archive.
      featureList = org.eclipse.rcp, org.my.platformupdate

      # The list of {os, ws, arch} configurations to build. This
      # value is a '&' separated list of ',' separate triples.
      # By default the value is *,*,* which is platform independant
      config = win32, win32, x86

      packaging.properties

      root=
      root.win32.win32.x86=

      customTargets.xml

       <target name="init">
      <property name="archiveNamePrefix" value="targetPlatform-${buildId}"/>
      </target>
    5. Run the buildAndPackage target. After it has finished the target platform can be found at ${buildDirectory}/packaging/workingPlace/I<version>/targetPlatform-<version>.zip.
    No comments

    Add comment

    *
    (will not be published)


    *
    Notify me when a new comment is added.