Friday, September 24, 2010

The simple RCP product build

A question came up the other day on the difference between building small RCP apps pre-3.5 with the delta pack, and what to do in the new p2 world. So I did what everybody wishes they could do ... I cornered Andrew Niefer and asked him a few questions.

I created the standard RCP mail app and then a feature to contain it. The I created a .product file that includes the RCP mail feature and org.eclipse.rcp (a few more plugins than the mail app technically needs, but a good starting point). The .product also had some branding information/splash information in it.

I want to use a product build, as I'm building a product. If you're going to be creating your runnable repo from p2 repos, you don't set baseLocation any more. You care about 2 different properties:
  • repoBaseLocation - a directory where you can mirror your p2 repos, or at least the pieces you need.  You can create multiple repo directories under this location
  • transformedRepoLocation - PDE Build will take your repoBaseLocation and convert it to a runnable repo (to be consumed by the build)
Out of the regular build properties, this looks like:


You also need to set the location(s) of the repos you will consume, and provide a product file:


There are other options that need to be filled in the file, but that's left as an exercise to the reader. The next step is to set up your customTargets.xml. Because I assume the defaults for most everything, I don't have to copy out the template any more. For the p2 part of this exercise, just provide a preProcessRepos target

<project name="RCP Mail customTargets overrides" >
        <import file="${eclipse.pdebuild.templates}/headless-build/customTargets.xml" />

        <target name="preProcessRepos">
                <p2.mirror source="${eclipsePlatformRepo}" destination="${repoBaseLocation}/launchers">
                        <iu id="" version=""/>
                        <iu id="" version="" />

        <target name="postFetch">
                <replace file="${buildDirectory}/" token="HEAD" value="${timestamp}" />
</project> will mirror everthing you need for the org.eclipse.rcp feature, including the different platform fragments. will mirror the features that a product build can use to create your specific executables (rebranded or renamed, etc). PDE build will run the p2.repo2runnable step for you automatically.

Now you just need to run it:

eclipse/eclipse -application org.eclipse.ant.core.antRunner \
 -buildfile eclipse/plugins/org.eclipse.pde.build_3.6.0.v20100603/scripts/productBuild/productBuild.xml \
 -Dbuilder=/opt/local/rcp/builder  \
 -Dbase=/opt/local/rcp/base \

This generate 4 zips (the platforms from my configs= property) although the names were a little odd, they were complete product zips for each platform.

Thank you to Andrew for the examples and tips I used to set this up.