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. Using a target platform
1.1. Purpose of the target platform
The set of plug-ins available for your application development is defined by the plug-ins in your workspace in addition to the plug-ins defined by your target platform. For example, the SWT and JFace plug-ins are typically provided by your target platform. By default, the plug-in installed in your Eclipse IDE installation are used as target platform.
It is good practice to develop and build against a explicit target definition which is stored in a configuration file. This way the plug-in dependencies and the used versions are controlled and specified during the development. A target definition file is typically shared between the developers to ensure that everyone is using the same basis for development. If such a target definition file does not exists, than every developer develops against his version of the Eclipse IDE, which can lead to incompatible changes.
You can activate and switch the target platform in the Eclipse Preferences. Select. 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.2. Creating a target platform
The creation of a target platform is demonstrated in detail in the exercise.
You can specify your target platform with a target definition file. A target definition file can be created via.
You can add new locations via the Add… button in the Locations section. To add an Eclipse p2 update site, select Software Site and specify the URL.
|If you create a target platform, wait until the target platform is completely resolved before setting it as target platform.|
All plug-ins you are planning to use in your application and test code must be included in the target definition. For example, if you want to use SWTBot for unit tests, add SWTBot for SWT Testing features from http://download.eclipse.org/technology/swtbot/releases/latest/ to your target platform.
A preferred way of defining your target platform is to use (p2) update sites. These are of the same type as the update sites that you used to install a new set of plug-ins. If the content in the update sites defined by your target platform changes, your local set of plug-ins can be updated.
It is also possible to define your target platform based on plug-ins in your file system. But this is not recommended as popular build systems like Maven/Tycho do not support file based target definition files.
2. Exercise: Setting up a target platform
In this exercise you create a target definition. This target definition is used to compile the Eclipse components in your workspace.
2.1. Create a project of type general
Create a new project called target-platform of type General via.
2.2. Create a target definition file
Create a new target definition file via themenu path.
target-platform as file name and press the Finish button.
This creates a new file and opens the Target Definition editor. Press the Add… button.
Select Software site in the following dialog.
Press the Next button and enter the http://download.eclipse.org/releases/latest URL in the Work with selection box.
Latest points to the latest release, you can also select a specific release to build against.
Remove the Group by Category flag and add the following components:
Eclipse Platform SDK
Components for RCP
Equinox Target Components
The native launchers for the platform
Save the target definition file.
2.3. Use the target definition file
After saving the target definition file, it is resolved which will take a while, you can see the progress via the toolbar of your IDE.
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.
2.4. Remove version dependencies
Select the Source tab in the target platform editor.
As we are building in this exercise against the latest release of Eclipse we want to remove the version numbers. Therefore, replace all numbers with "0.0.0" which is a placeholder for any number.
This way, you will always use the latest available version from your update site.
If you check the content of the target platform, it should look similar to the following.
<?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="http://download.eclipse.org/releases/latest"/> <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>
2.6. Validate setup
To check if your target definition is active, try to open the
IJavaProject class via Ctrl+Shift+T (Open Type).
This should not be possible, as this class is not part of your target platform.
2.7. 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.
3. Exercise: Mirroring p2 update
To avoid long running network operations to server outside of the own network, you can mirror p2 update sites.
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 2020-06 update site to C:\Users\Lars\mirror.
If you are not using Windows, use
eclipse instead of
./eclipsec -nosplash -verbose -application org.eclipse.equinox.p2.metadata.repository.mirrorApplication -source org.eclipse.equinox.p2.artifact.repository.mirrorApplication http://download.eclipse.org/releases/2020-06 -destination C:\Users\Lars\mirror ./eclipsec -nosplash -verbose -application org.eclipse.equinox.p2.artifact.repository.mirrorApplication -source org.eclipse.equinox.p2.artifact.repository.mirrorApplication http://download.eclipse.org/releases/2020-06 -destination C:\Users\Lars\mirror
4. Learn more and get support
This tutorial continues on Eclipse RCP online training with lots of video material, additional exercises and much more content.