How to build Eclipse RCP only for specific OS - eclipse

I have set up an Eclipse RCP build with maven and tycho. Currently there are build results for several OS's that I don't need. How can I restrict It only to be build for a speciffic OS?

I don't know much about tycho, however I know there is a separate plugin to configure the platforms.
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tycho-version}</version>
<configuration>
<environments>
<environment>
<os>win32</os>
<ws>win32</ws>
<arch>x86</arch>
</environment>
<environment>
<os>linux</os>
<ws>gtk</ws>
<arch>x86_64</arch>
</environment>
</environments>
</configuration>
</plugin>
</plugins>
</build>
I did find a few links in Google as well. Googling "tycho target platform" will probably find you more.
[http://www.vogella.com/articles/EclipseTycho/article.html]
[http://wiki.eclipse.org/Tycho/Plugins_Explained#target-platform-configuration]

Related

Why Tycho cannot resolve this simple dependency to SWT?

I thought to have studied enough Maven + Tycho to configure at least a minimal target environment for a headless build, but still I am unable to make this small example work. I have three projects:
test, that contains
sub.ui and
sub.target
The test project has just a pom.xml that builds the two subprojects and whose only interesting part is the <pluginManagement> section:
...
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<versionRange>[1.0.0,)</versionRange>
<goals>
<goal>target-platform</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-maven-plugin</artifactId>
<version>${tycho.version}</version>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tycho.version}</version>
<configuration>
<pomDependencies>wrapAsBundle</pomDependencies>
<target>
<artifact>
<groupId>${project.groupId}</groupId>
<artifactId>sub.target</artifactId>
<version>0.0.1-SNAPSHOT</version>
</artifact>
</target>
<environments>
<environment>
<os>linux</os>
<ws>gtk</ws>
<arch>x86</arch>
</environment>
<environment>
<os>linux</os>
<ws>gtk</ws>
<arch>x86_64</arch>
</environment>
<environment>
<os>win32</os>
<ws>win32</ws>
<arch>x86</arch>
</environment>
<environment>
<os>win32</os>
<ws>win32</ws>
<arch>x86_64</arch>
</environment>
<environment>
<os>macosx</os>
<ws>cocoa</ws>
<arch>x86_64</arch>
</environment>
</environments>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
...
verbose but quite straightforward (except perhaps for the lifecycle-mapping plugin, that however impacts only when building under Eclipse, and I want to build outside Eclipse). The sub.target project has a canonical pom.xml with just:
...
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
</plugin>
</plugins>
</build>
...
and a brief sub.target.target file:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?pde version="3.8"?>
<target includeMode="feature" name="Test" sequenceNumber="1">
<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.p2.user.ui.feature.group" version="0.0.0"/>
</location>
</locations>
<targetJRE path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"/>
</target>
The sub.ui project is a small plugin project with a silly main that uses a SWT class:
package foo;
import org.eclipse.swt.widgets.Label;
public class Main {
public static void main(String[] args) {
Label l = new Label(null, 0);
}
}
and a MANIFEST.MF:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Test UI
Bundle-SymbolicName: sub.ui;singleton:=true
Bundle-Version: 0.0.1.qualifier
Automatic-Module-Name: sub.ui
Bundle-RequiredExecutionEnvironment: JavaSE-11
Require-Bundle: org.eclipse.swt
Now, if I open a console and I mvn clear compile, Maven fails while building the Test UI plugin, and displays the errors:
[ERROR] Failed to execute goal org.eclipse.tycho:tycho-compiler-plugin:2.4.0:compile (default-compile) on project sub.ui: Compilation failure: Compilation failure:
[ERROR] /.../sub.ui/src/foo/Main.java:[3]
[ERROR] import org.eclipse.swt.widgets.Label;
[ERROR] ^^^^^^^^^^^
[ERROR] The import org.eclipse cannot be resolved
[ERROR] /.../sub.ui/src/foo/Main.java:[8]
[ERROR] Label l = new Label(null, 0);
[ERROR] ^^^^^
[ERROR] Label cannot be resolved to a type
[ERROR] /.../sub.ui/src/foo/Main.java:[8]
[ERROR] Label l = new Label(null, 0);
[ERROR] ^^^^^
[ERROR] Label cannot be resolved to a type
[ERROR] 3 problems (3 errors)
Apparently the build process does not link my code with the SWT version for my macos+cocoa platform, that is nevertheless listed among the plugins in the org.eclipse.equinox.p2.user.ui.feature.group. Strangely, if I launch Maven from Eclipse every now and then it links the right SWT library and completes the build process. What am I missing? How do I convince Tycho to use the information about my platform to consistently select the macos+cocoa SWT jar and link it to my code? I can share the complete example project on GitHub upon request if you cannot spot the mistake in the above code. Thank you for your patience.
Problem solved. Apparently the x86 platforms are no longer supported (the project I am working on is quite old). If we remove all the x86 <environment>s from the <pluginManagement> section of the main pom.xml file and leave only the x86_64 ones, everything works.

How to build a multiplatform Eclipse update site with Tycho

On my PDE/Tycho Eclipse environment I want to build a plugin of type eclipse-repository which contains 3 features each one for a specific platform.
The eclipse-repository plugin reads all its configuration from a parent plugin which content is the following:
<properties>
<tycho.version>0.26.0</tycho.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>neon</id>
<layout>p2</layout>
<url>http://download.eclipse.org/releases/neon/</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-maven-plugin</artifactId>
<version>${tycho.version}</version>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tycho.version}</version>
<configuration>
<environments>
<environment>
<os>win32</os>
<ws>win32</ws>
<arch>x86</arch>
</environment>
<environment>
<os>linux</os>
<ws>gtk</ws>
<arch>x86_64</arch>
</environment>
<environment>
<os>macosx</os>
<ws>cocoa</ws>
<arch>x86_64</arch>
</environment>
</environments>
</configuration>
</plugin>
</plugins>
</build>
When I try to build the eclpse-repository project I get an error:
[ERROR] Failed to execute goal org.eclipse.tycho:tycho-p2-repository-plugin:0.26.0:assemble-repository (default-assemble-repository) on project ... : Execution default-assemble-repository of goal org.eclipse.tycho:tycho-p2-repository-plugin:0.26.0:assemble-repository failed: Cannot resolve dependencies of MavenProject ...

