Home Tutorials Training Consulting Products Books Company Donate Contact us


Get more...

Training Events

Eclipse Target Platform. Via a target platform you define which set of plug-ins and what version of Eclipse you develop against. This tutorial describes how to setup your target platform for Eclipse Plug-in and RCP development.

1. Configuring the available libraries via a target platform

Eclipse utilizes target definitions to specify the available Java libraries for Eclipse development. The active target definition is referred to as the "target platform."

The target platform determines the libraries against which your code is built and run. These libraries complement the plug-in projects in your workspace.

If no explicit target definition is set, the Eclipse IDE serves as the target platform. However, it is advisable to employ a target definition file to eliminate this IDE dependency. Typically, a target definition file is shared among developers, ensuring uniform library usage for development purposes.

1.1. Creating a target platform

The definition of a target platform is demonstrated in detail in the a later exercises.

A target definition file can be created via the File  New  Other…​  Plug-in Development  Target Definition menu.

You can add new libraries via the Add…​ button in the Locations section. You can add:

  • Software Sites which are a Eclipse technology also known as update sites

  • Directories

  • Installation

  • Features

  • Target Files which allows you to split your target files into smaller units

  • Maven which allows you to use standard Java libraries from a Maven repository

The following is a example of a target definition file:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?pde version="3.8"?>
<target name="target-platform">
    <locations>
        <location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="true" type="InstallableUnit">
            <repository location="https://download.eclipse.org/releases/latest"/>
            <unit id="org.eclipse.equinox.compendium.sdk.feature.group" version="0.0.0"/>
            <unit id="org.eclipse.equinox.core.feature.feature.group" version="0.0.0"/>
        </location>
    </locations>
</target>

The includeMode property defines how dependencies should be handled:

  • planner = include dependencies

  • slicer don’t include dependencies

1.2. Example for adding content to the target platform

A convenient way of working with the target platform is to work directly in the text file, as this offers code complete on id and versions.

However the user interface is a nice way of creating a first version of the target file. To add content to a target definition file via the user interface, open your target definition file is in the Target Definition editor and press the Add…​ button.

Add content to target definition file

Select Software site in the following dialog.

Add content to target definition file
The Maven entry may be missing in your current installation, for this exercise this entry is not necessary.

Press the Next button and enter the URL to the Eclipse update sites in the Work with selection box. For example, one of the following

https://download.eclipse.org/releases/latest
https://download.eclipse.org/releases/2021-03
https://download.eclipse.org/releases/2021-12

The /latest points points to the latest release and therefore changes it content once a new release is out. The /2021-03 and /2021-12 update sites point to a specific release with pre-defined content.

Not all feature and plug-ins are grouped. To see all entries remove the Group by Category flag.

Remove Group by

Save the target definition file after such changes.

1.3. Using a target platform

You can activate and switch the target platform in the Eclipse Preferences. Select Window  Preferences  Plug-in Development  Target Platform. It is also possible to active a target platform via its editor via the Set as Active Target Platform link on the first page.

1.4. Version dependencies

If you wish not to specify a fixed version for a bundle in your target platform, you can set the version number to 0.0.0.. This serves as a placeholder, indicating that the system should use any available version.

For instance, when using an update site that provides the latest version, using 0.0.0.. as version number allows your target platform to select the most recent version of your plug-ins.

To do this, go to the _Source; tab in the target platform editor and replace all library version numbers with 0.0.0. This ensures you always utilize the latest version available from your update site.

2. Exercise: Creating a target platform definition file

In this exercise, you create a target definition file to define the libraries available for your Eclipse development.

2.1. Create a project of type general

Create a new project named target-platform of type General via the File  New  Other…​  General  Project menu path.

targetdefinitionproject10
targetdefinitionproject20

2.2. Create a target definition file

Create a new target definition file via the File  New  Other…​  Plug-in Development  Target Definition menu path.

Wizard path for target file

Use target-platform as file name and press the Finish button.

Define target definition file

This creates a new file and opens the Target Definition editor.

2.3. Setting up a target platform for RCP or OSGi development

The following describes the definition of two target platforms. One for Eclipse IDE / RCP development and the other one for OSGi development.

