Building Eclipse plugin with Tycho from mirrored P2 Repository in Nexus - eclipse

After endless reading and testing out different things, I now have to ask my specific question.
A few information about my project:
I would like to build a Eclipse plugin with Maven to integrate it in our CI/CD process.
We're using Eclipse-2019-06.
I'm in a separate developing network where I only have access to the internet via proxy.
A Nexus is running which is mirroring all the needed Maven repositories (Central and so).
Because of the proxy problem I installed the P2 Nexus plugin and bridge to add the Eclipse P2 repository https://download.eclipse.org/releases/2019-06/201906191000/ in our Nexus to mirror it locally. So the Nexus repository points now from the official P2 download site to the local http://nexus:8081/nexus/content/repositories/eclipse-repository address.
The first thing I tried then, was to add the update site http://nexus:8081/nexus/content/repositories/eclipse-repository to the running Eclipse installation to access all the plugins and so on. This works fine!
So now I'm trying to build the official Eclipse Plugin Tycho demo itp01 from https://github.com/eclipse/tycho-demo.
And here comes the problem: I changed the repositories section in the official pom.xml to
<repositories>
<repository>
<id>eclipse-repo</id>
<layout>p2</layout>
<url>http://nexus:8081/nexus/content/repositories/eclipse-repository</url>
</repository>
</repositories>here
When I now try to build the itp01 project I get the so often seen error:
[ERROR] Cannot resolve project dependencies:
[ERROR] Software being installed: tycho.demo.itp01 1.0.0.qualifier
[ERROR] Missing requirement: tycho.demo.itp01 1.0.0.qualifier requires 'osgi.bundle; org.eclipse.core.runtime 3.15.300' but it could not be found
[ERROR]
[ERROR] See http://wiki.eclipse.org/Tycho/Dependency_Resolution_Troubleshooting for help.
[ERROR] Cannot resolve dependencies of MavenProject: tycho.demo.itp01:tycho.demo.itp01:1.0.0-SNAPSHOT # /home/frto100/git/org.eclipse.tycho-demo/itp01/tycho.demo.itp01/pom.xml: See log for details -> [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.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MavenExecutionException
It looks like it's not possible for Tycho to read the artifacts from the P2 repository in Nexus.
Secondhand I'm not sure if Tycho even evaluates the given repository URL. Is it possible to check if Tycho is really using the correct URL?
Can somebody maybe give me a hint where the problem could be? Or maybe somebody already solved this problem.
Thanks so much!

If you are using Maven 3.6.1 (which is embedded in Eclipse 2019-06 and 2019-09), you probably ran into the following issue:
Maven issue MNG-6642: Tycho-based modules do not build with 3.6.1 (works with 3.6.0)
Using a different Maven version than 3.6.1 should solve the issue.

Related

Eclipse Tycho: Compile error when using the java.xml.bind module?

