Feature For Multiple OS - tycho

I want to create a feature for the basic Eclipse platform used to create our applications, but for multiple operating systems.
Since the feature.xml seems to support it, I thought as was easy as doing something like this:
<plugin
id="org.eclipse.swt"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="org.eclipse.swt.win32.win32.x86"
os="win32"
ws="win32"
arch="x86"
download-size="0"
install-size="0"
version="0.0.0"
fragment="true"
unpack="false"/>
<plugin
id="org.eclipse.swt.win32.win32.x86_64"
os="win32"
ws="win32"
arch="x86_64"
download-size="0"
install-size="0"
version="0.0.0"
fragment="true"
unpack="false"/>
...adding the plug-ins into a target platform and building it using Tycho. However I get the following exception:
[ERROR] Cannot resolve target definition:
[ERROR] Problems resolving provisioning plan.:
[ERROR] org.eclipse.swt.win32.win32.x86_64 3.7.2.v3740f cannot be installed in this environment because its filter is not applicable.
[ERROR]
[ERROR] Failed to resolve target definition C:\workspaces\MyGreatWorkspace\org.acme.platform.feature\build.target: See log for details: org.eclipse.swt.win32.win32.x86_64 3.7.2.v3740f cannot be installed in this environment because its filter is not applicable. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
Neither the target platform definition nor the pom.xml have defined the environment tag, so I'm not even sure what Tycho is validating against.
Having the environment tag doesn't change the exception either:
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<configuration>
<!-- [SNIP] -->
<environments>
<environment>
<os>win32</os>
<ws>win32</ws>
<arch>x86</arch>
</environment>
<environment>
<os>win32</os>
<ws>win32</ws>
<arch>x86_64</arch>
</environment>
</environments>
</configuration>
How do I create a feature for multiple operating systems?

Related

Compiling only part of java classess to java script with GWT using module source path

Guys I am trying to filter out some java files to not be compiled to java script. I cant make it work. I've check documentation here:
https://www.gwtproject.org/doc/latest/DevGuideOrganizingProjects.html#DevGuideModuleXml
<source path="_path_" /> : Each occurrence of the tag adds a package to the source path by combining the package in which the module XML is found with the specified path to a subpackage. Any Java source file appearing in this subpackage or any of its subpackages is assumed to be translatable. The element supports pattern-based filtering to allow fine-grained control over which resources get copied into the output directory during a GWT compile.
If no element is defined in a module XML file, the client subpackage is implicitly added to the source path as if had been found in the XML. This default helps keep module XML compact for standard project layouts.
but still no success.
My module file: model.gwt.xml
located in: com.company.section.app.model
with content:
<module>
<source path="">
</source>
</module>
takes all java files from package:
com.company.section.app.model
And I would like to compile only few of them, from f.e.: package com.company.section.app.model.to.javascript
So I do change my module file content into:
<module>
<source path="to.javascript">
</source>
</module>
But I am getting errors, f.e.:
[INFO] [ERROR] Line 69: No source code is available for type
com.company.section.app.model.to.javascript.DeviceDTO; did you forget to
inherit a required module?
I've tried already many combinations like:
<source path="com.company.section.app.model.to.javascript.*">
<source path="to.javascript.*">
<source path=".to.javascript.*">
Some times I am getting error:
[INFO] #
[INFO] # A fatal error has been detected by the Java Runtime Environment:
[INFO] #
[INFO] # SIGSEGV (0xb) at pc=0x00007f09897b3986, pid=1626892, tid=1626899
[INFO] #
[INFO] # JRE version: OpenJDK Runtime Environment (17.0.1+12) (build 17.0.1+12-Ubuntu-121.04)
[INFO] # Java VM: OpenJDK 64-Bit Server VM (17.0.1+12-Ubuntu-121.04, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
[INFO] # Problematic frame:
[INFO] # V [libjvm.so+0x6db986]
[INFO] #
I added source plugin to the project I wanna import (model)
<plugin>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<phase>package</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
I also add source dependency to project
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>shared</artifactId>
<version>${project.version}</version>
<classifier>sources</classifier>
</dependency>
I can't find any good example of such usage. Do I miss some * asterix? I just dont get it.
Documentation stands that I should add part of package to path, or I miss understood.
Please help.
I hope I did explain it well enough.
I found solution, or my mistake.
In xml module file we need to put path, and not package, like I was doing, so replacing:
<source path="to.javascript">
with
<source path="to/javascript">
Do the job

Eclipse 2018-12 has dependency to Windows, Linux and MaxOS