3. Exercise: Setting up a target platform for Eclipse based application development

In this exercise, you add standard Eclipse libraries to your target definition.

Ensure you target definition file is open in the Target Definition editor. Switch to the Source tab of the editor. Copy and paste the following text into the file:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?pde version="3.8"?>
<target name="target-platform">
 <locations>
  <location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="true" type="InstallableUnit">
   <repository location="https://download.eclipse.org/releases/2023-09"/>
   <unit id="org.eclipse.equinox.sdk.feature.group" version="0.0.0"/>
   <unit id="org.eclipse.platform.sdk" version="0.0.0"/>
  </location>
 </locations>
</target>
https://download.eclipse.org/releases/latest or https://download.eclipse.org/releases/2023-12 has changed some of its imports and available features. This text is currently still based on 2023-09 and will be updated shortly.

You repository location points to an Eclipse update site which contains the Java libraries from Eclipse you can use. You will later extend this to include standard Java libraries using Maven repositories.

You can use the following URL to compile against the latest release.

Or you can compile against another release:

Please note that the usage of other update sites, may require changes in the exercises.

The versions have manually set to 0.0.0 via the text which mean "any version". This allows you to change the URL to another release without without having to update the individual versions.

3.1. Add option to use NatTable in your code

NatTable is an advanced framework for building tables and trees. We want to be able to use NatTable in our development environment. Therefore, modify your target platform.

Open the target definition file in the target definition editor and add the following entries.

Table 1. Update sites for the target definition
Name URL

NatTable update site

https://download.eclipse.org/nattable/releases/1.6.0/repository/

vogella sample data model

https://dl.bintray.com/vogellacompany/codeexamples-javadatamodel/updatesite/1.4.0/

The data model is of course not necessary for the usage of Nattable but will give us a simple data model to use NatTable.

The following features of the update sites above should be added to the target definition file.

target platform nattable

Ensure you activate this target definition by clicking on the Set as Target Platform link in the target definition editor.

A target platform file which supports NatTable should therefore have at least the following entries, you may have more entries.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?pde version="3.8"?>
<target name="target-platform">
 <locations>
  <location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="true" type="InstallableUnit">
   <repository location="https://download.eclipse.org/releases/latest"/>
   <unit id="org.eclipse.equinox.executable.feature.group" version="0.0.0"/>
   <unit id="org.eclipse.sdk.feature.group" version="0.0.0"/>
  </location>
  <location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="true" type="InstallableUnit">
   <repository location="https://download.eclipse.org/nattable/releases/1.6.0/repository/"/>
   <unit id="org.eclipse.nebula.widgets.nattable.core.feature.feature.group" version="0.0.0"/>
   <unit id="org.eclipse.nebula.widgets.nattable.core.source.feature.feature.group" version="0.0.0"/>
   <unit id="org.eclipse.nebula.widgets.nattable.extension.e4.feature.feature.group" version="0.0.0"/>
   <unit id="org.eclipse.nebula.widgets.nattable.extension.e4.source.feature.feature.group" version="0.0.0"/>
   <unit id="org.eclipse.nebula.widgets.nattable.extension.glazedlists.feature.feature.group" version="0.0.0"/>
   <unit id="org.eclipse.nebula.widgets.nattable.extension.glazedlists.source.feature.feature.group" version="0.0.0"/>
   <unit id="org.eclipse.nebula.widgets.nattable.extension.nebula.feature.feature.group" version="0.0.0"/>
   <unit id="org.eclipse.nebula.widgets.nattable.extension.nebula.source.feature.feature.group" version="0.0.0"/>
   <unit id="org.eclipse.nebula.widgets.nattable.extension.poi.feature.feature.group" version="0.0.0"/>
   <unit id="org.eclipse.nebula.widgets.nattable.extension.poi.source.feature.feature.group" version="0.0.0"/>
  </location>
  <location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="true" type="InstallableUnit">
   <repository location="https://dl.bintray.com/vogellacompany/codeexamples-javadatamodel/updatesite/1.4.0/"/>
   <unit id="com.vogella.model.feature.feature.group" version="0.0.0"/>
   <unit id="com.vogella.model.feature.source.feature.group" version="0.0.0"/>
  </location>
 </locations>