Eclipse cannot find dependencies of a plugin built with Maven Tycho

I am using Maven Tycho to compile my projects which are structured like this :
- plugin1
- plugin2 (depends on plugin1)
- plugin3 (depends on plugin1 & 2)
- plugin4 (depends on plugin1)
- plugin5 (depends on plugin1 & 4)
- plugin6 (depends on all previous plugins)
- plugin7 (depends on all previous plugins)
{all these plugins are compiled as eclipse-plugin}
- feature1 (contains all previous plugins) {eclipse-feature}
- updatesite1 {eclipse-repository}
- generalproject (contains only the parent pom)
I compile this via Eclipse (maven install), everything works and i can access my local repository, and install my feature in the same Eclipse (through "Install new software").
The problem is when i try to install my feature to another instance of Eclipse, which refuse to install it with the error :
(Missing requirement: Acceleo Texts Module IDE Plug-in 1.0.0.201612161812 (myproject.acceleo.ui 1.0.0.201612161812) requires 'bundle org.eclipse.ocl 0.0.0' but it could not be found)
I know that this is a non satisfied requirement problem, but in Eclipse i checked "Contact all update sites during install to find required software", and my pom declares repositories containing all requirements, here is my parent pom :
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>myproject.project</groupId>
<artifactId>myproject.general</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<properties>
<tycho.version>0.23.0</tycho.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>Mars</id>
<layout>p2</layout>
<url>http://download.eclipse.org/releases/mars/</url>
</repository>
<repository>
<id>Sirius</id>
<layout>p2</layout>
<url>http://download.eclipse.org/sirius/updates/releases/4.1.2/mars/</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<!-- enable tycho build extension -->
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-maven-plugin</artifactId>
<version>${tycho.version}</version>
<extensions>true</extensions>
</plugin>
<plugin>
<!-- enable tycho build extension -->
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tycho.version}</version>
<configuration>
<environments>
<environment>
<os>linux</os>
<ws>gtk</ws>
<arch>i386</arch>
</environment>
<environment>
<os>linux</os>
<ws>gtk</ws>
<arch>x86_64</arch>
</environment>
<environment>
<os>win32</os>
<ws>win32</ws>
<arch>x86</arch>
</environment>
<environment>
<os>win32</os>
<ws>win32</ws>
<arch>x86_64</arch>
</environment>
<environment>
<os>macosx</os>
<ws>cocoa</ws>
<arch>x86_64</arch>
</environment>
</environments>
</configuration>
</plugin>
</plugins>
</build>
<modules>
<module>../myproject</module>
<module>../myproject.acceleo</module>
<module>../myproject.acceleo.ui</module>
<module>../myproject.design</module>
<module>../myproject.edit</module>
<module>../myproject.editor</module>
<module>../myproject.plugin</module>
<module>../myproject.project</module>
<module>../myproject.site</module>
</modules>
</project>
I cannot figure how to resolve this ? did i omit something in my procedure ?
Thank you.
I fell for the same thing. Tycho does not include all dependencies, even though that's normal and desired maven behaviour. As maven does not "see" tycho (so manifest-derived) dependencies, they are not included.
You can override this behaviour by setting to true:
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-p2-repository-plugin</artifactId>
<version>${tycho-version}</version>
<configuration>
<includeAllDependencies>true</includeAllDependencies>
</configuration>
</plugin>
Probably the Eclipse installation where you want to install your feature does not have an update site configured that contains org.eclipse.ocl. This has nothing to do with your Maven build, as long as you didn't configure your feature to also contain the required bundles, which could also be done.

