Materializing and Provisioning your Target Platform as local p2 site with Buckminster

This post was inspired by another blog post I had found on the web when trying to build a p2 site corresponding to a target platform defined for my projects. For an year I’ve been using Buckminster for building my Eclipse projects (especially when I had problems building my Xtext projects with Maven/Tycho, so that I decided to switch to Buckminster).

Having a p2 site for the current platform has some advantages, I guess:

  • Building RCP products will be easier (Buckminster relies on p2 directory, and all the bundles for building the product will be searched for in p2 sites);
  • It represents a (local) mirror for the target platform (for easier access).

In this post/tutorial I’ll describe my experiences

  • Define a target platform with Buckminster mechanisms (CSPEC, CQUERY and RMAP) instead of relying on target definitions with Eclipse Target Editor;
  • Build a p2 site with the contents of the so defined target platform.

In this tutorial we will create a target platform consisting of the following features

  • org.eclipse.rcp
  • org.eclipse.rcp.source
  • org.eclipse.emf.sdk
  • org.eclipse.equinox.executable

The code is available at:,

This tutorial will show how to materialize the target platform and build the p2 sites

  • in the IDE,
  • headlessly from the command line through ant, and
  • headlessly in Jenkins.

For the IDE you will need to install Buckminster main features in Eclipse, using the update site

NOTE: sometimes Buckminster’s cache in the IDE becomes stale, and you might experience errors about missing components; you might want to restart Eclipse and usually this makes the problem go away.

Why not the Target Editor?

I experienced many problems when using Eclipse Target Editor (based on p2 sites); I found it quite unreliable, especially for modifying a target definition, for updating a target definition (the Update button works 1 time out of 10); moreover, it takes some time for the target to be resolved (every time you reopen a target definition with the editor).

Furthermore, when you define a target for building RCP products, then you usually want to be able to build for several platforms, not only the current one; in these cases you have a checkbox to select (“Include all environments“):

But in that case, you must give up on “Include required software”, and this might get you into troubles about missing bundles, when building your product, if it needs to include more involved features (besides the standard “Eclipse RCP SDK” and “Eclipse Platform Launcher Executables”); for instance, if your product needs also EMF Eclipse Modeling Framework SDK (which is required when using Eclipse RCP 4.2).

Defining a target platform the “Buckminster way” does not have this limitation (and, honestly, once you get familiar with that, it’s much faster than using the target editor).

Defining a Target Platform with Buckminster

Although Buckminster is able to materialize a target platform starting from a standard target definition, it also provides an alternative way:

  1. Define a component which represents all the target features by creating a project and a custom CSPEC; this CSPEC basically declares the target features as dependencies
  2. Define a resource map (RMAP) which tells Buckminster where to find these dependencies; we will use of course official Eclipse p2 site repositories for these dependencies
  3. Define a component query (CQUERY) which materializes the component representing the target platform

In our example, this project is called (it is a generic project without any nature). This is the project where we will define all Buckminster files (CSPEC, CQUERY and RMAP). In this project we define the component specification: buckminster.cspec

Here we use the name of the features for our target platform. (NOTE: org.eclipse.rcp and org.eclipse.rcp.source, together, correspond to Eclipse RCP SDK.)

The rmap (which we call target-platform.rmap) is defined as follows:

In our case we use the two main Eclipse p2 repositories (if the features you need are available from other p2 repositories, you will need to provide p2 reader types for these repositories as well). We will not use regular expressions for specifying the source p2 repositories, since there are no ambiguities in this example; instead, we simply specify the locators in the order we desire (preferring juno release site to juno updates). Note that we also have a search path for local sources. This is useful for building headlessly, so that Buckminster is able to find, resolve and bind to the workspace our own projects.

Finally, the component query (which we call target-platform.cquery) is defined as

Thus we request the component corresponding to our project Note that we specify that we are not interested in any specific architecture, so that we will have a target platform for all platforms/environments/architectures. Note also that in the cquery we reference the above defined rmap.

Materializing the Target Platform

We can now materialize the target platform so defined by opening the target-platform.cquery with Buckminster corresponding editor:

WAIT: If you pressed the “Resolve and Materialize” now, Buckminster would materialize the target platform in the directory tp of a hidden project in your workspace (.buckminster). Moreover, by default, the created target platform is based on the configuration of the currently running Eclipse instance. If you want to start from a plain and empty platform (just like you do with a standard target definition with the target editor), there are a few more steps to perform:

  1. Create an empty target platform manually that contains one single and empty directory.
  2. Set this target platform active.
  3. A subsequent resolution/materialization will use that platform.

You can specify any directory of your filesystem, in any case, make sure the directory you choose already exists.

One possible way of doing this, as illustrated also here, is

  1. Create a new general project named TP (or some name of your preference) in the workspace
  2. In “Window” => “Preferences” => “Plug-in Development” => “Target Platform”
    Select Add…
  3. Start with an empty target definition
  4. Enter TP in the Name: field (or some name of your preference)
  5. Add a directory
  6. Click on “Variables…” scroll down and select “workspace_loc” and then type TP in the Argument: field

This procedure is shown by the following screenshots.

NOTE: these additional steps are not required when building headlessly

Once you pressed Finish and set this new target as the active target platform, you’re ready to materialize the cquery from the cquery editor. Of course, it might take some time for downloading all the features. Once the materialization is finished, if you followed the above procedure and created a general project TP in your workspace, you can see the materialized target platform

Create a feature for the p2 site for your target platform

Once the target platform is resolved (you can also have a look at the current new target platform from the Eclipse preferences), we are ready to create a feature that we use to create the p2 site corresponding to our target platform.

We thus create a new feature project, that we call, and we initialize it with all the bundles (plugins and fragments) of the current target platform (if you have other bundle projects in your workspace, make sure to unselect such additional workspace projects)