I just updated my application's org.eclipse.e4.rcp feature from Eclipse 4.9. to 4.10 (or 2012-09 to 2012-12). Now I get the exception:
[ERROR] Cannot resolve target definition:
[ERROR] Problems resolving provisioning plan.:
[ERROR] Unable to satisfy dependency from org.eclipse.swt 3.109.0.v20181204-1801 to org.eclipse.equinox.p2.iu; org.eclipse.swt.gtk.linux.x86_64 [3.109.0.v20181204-1801,3.109.0.v20181204-1801].
[ERROR] Unable to satisfy dependency from org.eclipse.swt 3.109.0.v20181204-1801 to org.eclipse.equinox.p2.iu; org.eclipse.swt.cocoa.macosx.x86_64 [3.109.0.v20181204-1801,3.109.0.v20181204-1801].
[ERROR] Unable to satisfy dependency from org.eclipse.swt 3.109.0.v20181204-1801 to org.eclipse.equinox.p2.iu; org.eclipse.swt.gtk.linux.ppc64le [3.109.0.v20181204-1801,3.109.0.v20181204-1801].
Both the .target file and the pom.xml have defined the target platform as being for Windows only:
<environment>
<os>win32</os>
<ws>win32</ws>
<arch>x86_64</arch>
</environment>
And the target file has additionally includeAllPlatforms="false". If I set it to true, I get the very similar exception:
[ERROR] Software being installed: org.acme.plugin 7.0.0.qualifier
[ERROR] Missing requirement: org.eclipse.swt 3.109.0.v20181204-1801 requires 'org.eclipse.equinox.p2.iu; org.eclipse.swt.gtk.linux.x86_64 [3.109.0.v20181204-1801,3.109.0.v20181204-1801]' but it could not be found
[ERROR] Cannot satisfy dependency: org.acme.plugin 7.0.0.qualifier depends on: java.package; org.eclipse.jface.preference 0.0.0
[ERROR] Cannot satisfy dependency: org.eclipse.jface 3.15.0.v20181123-1505 depends on: osgi.bundle; org.eclipse.swt [3.104.0,4.0.0)
If I add the fragments to the target platform, I get the following message (which is completely understandable):
org.eclipse.swt.gtk.linux.x86_64 3.109.0.v20181204-1801 cannot be installed in this environment because its filter is not applicable. -> [Help 1]
Setting the target platform to planner mode doesn't work. Neither does setting <org.eclipse.swt.buildtime>true</org.eclipse.swt.buildtime> in the pom.xml (false doesn't work either).
Looking at the XML file of the feature I can't see anything wrong with it (the fragments are defined for their OS only), still the target platform wants to haven the fragments for Linux and MacOS, even though I'm on Windows.
The target platform looks like this (yet again, it works if I replace 2018-12 with 2018-09):
<location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="false" type="InstallableUnit">
<repository location="https://download.eclipse.org/releases/2018-12/"/>
<unit id="org.eclipse.e4.rcp.feature.group" version="0.0.0" />
<unit id="org.eclipse.emf.common.feature.group" version="0.0.0" />
<unit id="org.eclipse.emf.ecore.feature.group" version="0.0.0" />
<unit id="org.eclipse.equinox.executable.feature.group" version="0.0.0" />
<unit id="org.eclipse.rcp.feature.group" version="0.0.0" />
</location>
And it's hooked in the pom.xml like this:
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<configuration>
<resolver>p2</resolver>
<target>
<artifact>
<groupId>groupId</groupId>
<artifactId>org.acme.plugin.build</artifactId>
<version>7.0.0-SNAPSHOT</version>
<classifier>platform</classifier>
</artifact>
</target>
<ignoreTychoRepositories>true</ignoreTychoRepositories>
<environments>
<environment>
<os>win32</os>
<ws>win32</ws>
<arch>x86_64</arch>
</environment>
</environments>
</configuration>
</plugin>
What is the problem? How can I fix it?
Who would have thought? It's the exact same Eclipse bug as in this question again. For some reason our build process gives preference to the plug-ins in Maven Central over the ones in the Eclipse repository. Since they have broken Maven dependencies, and since Tycho (obviously) still evaluates these dependencies, that breaks the build.
In our case the fix was as easy as moving Maven Central down below the Eclipse repo in our target platform.

How to build Eclipse plugin project with dependency on Eclipse Birt?