Missing artifacts on Maven Central Repository

Maven central repository does not have jars and artifacts of Eclipse Juno 4.2 release.
Where can i find all these jars and artifacts(along with pom.xml-including transitive dependencies).It will be helpful for us to resolve all maven dependencies as we are planning to migrate eclipse plugins from 3.2 to 4.2.
Before posting a new question, take a look to the old ones.
I think this thread will reply to your : Maven with Eclipse Juno
We faced a similar Problem. Perhaps you should consider using Tycho to build Eclipse Plugins with Maven. It supports using eclipse update sites as dependency source. This way you do not need to resolve eclipse dependencies from a Maven repository.
Tycho takes the Manifest file as dependency definition. However it is still possible to include maven dependencies. The concrete plugin project has to have the packaging
<packaging>eclipse-plugin</packaging>
If your target platform definition does not contain the needed update sites that contain your dependencies add this to your pom:
<repositories>
<repository>
<id>indigo</id>
<!-- Or juno update site in your case -->
<url>http://download.eclipse.org/releases/indigo/</url>
<layout>p2</layout>
</repository>
</repositories>
Additionally you have to configure the build as following:
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-maven-plugin</artifactId>
<version>${tycho.version}</version>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tycho.version}</version>
<configuration>
<target>
<artifact>
<!-- coordinates of your target platform definition -->
</artifact>
</target>
<!-- This allows you to additionally consider pom dependencies -->
<pomDependencies>consider</pomDependencies>
<configuration>
<environments>
<environment>
<os>linux</os>
<ws>gtk</ws>
<arch>x86</arch>
</environment>
<environment>
<os>linux</os>
<ws>gtk</ws>
<arch>x86_64</arch>
</environment>
<environment>
<os>win32</os>
<ws>win32</ws>
<arch>x86</arch>
</environment>
<environment>
<os>win32</os>
<ws>win32</ws>
<arch>x86_64</arch>
</environment>
<environment>
<os>macosx</os>
<ws>cocoa</ws>
<arch>x86_64</arch>
</environment>
</environments>
</configuration>
</configuration>
</plugin>
</plugins>

eclipse product invocation causes ClassNotFoundException of org.eclipse.swt.SWTError

I found a nice todo-tool that is based on eclipse-rcp and xtext (Sebastian Benz - Eclipse-Task-Editor). I cloned the git repository an exported the product. Unfortunately, I'm getting following exception as starting the eclipse product:
Caused by: java.lang.ClassNotFoundException: org.eclipse.swt.SWTError
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:513)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:429)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:417)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 43 more
The entire stack trace can be found (here). I found a guy having the same exception caused by some wrong parameters. I removed all of them but the exception is still present. Do you have a clue what could cause the issue? Thank you!
I use Eclipse Indigo Service Release 1 on Gnome/Linux with the following java version:
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02, mixed mode)
Maybe , the application not found the right swt lib in your plugin folder. you need a jar named "org.eclipse.swt.gtk.linux.x86_64_xxxx.jar". you can check it.
I solved the 'same/a similar' problem by editing the root pom.xml like so:
<build>
<plugins>
<plugin>
<groupId>${tycho-groupid}</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tycho-version}</version>
<configuration>
<resolver>p2</resolver>
<target>
<artifact>
<groupId>de.sebastianbenz.task.tools</groupId>
<artifactId>de.sebastianbenz.task.target</artifactId>
<version>${task-editor-version}</version>
<classifier>indigo</classifier>
</artifact>
</target>
<ignoreTychoRepositories>true</ignoreTychoRepositories>
<environments>
<!--
<environment>
<os>macosx</os>
<ws>cocoa</ws>
<arch>x86_64</arch>
</environment>
<environment>
<os>win32</os>
<ws>win32</ws>
<arch>x86</arch>
</environment>
<environment>
<os>win32</os>
<ws>win32</ws>
<arch>x86_64</arch>
</environment>
<environment>
<os>linux</os>
<ws>gtk</ws>
<arch>x86</arch>
</environment>
-->
<environment>
<os>linux</os>
<ws>gtk</ws>
<arch>x86_64</arch>
</environment>
</environments>
</configuration>
</plugin>
<plugin>
<groupId>${tycho-groupid}</groupId>
<artifactId>tycho-maven-plugin</artifactId>
<version>${tycho-version}</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
Believe it or not, I was able to solve the export problem by simply downloading the same version of Eclipse but from a different mirror - initially I downloaded it from the U of Waterloo and the 2nd time around from the U of Pennsylvania mirror. I backed up the projects before blowing away the previous Eclipse installation and re-imported them on the new instance. The product export worked without a hitch. I am using Eclipse 3.7.2 - Indigo for RAP and RCP developers.