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.
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 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.
Once you have a target definition file, you can set it as the target platform in your Eclipse IDE. This can be done via the Set as Active Target Platform link in the Target definition editor.
|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.
You can switch the target platform in the Eclipse Preferences. Select.
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.
In this exercise you create a target definition which can be used to develop an Eclipse RCP application.
Create a new project called target-platform of type General via.
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.
AFter saving the target definition file, it is resolved which will take a while.
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.
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>
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.
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.
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
I hope you enjoyed this tutorial. You find an extended online training at the Eclipse RCP online training website.
Copyright © 2012-2019 vogella GmbH. Free use of the software examples is granted under the terms of the Eclipse Public License 2.0. This tutorial is published under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Germany license.