Before creating the p2 site, you may want to create a (e.g., in the main project where we set some properties for Buckminster (e.g., that we want to build a site for all environments, and that we want the site to be created in a specific folder, in this example /tmp/bucky):

We are now ready to build a p2 site for this feature with Buckminster:

  1. right click on the project
  2. select Buckminster -> Invoke Action…
  3. select the action site.p2 (and, additionally, select the file above)

If you used the same property file, you can find the site.p2 in /tmp/bucky/build/ .

The p2 site you’ve just created could already be used, for instance, for building your RCP product with Buckminster through the p2 director. However, as it is, it contains only bundles, no (installable) features, thus it cannot be used, for instance, as a mirror for your target platform… see the next section

Create a feature for the p2 MIRROR site for your target platform

We create a new feature project, and, as before, we initialize it with all the bundles (plugins and fragments) of the current target platform (if you have other bundle projects in your workspace, make sure to unselect such additional workspace projects); but this time, once the feature project is created, we also add to the feature.xml all the features that we used to create our target platform:

Let’s run the action site.p2 (using the same file) on this new feature project. This time, we will end up with a p2 site with all the installable features of our target platform! You can verify this by using the Eclipse install new features menu and using as repository the one just created (if you used the same output directory it will be located at /tmp/bucky/build/

Even more, you might create a target definition file, open it with the Eclipse target editor, and create a target definition using your local mirror!

Headless execution from the command line

If you want to materialize the target platform and build the p2 site from the command line, you need to install the headless version of Buckminster.

For instance, you download the director from and then you run the director as follows

Headlessly, we will need to

  1. resolve the cquery for the target platform (that we already showed above);
  2. resolve the cquery for the site feature, (in this case, it is the one for the mirror site), mirror-project.cquery:

    Note we reuse the same rmap we saw before. This way, during the materialization of the mirror site feature, possible additional dependencies will be resolved by Buckminster and added to the target platform;
  3. perform the site.p2 action (before we also perform a buckminster.clean) on the component of the mirror site

We then write an ANT file, build.ant, in the project, as follows (this was inspired by the one generated by the Xtext wizard, developed by Dennis HübnerI’ve blogged about that, and from the one that can be found here):

You will need to run ant passing this file and also specifying the path where your headless Buckminster is installed, in my case I run

This ant script runs Buckminster twice:

  1. The first time it runs the materialization commands (stored in the file
  2. Then it runs the actual commands to build the p2 site (stored in the file; in this case we only build the p2 site for the mirror feature

You need to execute Buckminster twice because of some conflicting bundles (see the discussion here) which cause problems if you attempt to run everything in one shot; if you did not separate the steps, you would get something like

Once the script is finished you will get the p2 site in the subdirectory buildroot/buckminster.output/*-eclipse.feature/site.p2.

Headless execution in Jenkins

The last task is to build headlessly in Jenkins; of course, this assumes you have a working Jenkins installation with the Buckminster plugin (I’ve blogged about that also).

We write the commands to execute in two text files (similar to the ones shown in the previous section):


Then we can create a Jenkins job, which fetches the sources from the git repository

specify two Buckminster execution steps (as noted in the previous section, this is mandatory for the whole process to succeed):

and archive the artifacts

When the job finishes, you can see the archived p2 site

That’s all…

I hope you enjoyed this post, and comments are more than welcome 🙂

12 thoughts on “Materializing and Provisioning your Target Platform as local p2 site with Buckminster

    1. Lorenzo Bettini Post author

      Hi Vlad, glad you liked it 🙂
      usually for non-RCP stuff it is easier: you do not need the executable features and the site.p2 usually is not architecture dependent… so I would say, no, there should be no difference… are you experiencing problems in your context?

      1. Vlad

        No, I don’t have any problems directly, but I got it working in an ad-hoc fashion for a year or so ago and since then didn’t dared to change anything for fear that it will start misbehaving. I’m using a static target platform, manually installed, and I would like very much to automate that. Hopefully I can get it to work with the walkthrough above.

  1. Pingback: Building Xtext projects with Buckminster | Lorenzo Bettini

  2. Pingback: Mirror Eclipse repositories with p2.mirror Ant task | Lorenzo Bettini

  3. Pingback: Building an Eclipse RCP Product with Buckminster | Lorenzo Bettini

  4. Boris Brodski

    Thank you for the great tutorial!

    In general I share your opinion on the “Target Editor”, but I found a way to make it do it’s job.

    – open .target file with the eclipse text editor
    – change, what you want to change
    – increase “sequenceNumber” in the “target” tag
    – save the file

    Eclipse automatically resolves new target platform.

    If I what to add new features, I add those in the “Target Editor” itself, inspects changes (diff) and then
    reapply changes manually using the method described above.

    1. Lorenzo Bettini Post author

      Hi Boris
      I’m basically doing the same procedure when I use a .target definition file… but it’s a kind of shame that the UI tooling about target definition files is so poor that it’s mostly unusable 🙂

  5. Felix Dorner

    Ciao Lorenzo, thank you for this. I just wanted to comment on something that might be completely obvious, but I had to think about it for a while:

    I tested your example with a single dependency to the org.eclipse.sdk feature. I went through the whole process and created a p2 mirror repository including the org.eclipse.sdk and all target plugins. I then added this local repo as a “Software Site” in a new .target definition and duh! org.eclipse.emf.ecore cannot be found! So there is a little gotcha:

    The EMF features are well present in the TP directory that was initially materialized by buckminster, but only adding the org.eclipse.sdk feature to the site-mirror-feature will not automatically include the emf features, since they are not included, but rather listed a dependency in the org.eclipse.e4.rcp feature. So if you want a fully self-contained mirror you would need to know about these feature dependencies and add them manually to the site-mirror feature, right?

    1. Lorenzo Bettini Post author

      Hi Felix

      The problem is that when p2 creates an update site it does not automatically drag in all the dependencies of the features, so you won’t get EMF features in the update site.

      This post is pretty old, and I strongly suggest NOT to use this technique to generate a mirror: you should use Eclipse b3, which is really cool, it comes with a nice editor, and it creates a real mirror (by the way, before creating the mirror it also checks whether dependencies are satisfied, so when the mirror is finally created you can be sure that it contains all you need).

  6. Pingback: Mirror Eclipse repositories with p2.mirror Ant task | Lorenzo Bettini

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.