I think the problem is the same as described in this blog post but I get this for Java 10: I have an Eclipse RCP application that uses Java 10 features but also JAXB classes. In Eclipse, I have to add the java.xml.bind module to the build path configuration of my project (as described here) to let the compile errors go away.
However, when building the product with Tycho 1.2.0 I get the following error, exactly for the class that uses JAXB:
[ERROR] Failed to execute goal org.eclipse.tycho:tycho-compiler-plugin:1.2.0:compile (default-compile) on project epd-editor: Compilation failure: Compilation failure:
[ERROR] ...app\src\app\editors\XmlPage.java:
[ERROR] package app.editors;
[ERROR] ^
[ERROR] Internal compiler error: java.lang.NullPointerException at org.eclipse.jdt.internal.compiler.lookup.BinaryModuleBinding.create(BinaryModuleBinding.java:64)
[ERROR] java.lang.NullPointerException
[ERROR] at org.eclipse.jdt.internal.compiler.lookup.BinaryModuleBinding.create(BinaryModuleBinding.java:64)
[ERROR] at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.getModuleFromAnswer(LookupEnvironment.java:427)
[ERROR] at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForTypeFromModules(LookupEnvironment.java:367)
[ERROR] at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForType(LookupEnvironment.java:228)
[ERROR] at org.eclipse.jdt.internal.compiler.lookup.UnresolvedReferenceBinding.resolve(UnresolvedReferenceBinding.java:105)
Is there a way to configure the Tycho compiler plugin so that it can see modules like java.xml.bind or is there another reason for this error?
Thanks.
Java EE modules are deprecated for removal and not resolved by default and will be removed in Java 11.
The best way to handle this is to use a third-party dependency, but as you observe JDT trips over its own feet when that is done. I opened an issue and it was fixed some time ago, but it's not easy to find an artifact that contains the change and works on Java 10. The first artifact I know of comes from Eclipse Photon I20180531-0700.
Execute the following in Eclipse's plugins folder (#people from the future: you may have to update the version):
mvn install:install-file \
-Dfile=org.eclipse.jdt.core_3.14.0.v20180528-0519.jar \
-DgroupId=org.eclipse.tycho \
-DartifactId=org.eclipse.jdt.core \
-Dversion=3.14.0.v20180528-0519 \
-Dpackaging=jar
You can then use it as follows as dependencies for Maven's compiler plugin:
<dependency>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-compiler-jdt</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.tycho</groupId>
<artifactId>org.eclipse.jdt.core</artifactId>
<!-- unreleased version that was pulled from Eclipse Photon I20180531-0700
contains the fix and compiles Java 10 -->
<version>3.14.0.v20180528-0519</version>
</dependency>
The problem is also described on java9.wtf with a demo project on GitHub. (I forgot to push, so it's only online for about five minutes now. 😒)
There are three ways you can include modules from the java.se.ee aggregator module, which is not included for compile or runtime in JDK 10. (As of JDK 11, these modules will be removed from the JDK).
The simplest is to use the command line option, --add-modules java.xml.bind. This will use the version that is still included in the JDK.
Find a JAXB implementation jar. Maven central is a good place to go for this, there is also a reference implementation for JSR 222 (JAXB), which is part of the Java Web Services Developer Pack (http://www.oracle.com/technetwork/java/webservicespack-jsp-140788.html) but this is waaaay old and may not be the best choice. You can add where you've downloaded the jar to the upgrade module path using --upgrade-module-path {path}
An alternative to 2 is to simply put the jar containing JAXB on the classpath.
I'm not familiar with Tycho but you would need to figure out how to use one of these methods with its configuration.

Linking JSF libraries from JBoss in Maven

I have a very simple web project in Eclipse that uses JSF and runs with a JBoss 4.2.3. I have 'Mavenized' the project and a pom.xml is generated. The pom.xml is empty with no dependencies, but I can install this maven project and I see my web page when I run the JBoss from eclipse. All fine till here.
Now I need to extend the logic of the java code and I need to add a new artifact generated from another project, and here is where my problem starts. When I add a dependency to this new artifact and I try the make a 'install' I am getting this error:
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile
(default-compile) on project MyTest: Compilation failure: Compilation
failure:
[ERROR]
/home/daniel/workspace/valais/voba-switch/src/ch/steria/scada/sw/web/controller/SwitchController.java:[7,24]
package javax.faces.model does not exist
[ERROR]
/home/daniel/workspace/valais/voba-switch/src/ch/steria/scada/sw/web/controller/SwitchController.java:[45,13]
cannot find symbol
[ERROR] symbol : class SelectItem
I see the libraries missing are in the jboss-web.deployer directory of the JBoss. How can I link this libraries in the pom.xml or how can I get the right ones from the jboss maven repository for my jboss vesion?
Thanks,
Dani.
I just had to set the artifacts from JBoss as 'provided'.

How to get Nexus p2 proxy to work with Eclipse p2 repository?

We are using Maven (with Tycho) and Nexus to build our Eclipse plugins. While we are continuously digging deeper into it, we are still learning how to use Maven with Nexus best. Our plugins will have to run on Eclipse 3.6 or better, so we defined bundle requirements pointing to Eclipse 3.6. We are running our own Nexus which should act as a mirror to the public repository, but there seem to be only the latest versions available on repo.eclipse.org, not the older 3.6 we need, as we keep getting
[ERROR] Cannot resolve project dependencies:
[ERROR] Software being installed: our.own.plugin 3.0.0.qualifier
[ERROR] Missing requirement: our.own.plugin 3.0.0.qualifier requires 'bundle org.eclipse.core.runtime 3.6.0' but it could not be found
Is there a public Nexus repository available for older versions? If not, where can we get the 3.6 artifacts to upload them on our local Nexus?
After some more investigation, I find that after I added a proxy from download.eclipse.org/eclipse/updates/3.6/ as remote repository to Nexus, the build keeps saying
[INFO] Fetching p2.index from http://192.168.205.205:8081/nexus/content/groups/public-p2/ (0B of 134B at 0B/s)
[INFO] Fetching p2.index from http://192.168.205.205:8081/nexus/content/groups/public-p2/ (134B of 134B at 0B/s)
[INFO] Loading repository 'http://192.168.205.205:8081/nexus/content/repositories/eclipse-4.4' from mirror 'nexus-p2' at '192.168.205.205:8081/nexus/content/groups/public-p2/'
and finally fails after a while with
Exception in thread "main" java.lang.StackOverflowError
at org.eclipse.equinox.internal.p2.transport.ecf.RepositoryTransport.download(RepositoryTransport.java:111)
at org.eclipse.equinox.internal.p2.transport.ecf.RepositoryTransport.download(RepositoryTransport.java:156)
at org.eclipse.equinox.internal.p2.repository.helpers.AbstractRepositoryManager.loadIndexFile(AbstractRepositoryManager.java:735)
at org.eclipse.equinox.internal.p2.repository.helpers.AbstractRepositoryManager.loadRepository(AbstractRepositoryManager.java:657)
at org.eclipse.equinox.internal.p2.metadata.repository.MetadataRepositoryManager.loadRepository(MetadataRepositoryManager.java:96)
at org.eclipse.tycho.p2.remote.RemoteMetadataRepositoryManager.loadRepository(RemoteMetadataRepositoryManager.java:59)
at org.eclipse.tycho.p2.remote.RemoteMetadataRepositoryManager.loadRepository(RemoteMetadataRepositoryManager.java:52)
at
...
What is the problem?
I noticed that the remote Eclipse 3.6 repository does not have a p2.index file, so I tried Eclipse 4.4, but I receive the same result.
I use Nexus as a mirror for all repositories by adding the following configuration to .m2/settings.xml:
<mirror>
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://192.168.205.205:8081/nexus/content/groups/public/</url>
</mirror>
<mirror>
<id>nexus-p2</id>
<mirrorOf>*</mirrorOf>
<mirrorOfLayouts>p2</mirrorOfLayouts>
<url>http://192.168.205.205:8081/nexus/content/groups/public-p2/</url>
<layout>p2</layout>
</mirror>
Maybe something is wrong with this configurations? I suspect that maybe Nexus tries to mirror its own repository, leading to endless requests?
To access eclipse artifacts from a tycho build, the easiest approach is to include a repository section in your pom like this:
<repository>
<id>eclipse-helios</id>
<url>http://download.eclipse.org/releases/helios</url>
<layout>p2</layout>
</repository>
The shown url contains all content from the so-called simultaneous release train, and by this is should normally contain all your depedencies from a single location (it does contain EMF 2.6) (Helios corresponds to Eclipse 3.6).
This repository is big, containing one release and two service releases. To narrow it down to, e.g., Helios SR2, you may want to use
<url>http://download.eclipse.org/releases/helios/201102250900</url>
If you define the plugin as requiring exactly 3.6.0 you will only be able to run it on Eclipse 3.6 and not on any later version. You should specify the version as 3.6.0 or later if you want to run on newer versions.
Older versions of Eclipse including 3.6 are available on the Eclipse archive download site http://archive.eclipse.org/eclipse/downloads/

Maven Error in Eclipse - BPMN2 Modeler

my problem is the following. I have Eclipse Kepler SR1 and imported an maven project out of the following git: http://git.eclipse.org/c/bpmn2/.git/
This is a metamodel for the BPMN 2.0. After that i wanted to do a maven install but when i do this the following Error pops up
[ERROR] Failed to execute goal org.eclipse.cbi.maven.plugins:eclipse-jarsigner-plugin:1.0.3:sign (sign) on project org.eclipse.bpmn2: Could not sign artifact org.eclipse.bpmn2:org.eclipse.bpmn2:eclipse-plugin:0.7.0-SNAPSHOT: Connection to http://build.eclipse.org:31338 refused: Connection timed out: connect -> [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.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :org.eclipse.bpmn2
Maven is correctly installed and i checked the superpom. There is no mistake in my opinion. I also updated the pluginRepository for plugin signin to https://repo.eclipse.org/content/repositories/cbi-releases/. Is there anyone who knows the mistake and can help me?
Best Regards
The first line of your error message contains a timeout for http://build.eclipse.org:31338 - that seems to me an internal address.
If I am not mistaken, this is used by the jar signer plug-in mentioned in the build script that is an eclipse.org-only service (for obvious reasons). Search for the followi
<groupId>org.eclipse.cbi.maven.plugins</groupId>
<artifactId>eclipse-jarsigner-plugin</artifactId>
As signing is an internal service, we in the EMF-IncQuery project execute signing only when a specific profile is selected, thus allowing building our project outside eclipse.org servers.

Tycho cannot resolve Require-Bundle: org.sample.ide.common;bundle-version="1.0.0.qualifier"

I build an Eclipse plug-in project with Tycho.
I got this error message.
[ERROR] Cannot resolve project dependencies:
[ERROR] Software being installed: org.sample.ide.core 1.0.0.qualifier
[ERROR] Missing requirement: org.sample.ide.core 1.0.0.qualifier requires 'bundle org.sample.ide.common 1.0.0' but it could not be found
org.sample.ide.core-1.0.0.qualifier has org.sample.ide.common-1.0.0.qualifier as required bundle.
When I export the plug-in project with the Eclipse PDE export function, the dependent projects are recognized inside the same workspace.
And my manifest.mf has version like 1.0.0.qualifier, and my pom.xml has 1.0.0-SNAPSHOT. Is that problem?
Having artifacts with .qualifier versions is supported, so this is not the cause of your problem.
However I am not sure to what extend Tycho also supports .qualifier replacement in dependencies, e.g. Require-Bundle headers. (At least, this is buggy.) So you should try to build your project with a dependency to version 1.0.0 instead of 1.0.0.qualifier.
Tycho replaces the .qualifier with a timestamp or fixed string in the reactor build within all manifest files. It resolves the files from the repositories defined from the target files attached, and from the local repository. If none of these contain an exactly matching dependency, tycho will not succeed with the build.
Note that the resolution of PDE export is based on the current target set in Eclipse, and that PDE will replace the qualifier for all bundles open in the workspace. Tycho does not know of these, its scope is what is included in the reactor during the build.