Author Archives: Lorenzo Bettini

About Lorenzo Bettini

Lorenzo Bettini is an Associate Professor in Computer Science at the Dipartimento di Statistica, Informatica, Applicazioni "Giuseppe Parenti", Università di Firenze, Italy. Previously, he was a researcher in Computer Science at Dipartimento di Informatica, Università di Torino, Italy. He has a Masters Degree summa cum laude in Computer Science (Università di Firenze) and a PhD in "Logics and Theoretical Computer Science" (Università di Siena). His research interests cover design, theory, and the implementation of statically typed programming languages and Domain Specific Languages. He is also the author of about 90 research papers published in international conferences and international journals.

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: https://github.com/LorenzoBettini/Target_to_p2_with_Buckminster,

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 http://download.eclipse.org/tools/buckminster/updates-4.2.

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 bucky.example.rcpemf.target (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 bucky.example.rcpemf.target. 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 bucky.example.rcpemf.target.site, 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 buckminster.properties (e.g., in the main project bucky.example.rcpemf.target) 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 bucky.example.rcpemf.target.site project
  2. select Buckminster -> Invoke Action…
  3. select the action site.p2 (and, additionally, select the buckminster.properties file above)


If you used the same property file, you can find the site.p2 in /tmp/bucky/build/bucky.example.rcpemf.target.site_1.0.0-eclipse.feature/site.p2/ .

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 bucky.example.rcpemf.target.mirror.site, 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 buckminster.properties 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/bucky.example.rcpemf.target.mirror.site_1.0.0-eclipse.feature/site.p2/).

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 http://www.eclipse.org/buckminster/downloads.html 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 bucky.example.rcpemf.target, 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 bucky.example.rcpemf.target/headless-resolve-commands.txt)
  2. Then it runs the actual commands to build the p2 site (stored in the file bucky.example.rcpemf.target/headless-perform-commands.txt); 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/bucky.example.rcpemf.target.mirror.site_*-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):

  • bucky.example.rcpemf.target/jenkins-resolve-mirror-commands.txt
  • bucky.example.rcpemf.target.mirror.site/jenkins-perform-commands.txt

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 🙂

Accessing your remote Ubuntu machine with VNC and ssh

If you want to access your remote Ubuntu machine with VNC, in particular by tunnelling through ssh, there is already some documentation which can be found here. However, at least for me, the procedure explained there does not work out of the box. So here’s what I had to do to make it work.

First of all you need to install in the machines the following packages:

  • remote machine: xvfb x11vnc openssh-server
  • local machine: xtightvncviewer openssh-client

Then, the script to run on your client machine to access the server has to be slightly modified as follows

where you will have to replace USER with your user on the remote machine, and REMOTEIP with the address of your remote machine.

Basically, the changes I had to make to the original script were to add the -auth command line option specifying the path to the .Xauthority, and the command line option -create to actually start an instance of the X server on the remote machine.

Using Buckminster Plugin in Jenkins

The bugs described in this post are now fixed (since I became the new maintainer of this plugin 🙂

If you use Buckminster for your builds, and have a personal Jenkins build system, you might want to rely on the Buckminster Plugin, which can be installed directly from Jenkins:

Unfortunately this plugin has some bugs (at least two) which somehow prevent you from using it, especially for new Eclipse versions. But it is quite easy to fix them once you know how; I found the solutions on the web, but I thought I could summarize them here to have them in one place.

First, if you’re not using Internet Explorer, then you’ll not be able to add build steps (which makes the plugin useless 🙂

As documented in the bug report (not yet fixed): you need to edit this file (all paths are intended to be prefixed with your Jenkins path)

plugins/buckminster/WEB-INF/classes/hudson/plugins/buckminster/EclipseBuckminsterBuilder/config.jelly

and “remove the <f:section></f:section> tags which surround the <f:advanced> entries”. This is expressed by this diff with the original file

Then, with the default configuration of the plugin, you won’t be able to install a recent version of Buckminster, thus you need to provide a custom .json (to put in userContent/buckminster/buckminster.json) file to allow new versions of Buckminster to be installed (an older example is found here); this is the json file I use:

Hope this helps 🙂

Back from EclipseCon Europe 2012

I’m really sad that EclipseCon Europe has already finished, it has been a wonderful edition with lots of very interesting presentations!

My favourite ones were:

And last but not least… “be nice to nerds…” 🙂

Installing Eclipse Features via the command line

If you have many eclipse installations (with different features/plugins) and you want to have such installations in several computers (possibly with different operating systems or with different architectures), then being able to install eclipse features from the command line might be quite helpful (at least, it is for me 🙂

You can find some related posts, like Lars Vogel’s or Paul Webster’s. These are just my two cents 🙂

What you need to do is to run eclipse from the command line (if you’re using Windows, you need to run eclipsec.exe, note the final ‘c’, instead of eclipse.exe), with these parameters

Where the repo URLs are just the same as the ones you use as update sites or p2 repositories when installing a feature in Eclipse (you may want to always put the eclipse distribution main update site, e.g., http://download.eclipse.org/releases/juno), while the feature IDs are the actual identifiers of features you want to install; knowing the correct feature ID might not be immediate to discover, if you’re only used to the names you see in the update manager.

For instance, say that you want to install Xtext SDK, from the site http://download.eclipse.org/modeling/tmf/xtext/updates/composite/releases/ , then in Eclipse you would do something like in the following screenshot

but instead of “Xtext SDK“, in the command line, you should specify org.eclipse.xtext.sdk.feature.group. While in this case it was easy to infer the feature ID, but… at least for me, it was not immediate to know that “Eclipse Java EE Developer Tools” feature is indeed org.eclipse.jst.enterprise_ui.feature.feature.group !!! 🙂

Fortunately, you can get to know that by clicking that “More…” link in the above screenshot, which leads you an information dialog where you can easily find the identifier of the selected feature:

Of course you can also have the list of all the contents of an update site, by using the option -list:

For instance, this is the command line I use to install in the Xtext eclipse distribution (http://www.eclipse.org/Xtext/download.html) additional stuff like the Xpand SDK, some Mylyn connectors, SwtBot and EMF CDO:

The final -vmargs are just some additional arguments which you may want to skip.

Hope this helps 🙂

New look!

OK, I’ve been using PmWiki for some years now for my webpage… it was time for a fresh look 🙂

Let’s try WordPress then!

I’ll also take the chance to host my main programming blog on this very site.

Goodbye old home page 🙂