</target>

4. Exercise: Setting up a target platform for OSGi development

In this exercise you create a target definition which can be used to develop OSGi based command line applications.

4.1. Add content for OSGi development

Press the Add…​ button.

Add content to target definition file

Select Software site in the following dialog.

Depending on your installation, you may see different entries in the dialog, e.g. you may see an additional entry named Maven.

Add content to target definition file

Press the Next button and enter the following URL in the Work with selection box.

https://download.eclipse.org/releases/latest

https://download.eclipse.org/releases/latest points to the latest Eclipse release, you can also select a specific release to build against.

Remove the Group by Category flag and add the following components:

Table 2. Target components
Component Description

Equinox Compendium SDK

Additional OSGi services

Equinox Core Function

Basis runtime and functionality of OSGi

Remove Group by

Save the target definition file.

4.2. Example solution for the target platform

If you check the content of the target platform via the Source tab, it should look similar to the following listing.

Please note that the version number has been set to 0.0.0 in the listing, so that

Show Solution
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?pde version="3.8"?>
<target name="target-platform">
    <locations>
        <location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="true" type="InstallableUnit">
            <repository location="https://download.eclipse.org/releases/latest"/>
            <unit id="org.eclipse.equinox.compendium.sdk.feature.group" version="0.0.0"/>
            <unit id="org.eclipse.equinox.core.feature.feature.group" version="0.0.0"/>
        </location>
    </locations>
</target>

5. Use the target definition file

Save the target definition file and switch in the editor to the Definition tab. The IDE validates the definition (resolves it) and downloads the defined libraries.

Avoid using the Eclipse IDE until the target is resolved. Resolving targets is using the network and you do not want to interrupt this, as this might result in an inconsistent target definition.

After the target is resolved, press the Set as Active Target Platform to activate it. Please note that your version numbers might be different from the versions in the screenshot.

tutorial targetdefinition40

6. Solving potential issues with your target definition

Your target platform depends on external update sites and the availability of the network. Theses update sites might change over time, so you should be able to revert your target platform settings in case you face issues.

If you face issues with your target platform, switch to the IDE as target platform and afterwards switch back to your target definition.

That sometimes solves target resolution issues.

If the target definition does not work, e.g. because of network issues, you can use your Eclipse IDE as target platform via Window  Preferences  Plug-in Development  Target Platform.

tutorial targetdefinition60

7. Optional exercise: Mirroring p2 update

To avoid long running network operations to server outside of the own network, you can mirror p2 update sites.

Mirroing with Tycho p2 explains how to mirror an update site with Maven.

One way is to use Eclipse to mirror a update site, for this you need to mirror the metadata and the artifacts.

The following is an example for Windows, which mirrors the latest update site to C:\Users\Lars\mirror.

Mirroring on Windows
./eclipsec -nosplash -verbose -application org.eclipse.equinox.p2.metadata.repository.mirrorApplication -source https://download.eclipse.org/releases/latest -destination C:\Users\Lars\mirror

./eclipsec -nosplash -verbose -application org.eclipse.equinox.p2.artifact.repository.mirrorApplication -source https://download.eclipse.org/releases/latest -destination C:\Users\Lars\mirror
Mirroring on Linux or Mac
./eclipse -nosplash -verbose -application org.eclipse.equinox.p2.metadata.repository.mirrorApplication -source https://download.eclipse.org/releases/latest -destination ~/mirror

./eclipse -nosplash -verbose -application org.eclipse.equinox.p2.artifact.repository.mirrorApplication -source https://download.eclipse.org/releases/latest -destination ~/mirror

This mirroring can run very, very long. But it still can be useful to do this, as you could upload the mirrored artifacts on a server in your network. This will make the target definition resolution most likely faster for your developers.

After a successful run, you can change your target platform for the platform features to point to the mirrored p2 update site.

8. Learn more and get support

This tutorial continues on Eclipse RCP online training or Eclipse IDE extensions with lots of video material, additional exercises and much more content.

9. Target platform resources

Legal Privacy Policy Change consent