Creating an Eclipse RCP target platform
September 1st, 2009 | Published in Rich Client Platform, Tips, eclipse | 10 Comments
The PDE team has given RCP developers some great new features in Eclipse 3.5. It’s now much easier to create and manage target platforms for Eclipse RCP applications. In this post, I’ll outline one simple workflow that should work in most cases.
But first, if you’re interested in what a target platform is or why you might want to create one, check out these previous posts.
So now that you understand why we should create a target platform, what’s the best way to do it?
Create a target definition file
Eclipse target platforms can be created and selected directly in the Target Platform preferences page, but a better approach is to define your target platform using a target definition file. A target definition file outlines what should be included in your target platform and where the features and bundles can be located. More importantly, target definition files can be checked in to your version control repository and shared among the members of your team.
So how do we create one? You see here a sample RCP application that was generated with the Hello World template. Let’s add a target definition to this project.

Right-click on the project name and select New > Other. Then choose Plug-in Development > Target Definition in the wizard selection dialog.

The wizard page prompts you to select a file name, and I’m going to choose samplercp.target to match my project name. Remember, it’s a good idea to have a separate target platform for each project you work on.
Define your target platform
Now that we have a target definition file in our project, we can select what to include in our target platform. We do that by identifying one or more locations that may contain features or bundles. Eclipse 3.5 supports four types of locations (directories, installations, features, and software sites).
In this workflow, I’ll be using a software site which means that the features and bundles will be downloaded from a repository and stored locally under my workspace .metadata folder.
For an RCP application, we typically want to set our target platform to the Eclipse RCP SDK which is made up of two features:
org.eclipse.rcporg.eclipse.rcp.source
Let’s add these features to our target platform. Start by clicking Add in the Target Definition Editor (this editor should have opened automatically after you created the target definition file). Then select Software Site on the Add Content dialog and click Next.

The next page of the wizard is where the real work is done. We’re going to specify a repository location where the Eclipse RCP SDK can be retrieved.
- First, select the Galileo repository from the Work with drop-down.
- Next, deselect the Group by Category checkbox. For some reason, the Eclipse RCP SDK does not appear anywhere in the category listing. You would think it would be included under the EclipseRT Target Platform Components category, but no such luck.
- Finally, place a check next to the Eclipse RCP SDK entry in the list and click Finish

As soon as you click finish, Eclipse PDE will start the process of downloading the RCP SDK to your machine. Your target definition file should look like this:

Activate your new target platform
The final step is to activate your target platform by clicking the Set as Target Platform link in the upper-right corner of the Target Definition Editor. Then you’re all set! And make sure to check in your target definition so everyone on your team can share the fruits of your hard work ;-)



Patrick on the RCP Panel at EclipseCon
September 2nd, 2009 at 2:22 am (#)
Hi Patrick,
These target platforms are a very useful feature indeed. Thanks for the hint to the target file, now I also know how this setup can be easily shared among the team members :-)
There is just one thing I ask myself: What is the best way to keep this target platform definition and my RCP product definition in sync? In the .product file you also list all features/plugins that make up your application (e.g. org.eclipse.rcp) and thus this information is very close to the content of the target file.
What is your suggestion to deal with this?
Cheers,
Kai
September 2nd, 2009 at 10:03 am (#)
Hi Kai,
I agree that it would be nice to specify dependency information in one place and reuse it for development and builds. Maybe some day we’ll get to a Maven-like dependency approach. Also, it should be noted that currently a product definition is a concatenation of target platform and workspace resources, so it’s not a one-to-one mapping.
Currently, there’s no way that I’m aware of to avoid duplicating the information. I highly suggest basing product definitions on features instead of bundles, which makes a definition simpler and easier to maintain.
Regards,
— Patrick
September 2nd, 2009 at 2:57 pm (#)
Hi Patrick,
thanks for this useful hint!
Martin
September 3rd, 2009 at 2:25 am (#)
Hi Patrick,
Thanks for your answer – at least I now know that I didn’t miss anything important ;-)
I very much agree that products should be specified using features; the only drawback which I see with this is that your RCP app becomes more bloated than it is necessary (as many features also contain plugins that you normally would not want to add). Still, trying to maintain the complete list of plugins is a real nightmare, so I opted for the features :-)
Kai
September 3rd, 2009 at 3:30 pm (#)
hi patrick,
Is there a guarantee that the Target Platform will be hosted by Eclipse.
e.g.: i develop a rcp-application
in 5 years i have to implement some new features. will i be able to build my application against the target definition pointing to the eclipse galileo update site?
if not, what would you suggest instead?
at our company we are allready using a target platform. we just used all the plugins from the ganymede release for 3.4 target platform. but it’s huge and there are lots of unneeded plugins in it. i’ve tried to minimize it, but from a certain point i was able to build our applications, but unable to launch them. and the error message didn’t tell me what.
alex
September 3rd, 2009 at 4:05 pm (#)
Hi Alex,
That would be a good question to ask the Eclipse Foundation, but I doubt if they would provide a guarantee. I was talking to Jeff McAffer at EclipseCon about this issue and he suggested Yoxos as a solution. This is really the same problem as depending on a Maven repository for builds, but they have a longer track record of supporting this type of thing.
In my work, I do not yet use update sites for build targets, only for development. I usually construct build targets locally and then archive them along with my source code.
— Patrick
September 18th, 2009 at 12:16 am (#)
Hi Patrick,
one little remark I have realized when playing around with target platform …
As long as I only have my RCP application in my Eclipse workspace everything is OK. But as soon as I want to add some junit test to my code the target platform in not sufficient any more. If I want to run pure java unit test as well as plugin junit tests I need to expand the target platform further. I ended up using the at least the EclipseSDK package as target platform, in order to work as usual!
Nevertheless, I still think that the concept of target platform is very valuable.
What are your experience in this area? Any possibilities I have missed?
Regards
Paul
September 18th, 2009 at 11:47 am (#)
Hi Paul,
Yes, you will almost always need to add other bundles to your target platform. JUnit is a common one, third party libraries will need to be added as well.
You can structure these additions in various ways. For some, you may want to create a directory and place the bundles there. For others (JUnit for example), you may want to point at an installation and select the bundles you need.
One thing to be careful of is to add only the bundles you really need. Adding the EclipseSDK to your target platform is usually unnecessary. Remember that you don’t have to limit a target platform to features, it can contain individual bundles as well. You’ll want to create your own features to contain those bundles. For example, you may want to create a com.mycompany.myproduct.test feature to reference your JUnit bundle.
Regards,
— Patrick
December 9th, 2009 at 10:43 am (#)
Hi,
how do I get the target platform and a product definition linked together?
Martin
December 9th, 2009 at 4:42 pm (#)
HI Martin,
There’s no way I know of to link target platforms and product definitions. The target platform specifies all of the bundles which *may* become part of your product. The product definition specifies the bundles that *are* part of your product.
I agree that there is some redundancy here and it would be nice if you could simply specify things once.
— Patrick