Tuesday, July 20, 2010

Headless Build for Beginners - part III

Automated building an RCP application from a product configuration file

Most of this post contains same info as the eclipse help page with same heading.

Creating a product configuration file is easy. Check the eclipse help page explains it well. Assuming the our product config example.product looks like this and resides in a plug-in com.example.product.




Basic Setup
We will need 3 directory paths
  1. where the features and plug-ins to be build will reside. We will call it buildDirectory.
  2. where the build configuration file (build.properties) will reside. We will call it buildConfiguration.
  3. where the eclipse installation resides. We will call it baseLocation.
Now to prepare these directories
  1. Copy the features and plug-ins in side the buildDirectory. Ideally this will be a source checked out from the version control system. Custom ant tasks can be used to automate that. For this example, the directory shall look like this
  2. <buildDirectory>
           plugins/
                  com.example.helloworld
                  com.example.product
                         example.product
           features/
                  com.example.helloworld.feature


  3. Copy build.properties file from baseLocation/plugins/org.eclipse.pde.build_<version>/templates/headless-build to buildConfiguration folder. This file will configure the build and the output.
  4. Now we need to edit this build.properties file and fill in the parameters
    1. product=C:/build/buildDirectory/plugins/com.example.product/example.product
    2. This entry shall point to the product configuration file. The features/plugins mentioned in this file will only be picked for the build but searched in buildDirectory and baseLocation.
    3. archivePrefix=HelloWorld
    4. The archivePrefix is the name of the Folder under which the product will reside.
    5. configs=win32, win32, x86
    6. The configs shall point to the platforms for which product has to be build. The eclipse mentioned at baseLocation should have RCP Delta Pack. Without the delta pack, the build wont be able to create product for other platforms. Also, when troubleshooting for missing config or launch files, ensure that right version of delta pack is installed.RCP Delta Pack is build along with SDK so the same version shall be used. I am building only for windows that is that the configs entry is for only win32. For building other platforms, uncomment the required platforms. The platforms are delimited using & \.
    7. buildDirectory=C:/build/buildDirectory
    8. This will the buildDirectory we setup above.
    9. buildType=I
    10. I is for Integration build, N for Nightly, M for Milestone, S for ...I dunno. But you got the point.
    11. buildId=ExampleProductBuild
    12. This will name the build archive.
    13. base=C:/
      baseLocation=${base}/eclipse
    14. The base is the location which contains the eclipse installation (with RCP Delta Pack).
Running and understanding output

The build will be invoked as before

java -jar <eclipse-installation-path>\plugins\org.eclipse.equinox.launcher_<version><qualifier>.jar -application org.eclipse.ant.core.antRunner -buildfile <eclipse-installation-path>\plugins\org.eclipse.pde.build_<version><qualifier>\scripts\productBuild\productBuild.xml -Dbuilder=c:\build\buildConfiguration

example

java -jar c:\eclipse\plugins\org.eclipse.equinox.launcher_1.1.0.v20100507.jar -application org.eclipse.ant.core.antRunner -buildfile c:\eclipse\plugins\org.eclipse.pde.build_3.6.0.v20100603\scripts\productBuild\productBuild.xml -Dbuilder=c:\build\buildConfiguration

The output will look like this

I.ExampleProductBuild
│   ExampleProductBuild-win32.win32.x86.zip

└───compilelogs
    └───plugins
        └───com.example.helloworld_1.0.0.201007191243
                @dot.log


The folder I.ExampleProductBuild will contain the build logs and the product build ExampleProductBuild-win32.win32.x86.zip. If we had chosen other configs they too will appear here in separate zip (or whichever format we specify).