I try to create an eclipse plugin using OSGI dependencies from two repositories, one with maven dependencies, and one with p2 dependencies :
<repositories>
<repository>
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>bintray-anrgenstar-genstar-packages</id>
<name>bintray</name>
<url>http://dl.bintray.com/anrgenstar/genstar-packages</url>
</repository>
</repositories>
<repository>
<id>gama</id>
<name>GAMA Snapshots</name>
<url>http://gama.unthinkingdepths.fr</url>
<layout>p2</layout>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
The project contain one parent pom.xml into ummisco.gaml.extensions.parent
, which build the eclipse plugin ummisco.gaml.extensions.genstar
:
- (1) ummisco.gaml.extensions.parent
- pom.xml
- (2) ummisco.gaml.extensions.genstar
- pom.xml
- src/...
- META-INF/MANIFEST.MF
(1) The ummisco.gaml.extensions.genstar
parent pom.xml
define the module <module>../ummisco.gaml.extensions.genstar</module>
to build and call the Tycho maven plugin :
<modelVersion>4.0.0</modelVersion>
<groupId>ummisco.gaml.extensions</groupId>
<artifactId>ummisco.gaml.extensions.parent</artifactId>
<version>1.7.0-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>../ummisco.gaml.extensions.genstar</module>
</modules>
<properties>
<p2-maven.version>1.2.0-SNAPSHOT</p2-maven.version>
<tycho.version>0.26.0</tycho.version>
<project.version>1.7.0-SNAPSHOT</project.version>
</properties>
<repositories>
<repository>
<id>sonatype-nexus-snapshots</id>
<name>Sonatype Nexus Snapshots</name>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>eclipse-mars</id>
<url>http://download.eclipse.org/releases/mars</url>
<layout>p2</layout>
</repository>
<repository>
<id>eclipse-elk</id>
<url>http://build.eclipse.org/modeling/elk/updates/nightly/</url>
<layout>p2</layout>
</repository>
<repository>
<id>eclipse-graphiti</id>
<url>http://download.eclipse.org/graphiti/updates/milestones/</url>
<layout>p2</layout>
</repository>
<repository>
<id>gama</id>
<name>GAMA Snapshots</name>
<url>http://gama.unthinkingdepths.fr</url>
<layout>p2</layout>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-maven-plugin</artifactId>
<version>${tycho.version}</version>
<extensions>true</extensions>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-p2-director-plugin</artifactId>
<version>${tycho.version}</version>
</plugin>
</plugins>
</build>
</project>
(2) The eclipse-plugin
pom.xml
of ummisco.gaml.extensions.genstar
which need p2 and maven dependencies to work use the tycho <pomDependencies>consider</pomDependencies>
option.
<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>ummisco.gaml.extensions.genstar</groupId>
<artifactId>ummisco.gaml.extensions.genstar</artifactId>
<packaging>eclipse-plugin</packaging>
<parent>
<groupId>ummisco.gaml.extensions</groupId>
<artifactId>ummisco.gaml.extensions.parent</artifactId>
<version>1.7.0-SNAPSHOT</version>
<relativePath>../ummisco.gaml.extensions.parent/</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>genstar.core</groupId>
<artifactId>core</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>genstar.spll</groupId>
<artifactId>spll</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>genstar.spin</groupId>
<artifactId>spin</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>genstar.gospl</groupId>
<artifactId>gospl</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
<repositories>
<repository>
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>bintray-anrgenstar-genstar-packages</id>
<name>bintray</name>
<url>http://dl.bintray.com/anrgenstar/genstar-packages</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tycho.version}</version>
<configuration>
<resolver>p2</resolver>
<pomDependencies>consider</pomDependencies>
</configuration>
</plugin>
</plugins>
</build>
</project>
The MANIFEST.MF
for this eclipse-plugin
is defined like that :
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Genstar
Bundle-SymbolicName: ummisco.gaml.extensions.genstar;singleton:=true
Bundle-Version: 1.7.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: msi.gama.core, core, gspl, spin, spll,
javax.xml;bundle-version="1.3.4"
When i try to mvn clean install
into ummisco.gaml.extensions.parent
it seems that tycho download and recognize the dependencies defined in p2 (msi.gama.core
for example), and defined in pom.xml (core, spll,gospl, spin
OSGI bundle), but transitive dependencies of these bundles are not resolved.
[INFO] Fetching p2.index from http://gama.unthinkingdepths.fr/ (172B)
[INFO] Adding repository http://gama.unthinkingdepths.fr
[INFO] Resolving dependencies of MavenProject: ummisco.gaml.extensions.genstar:ummisco.gaml.extensions.genstar:1.7.0-SNAPSHOT @ /home/reyman/Projets/genstar-gama-plugin/ummisco.gaml.extensions.genstar/pom.xml
[INFO] {osgi.os=linux, osgi.ws=gtk, org.eclipse.update.install.features=true, osgi.arch=x86_64}
[ERROR] Cannot resolve project dependencies:
[ERROR] Software being installed: ummisco.gaml.extensions.genstar 1.7.0.qualifier
[ERROR] Missing requirement: core 1.0.0 requires 'package org.math.R 0.0.0' but it could not be found
[ERROR] Cannot satisfy dependency: ummisco.gaml.extensions.genstar 1.7.0.qualifier depends on: bundle core 0.0.0
[ERROR]
I verify the transitive dependencies of the OSGI Bundle core 1.0.0
manifest (using mvn dependency:tree
) and it seems correct, the manifest contain the declaration of dependencies in Import-Package, like org.math.R as you can see here :
Manifest-Version: 1.0
Bnd-LastModified: 1481896487741
Build-Jdk: 1.8.0_101
Built-By: reyman
Bundle-ManifestVersion: 2
Bundle-Name: core
Bundle-SymbolicName: core
Bundle-Version: 1.0
Created-By: Apache Maven Bundle Plugin
Export-Package: core.configuration;version="1.0.0";uses:="com.thoughtw
orks.xstream,core.metamodel,core.metamodel.pop,core.metamodel.pop.io"
,core.metamodel;version="1.0.0",core.metamodel.geo;version="1.0.0";us
es:="com.vividsolutions.jts.geom,core.metamodel",core.metamodel.geo.i
o;version="1.0.0";uses:="com.vividsolutions.jts.geom,core.metamodel.g
eo",core.metamodel.pop;version="1.0.0";uses:="com.vividsolutions.jts.
geom,core.metamodel,core.metamodel.geo,core.util.data",core.metamodel
.pop.io;version="1.0.0",core.util;version="1.0.0";uses:="org.apache.l
ogging.log4j",core.util.R;version="1.0.0";uses:="org.math.R",core.uti
l.data;version="1.0.0";uses:="core.util.excpetion",core.util.excpetio
n;version="1.0.0",core.util.random;version="1.0.0",core.util.random.r
oulette;version="1.0.0",core.util.stats;version="1.0.0"
Import-Package: com.thoughtworks.xstream;version="[1.4,2)",com.thought
works.xstream.converters;version="[1.4,2)",com.thoughtworks.xstream.c
onverters.extended;version="[1.4,2)",com.thoughtworks.xstream.io;vers
ion="[1.4,2)",com.thoughtworks.xstream.io.xml;version="[1.4,2)",com.t
houghtworks.xstream.mapper;version="[1.4,2)",com.vividsolutions.jts.g
eom,core.metamodel;version="[1.0,2)",core.metamodel.geo;version="[1.0
,2)",core.metamodel.pop;version="[1.0,2)",core.metamodel.pop.io;versi
on="[1.0,2)",core.util.data;version="[1.0,2)",core.util.excpetion;ver
sion="[1.0,2)",core.util.random;version="[1.0,2)",org.apache.logging.
log4j;version="[2.7,3)",org.math.R,org.rosuda.REngine,org.rosuda.REng
ine.Rserve
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"
Tool: Bnd-3.2.0.201605172007
I really don't understand why the transitive dependencies are not automaticly resolved by tycho using the pom.xml dependency ... If tycho recognized the core, spll, spin, etc. package in the eclipse-plugin MANIFEST, why the transitive dependencies of core, spll, spin, gospl OSGI bundle are not downloaded ?
Do you think there is a solution for this problem ?
UPDATE
Following this repository i try to make two project :
maven-bundle
which bundle all dependencies into one big jartycho-bundle
which take thismaven-bundle
in dependency
Intelij Idea found the different dependency class when i compile in GUI mode, but not my maven project when i run mvn install
, it's really really weird... I don't understand where is the problem.
You can find the archive of the project here, you need to mvn clean install
pom.xml
into /maven-bundle/
folder, then mvn clean install
pom.xml
into tycho-bundle/
folder.
01_bundle_wrappers
and adjust theexclusion
entries accordingly (we're doing that with the Guava dependencies in the given example). – Beatrix