I have a set of Maven projects that I would like to migrate to SBT.
Tne only thing stopping me to do so, it's a project that is an Eclipse plugin, that has dependencies with Eclipse Birt.
The Tycho plugin for Maven, handles all the dependencies. This tool isn't available in SBT. I've found sbt-tycho plugin for SBT, but it looks like unmaintained (3 years with no activity).
Maybe I could build my Eclipse plugin with Maven, and the rest of projects with SBT. But don't know if this is possible.
Other alternative is to use Gradle, by means of the wuff plugin.
Related questions in StackOverflow:
How to build an eclipse plugin with sbt and sbt-osgi?
Can Apache Ivy handle dependencies in p2 repositories?
But I prefer SBT before Maven or Gradle, in order not to introduce yet another language besides Scala.
Is it possible to have all projects in SBT except the one that uses Tycho (Eclipse plugin)?. The Eclipse plugin project is a dependency of the main project, and it rarely changes.
Any ideas?
Update 1: additional information. Eclipse plugins use the p2 repository format for handling dependencies, instead of the standard Maven repository used for Gradle, Maven, Ivy and SBT. That's why special tools are needed. My custom Eclipse plugin has over 100 indirect p2 dependencies.
Update 2
pom.xml of my Eclipse plugin:
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>myCompany</groupId>
<artifactId>myPlugin</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<properties>
<tycho.version>0.19.0</tycho.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>eclipse</id>
<url>http://download.eclipse.org/releases/kepler</url>
<layout>p2</layout>
</repository>
<repository>
<id>babel</id>
<url>http://download.eclipse.org/technology/babel/update-site/R0.11.1/kepler</url>
<layout>p2</layout>
</repository>
<repository>
<id>logback</id>
<url>http://logback.qos.ch/p2/</url>
<layout>p2</layout>
</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>
<resolver>p2</resolver>
<environments>
<environment>
<os>linux</os>
<ws>gtk</ws>
<arch>x86_64</arch>
</environment>
<environment>
<os>win32</os>
<ws>win32</ws>
<arch>x86</arch>
</environment>
</environments>
</configuration>
</plugin>
</plugins>
</build>
</project>
It appears that the support for Eclipse updatesite with OSGi bundles is already available in Ivy. It doesn't however mean that the resolver can be used directly in sbt (I have never read about it and seen it in use before so I might be mistaken).
There's a way to include any resolver of Ivy in sbt using externalIvySettings():
create the configuration files as you would for Maven (pom.xml) or Ivy
(ivy.xml and optionally ivysettings.xml). External configuration is
selected by using one of the following expressions.
There's Ivy settings (resolver configuration) with externalIvySettings and Ivy file (dependency configuration) with externalIvyFile.
My guess is that you might be quite successful leveraging the support. Just add externalIvySettings and/or externalIvyFile to build.sbt, and create ivy.xml in the top-level directory of the Eclipse plugin's project with a declaration of Ivy's Eclipse updatesite resolver.
You may want to explore the support with the following build.sbt:
externalIvySettings()
libraryDependencies += "bundle" % "org.eclipse.swt.cocoa.macosx.x86_64" % "3.100.1.v4234e"
Place ivysettings.xml in the project's top-level directory (alongside build.sbt):
<ivysettings>
<settings defaultResolver="chain"/>
<resolvers>
<chain name="chain">
<ibiblio name="central" m2compatible="true"/>
<updatesite name="eclipse-juno" url="http://download.eclipse.org/releases/juno" />
</chain>
</resolvers>
</ivysettings>
With the two files above I could update up to failing on some packages:
> update
[info] Updating {file:/Users/jacek/sandbox/eclipse-p2/}eclipse-p2...
:: loading settings :: file = /Users/jacek/sandbox/eclipse-p2/ivysettings.xml
[warn] module not found: package#org.eclipse.swt.accessibility2;[0.0.0,)
[warn] ==== central: tried
[warn] http://repo1.maven.org/maven2/package/org.eclipse.swt.accessibility2/[revision]/org.eclipse.swt.accessibility2-[revision].pom
[warn] -- artifact package#org.eclipse.swt.accessibility2;[0.0.0,)!org.eclipse.swt.accessibility2.jar:
[warn] http://repo1.maven.org/maven2/package/org.eclipse.swt.accessibility2/[revision]/org.eclipse.swt.accessibility2-[revision].jar
[warn] ==== eclipse-juno: tried
[warn] module not found: package#org.mozilla.xpcom;[0.0.0,)
[warn] ==== central: tried
[warn] http://repo1.maven.org/maven2/package/org.mozilla.xpcom/[revision]/org.mozilla.xpcom-[revision].pom
[warn] -- artifact package#org.mozilla.xpcom;[0.0.0,)!org.mozilla.xpcom.jar:
[warn] http://repo1.maven.org/maven2/package/org.mozilla.xpcom/[revision]/org.mozilla.xpcom-[revision].jar
[warn] ==== eclipse-juno: tried
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: package#org.eclipse.swt.accessibility2;[0.0.0,): not found
[warn] :: package#org.mozilla.xpcom;[0.0.0,): not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn]
[warn] Note: Unresolved dependencies path:
[warn] package:org.eclipse.swt.accessibility2:[0.0.0,)
[warn] +- bundle:org.eclipse.swt:[3.0.0,4.0.0)
[warn] +- bundle:org.eclipse.swt.cocoa.macosx.x86_64:3.100.1.v4234e (/Users/jacek/sandbox/eclipse-p2/build.sbt#L3-4)
[warn] +- default:eclipse-p2_2.10:0.1-SNAPSHOT
[warn] package:org.mozilla.xpcom:[0.0.0,)
[warn] +- bundle:org.eclipse.swt:[3.0.0,4.0.0)
[warn] +- bundle:org.eclipse.swt.cocoa.macosx.x86_64:3.100.1.v4234e (/Users/jacek/sandbox/eclipse-p2/build.sbt#L3-4)
[warn] +- default:eclipse-p2_2.10:0.1-SNAPSHOT
Another solution (I haven't tried yet) is to use the sbt-osgi-manager plugin, designed for this purpose. It is actively mantained.
I'll update this answer with my experiences.
UPDATE: it doesn't work for me in the first try.
The final solution is to use a standard Maven repository for the Birt plugins. This solution is good for the embedding the Birt runtime, but not for a complete RCP app.

Build Eclipse cross-platform with Maven Tycho

I try to compile an Eclipse Indigo RCP application with Maven and Tycho. It works fine if I just build it for one platform but if I try to build it for more the build stops working.
The Problem is that I have platform specific plugins in my product file I want to build. Dependencies like org.eclipse.swt.win32.win32.x86 which are fragment plugins for org.eclipse.swt.
When I add no platform specific fragments to my product the application wouldn't start because there are no platform libraries like org.eclipse.swt.win32.win32.x86.
As Tycho repository we use a clone of the eclipse indigo update site hosted on our own server. It includes the delta-pack.
And when I add all fragments for all platforms the build crashed and maven tell me that the platform filters did not match for the Linux build for example.
Does anyone know how to fix this?
Should I add these platform dependent stuff into my product? I prefer to keep the specific dependencies out of my product, am I right?
It sounds like you have a plug-in based product. In this case you will need to manually edit your .product file and add in platform filters for these plug-ins. Unfortunately the built-in product editor in eclipse does not expose these values. See http://wiki.eclipse.org/Tycho/FAQ#How_to_build_plugin-based_products_with_platform-specific_fragments.3F
For each plugin e.g. org.eclipse.swt.win32.win32.x86 you will need to add something like;
<plugin id="org.eclipse.swt.win32.win32.x86" fragment="true" ws="win32" os="win32" arch="x86"/>
Note, if you use the product editor it will remove these values.
It is better however to use a feature based product. The feature editor permits these fields to be edited.
There is an easier solution I found in the blog: http://blog.sdruskat.net/building-a-cross-platform-feature-based-eclipse-rcp-product-with-tycho-the-umpteenth/
In the parent/master pom.xml,
To use all the plugins from p2, specify the 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>
<resolver>p2</resolver>
<environments>
<environment>
<os>linux</os>
<ws>gtk</ws>
<arch>x86_64</arch>
</environment>
<environment>
<os>win32</os>
<ws>win32</ws>
<arch>x86_64</arch>
</environment>
</environments>
</configuration>
</plugin>
</plugins>
</build>
My tycho version is 0.21.0

NoClassDefFoundError: Unable to run Tycho-built Eclipse RCP application under Linux/Mac OS

I'm developing a cross-platform RCP application in Win 7 (64bit), Indigo/Java 1.6, building the product with Tycho.
While the application runs fine from the Run Configuration within eclipse, and the Win x_86_64 build runs fine as well, I get the following errors on both xubuntu (with OpenJDK Java 6 Runtime (1.6.0_24) and Mac OS X (1.6.0_35).
The error (on Linux) looks like this (running java myprogram):
Exception in thread "main" java.lang.NoClassDefFoundError: myprogram
Caused by: java.lang.ClassNotFoundException: myprogram
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: myprogram. Program will exit.
I'm sure I've come across this before, and I think it was something stupid (this has happened on Windows before AFAIK, and re-installing Java fixed it for some reason). In this case, however, I think it must be to do with the build/target platform/Tycho setup.
The part of my parent POM responsible for the cross-platform build looks unsuspicious enough:
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tycho-version}</version>
<configuration>
<resolver>p2</resolver>
<pomDependencies>consider</pomDependencies>
<!-- configure the p2 target environments for multi-platform build -->
<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>
Does anybody have any ideas why this might not work?
Many thanks!
This is not how you run an Eclipse RCP application.
You either need to launch it with the appropriate native launcher, or with a java -jar plugins/org.eclipse.equinox.launcher_(yourVersion).jar (see this documentation) and probably further arguments to select your application.
Also, you need to make sure that you have the bundles in your application that Equinox needs to start up. You can do this by including the feature org.eclipse.rcp in you product.