Eclipse cannot find dependencies of a plugin built with Maven Tycho - eclipse

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.

Related

Build single update-site for RAP and RCP flavored feature

I have a build for a single-sourced RCP/RAP Eclipse feature project that uses maven profiles to either build RAP or RCP bundles, fragments and features.
This works reasonably well. If I include my update site project as module in the above build's parent POM I can also easily build a platform-specific update-site using either "eclipse-update-site" (or "eclipse-repository") packaging.
However, I was wondering, if there is a way to
build RCP target platform > publish to local repo
build RAP target platform > publish to local repo
run build for RCP (target platform from step 1) > publish to local repo
run build for RAP (target platform from step 2) > publish to local repo
run build for update site only, include feature for RAP and for RCP (not compiling anything, just assembling from 1+2)
I could successfully execute steps 1-4, but not 5, because Tycho was trying to resolve the features referenced by the category.xml with a different qualifier.
If I understand update sites/p2 repositories correctly, it should be possible to offer any artifacts / bundles / features in various flavors, right?
How can I solve this, or rather: can I have a single tycho build that runs the above build steps consecutively with the same qualifier for all?
Addendum: This existing question goes in the same direction and suggests to "install the (feature) Tycho project(s) into ... local Maven repository". That's actually what I'm doing when I run 1. and 2. after each other, specifiying the same local repo for both. But then 3. fails to pull the referenced artifacts from there, because the qualifier is different (two distinct reactor builds). Running everything in the same reactor build would be totally fine for me, but I think that's not possible, because there are different target platforms involved.
I think the solution there is pretty close to what I need, but I don't understand how my category.xml (or site.xml) and the extra dependencies in POM work together. Do I have to abandon category.xml altogether and respecify all my dependencies in the eclipse-repository POM?
My build roughly looks like this:
foo.releng/pom.xml (parent POM)
<?xml version="1.0" encoding="UTF-8"?>
<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>net.bar</groupId>
<artifactId>foo</artifactId>
<version>0.31.0-SNAPSHOT</version>
<packaging>pom</packaging>
<properties>
<tycho-version>1.0.0</tycho-version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jacoco-version>0.7.6.201602180812</jacoco-version>
</properties>
<modules>
<module>../foo.plugin1</module>
<module>../foo.plugin2</module>
<!-- feature module is built depending on target platform, see below -->
</modules>
<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 and dependency-resolution are RAP/RCP dependent, see profiles below -->
<resolver>p2</resolver>
<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>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>target-rcp</id>
<activation>
<property>
<name>target.platform</name>
<value>rcp</value>
</property>
</activation>
<modules>
<module>../foo.fragment.rcp</module>
<module>../foo.feature.rcp</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tycho-version}</version>
<configuration>
<target>
<artifact>
<groupId>net.bar</groupId>
<artifactId>net.bar.foo.target.rcp</artifactId>
<version>${project.version}</version>
<classifier>rcp</classifier>
</artifact>
</target>
<dependency-resolution>
<optionalDependencies>ignore</optionalDependencies>
<extraRequirements>
<requirement>
<type>eclipse-plugin</type>
<id>org.eclipse.ui</id>
<versionRange>0.0.0</versionRange>
</requirement>
... more rcp-only dependencies
</extraRequirements>
</dependency-resolution>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>target-rap</id>
<activation>
<property>
<name>target.platform</name>
<value>rap</value>
</property>
</activation>
<modules>
<module>../foo.fragment.rap</module>
<module>../foo.feature.rap</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tycho-version}</version>
<configuration>
... same as for RCP above, but for RAP
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
An this is the updatesite/category.xml
<?xml version="1.0" encoding="UTF-8"?>
<site>
<feature url="features/net.bar.foo.feature.rcp_0.31.0.qualifier.jar" id="net.bar.foo.feature.rcp" version="0.31.0.qualifier">
<category name="net.bar.rcp"/>
</feature>
<feature url="features/net.bar.foo.feature.rap_0.31.0.qualifier.jar" id="net.bar.foo.feature.rap" version="0.31.0.qualifier">
<category name="net.bar.rap"/>
</feature>
<category-def name="net.bar.rcp" label="RCP">
<description>
RCP Platform Features
</description>
</category-def>
<category-def name="net.bar.rap" label="RAP">
<description>
RAP Platform Features
</description>
</category-def>
</site>
And the updatesite/pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<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>
<parent>
<version>0.31.0-SNAPSHOT</version>
<relativePath>../foo.releng/pom.xml</relativePath>
<artifactId>foo</artifactId>
<groupId>net.bar</groupId>
</parent>
<artifactId>net.bar.foo.updatesite</artifactId>
<packaging>eclipse-repository</packaging>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-packaging-plugin</artifactId>
<version>${tycho-version}</version>
<configuration>
<archiveSite>true</archiveSite>
</configuration>
</plugin>
</plugins>
</build>
</project>
This question which concerns a very similar problem helped me to find a solution.
I succeded by configuring the tycho-packaging-plugin with a reproducible timestamp qualifier.
By using a constant version qualifier (based on the git commit ID) for all of my consecutive builds, the final repository build could resolve all referenced feature bundles correctly in the local maven repo.
After this adjustment the following build runs through without any problems and publishes a RAP and RCP feature flavor:
# build rcp target
cd foo/net.bar.foo.target.rcp
mvn clean install -Dmaven.repo.local=../../m2
# build rap target
cd ../net.bar.foo.target.rap
mvn clean install -Dmaven.repo.local=../../m2
# build features and plugins for rcp, then for rap
cd ../net.bar.foo.releng
mvn clean install -Dmaven.repo.local=../../m2 -Dtarget.platform=rcp
mvn clean install -Dmaven.repo.local=../../m2 -Dtarget.platform=rap
# build p2 repository
cd ../net.bar.foo.updatesite
mvn clean install -Dmaven.repo.local=../../m2 -Dtarget.platform=rap
Voilà:

why plugin built via Tycho working with JDT but not CDT

I am so frustrated when trying to find out the reason why the Eclipse plugin I built via Tycho is not working in CDT, but working in JDT.
The parent pom.xml looks like the following:
<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>com.company.eclipse.plugin</groupId>
<artifactId>abc-master</artifactId>
<version>1.0.0</version>
<name>abc Master</name>
<packaging>pom</packaging>
<modules>
<module>../abc</module>
</modules>
<properties>
<tycho.version>0.20.0</tycho.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<kepler-repo.url>http://download.eclipse.org/releases/kepler</kepler-repo.url>
</properties>
<repositories>
<repository>
<id>kepler</id>
<url>${kepler-repo.url}</url>
<layout>p2</layout>
</repository>
<repository>
<id>cdt</id>
<url>http://download.eclipse.org/tools/cdt/releases/kepler</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>
<pomDependencies>consider</pomDependencies>
<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>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>p2-composite</outputDirectory>
<resources>
<resource>
<directory>p2-composite-template</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
And the pom for abc plugin looke like the following
<?xml version="1.0" encoding="UTF-8"?>
<project>
<modelVersion>4.0.0</modelVersion>
<parent>
<relativePath>../abc-master/pom.xml</relativePath>
<groupId>com.company.eclipse.plugin</groupId>
<artifactId>abc-master</artifactId>
<version>1.0.0</version>
</parent>
<artifactId>com.company.eclipse.plugin.abc</artifactId>
<packaging>eclipse-plugin</packaging>
</project>
Any help is most appreciated.
thanks a lot for helping me. I suspect it is due to the Eclipse for C/C++ is somehow corrupted. So I download a new CDT, and copy the files from the new CDT to old CDT folder by folder, and try start the old CDT to see if the plugin works. After I replaced the "configuration" folder using new downloaded copy, the plugin works. So means something in the configuration folder in the old CDT prevent the plugin from starting. Unfortunately I forgot to backup the old CDT, so now I am not able to re-product the issue to investigate what is wrong in configuration folder.
Closed as cannot reproduce

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>

How to add the plugin with my RCP application in the Tycho SWTBot test runtime

My RCP was created on a 3.x Eclipse and is now on 4.x using the compatibility layer.
This is the setup that I have: I have two plugins: xyz-plugin and xyz-rcp-plugin. My RCP application is composed of these two plugins. I have a Test fragment (xyz-test) whose host plugin is xyz-plugin and contains SWTBot tests. My product configuration points to the application defined in the plugin.xml of xyz-rcp-plugin.
When I run the SWTBot Test via Eclipse, it all works ok. I point it to the correct application on the Main tab and it launches the correct one.
When I try to run it via Maven (using mvn integration-test), after the command to launch the UI for testing, no UI opens and it just reports saying there are test failures but it never actually even reaches the stage for testing my cases.
I feel this is happening because my test fragment only has xyz-plugin as its host and so knows its dependency but the application is actually contained in xyz-rcp-plugin so I am guessing it doesn't bring that plugin into the testing workspace. In fact, the test runs when I omit the <application> configuration in my pom file; it simple launches the default which is the Eclipse SDK.
So but how can I make the SWTBot test run my application, if the plugin with the application is not a dependency of the test plugin?
Below is my pom file for the test fragment,
<?xml version="1.0" encoding="UTF-8"?>
<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>
<parent>
<groupId>com.xyz</groupId>
<artifactId>all</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>com.xyz.test</artifactId>
<packaging>eclipse-test-plugin</packaging>
<properties>
<ui.test.vmargs></ui.test.vmargs>
</properties>
<profiles>
<profile>
<id>macosx</id>
<activation>
<os>
<family>mac</family>
</os>
</activation>
<properties>
<ui.test.vmargs>-XstartOnFirstThread</ui.test.vmargs>
</properties>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-surefire-plugin</artifactId>
<version>${tycho-version}</version>
<configuration>
<useUIHarness>true</useUIHarness>
<useUIThread>false</useUIThread>
<product>com.xyz.rcp.product</product>
<application>com.xyz.rcp.Application</application>
<argLine>${ui.test.vmargs}</argLine>
<dependencies>
<dependency>
<!-- explicit dependency is only needed because SWTbot brings its
own hamcrest bundle which conflicts with the one from junit in the eclipse
platform -->
<type>p2-installable-unit</type>
<artifactId>org.hamcrest</artifactId>
<version>0.0.0</version>
</dependency>
</dependencies>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack-xyz</id>
<phase>compile</phase>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<configuration>
<excludeTransitive>true</excludeTransitive>
<includeTypes>tar.gz</includeTypes>
<outputDirectory>${project.build.directory}/work</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Tycho does not automatically add the bundle defining the configured <application> to the test runtime - you need to manually ensure that this bundle is included.
One way to do this is to specify extra dependencies in the pom.xml of the test project. In this way, you can add bundles or even entire features (as always, including transitive dependencies) to the test runtime.
Example pom.xml snippet:
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tycho-version}</version>
<configuration>
<dependency-resolution>
<extraRequirements>
<requirement>
<type>eclipse-plugin</type>
<id>xyz-rcp-plugin</id>
<versionRange>0.0.0</versionRange>
</requirement>
</extraRequirements>
</dependency-resolution>
</configuration>
</plugin>

Dependencies from pom.xml not considered by Eclipse in Tycho Project

I created a Tycho project with an eclipse-plugin packaging. The project includes some dependencies that are specified via pom.xml. The relevant pom sections are:
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<tycho.version>0.15.0</tycho.version>
</properties>
<build>
<sourceDirectory>src</sourceDirectory>
<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>
<pomDependencies>consider</pomDependencies>
<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>
<repositories>
<repository>
<id>juno</id>
<layout>p2</layout>
<url>http://download.eclipse.org/releases/juno</url>
</repository>
<repository>
<id>com.springsource.repository.bundles.release</id>
<name>SpringSource Enterprise Bundle Repository - SpringSource Bundle Releases</name>
<url>http://repository.springsource.com/maven/bundles/release</url>
</repository>
<repository>
<id>com.springsource.repository.bundles.external</id>
<name>SpringSource Enterprise Bundle Repository - External Bundle Releases</name>
<url>http://repository.springsource.com/maven/bundles/external</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>com.springsource.org.testng</artifactId>
<version>6.4.0</version>
</dependency>
<dependency>
<groupId>com.google.guice</groupId>
<artifactId>com.springsource.com.google.inject</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>org.aopalliance</groupId>
<artifactId>com.springsource.org.aopalliance</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
And the Manifest is:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Plugin-project-pure
Bundle-SymbolicName: plugin-project-pure
Bundle-Version: 1.0.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Require-Bundle: org.eclipse.equinox.app,
org.eclipse.uml2.uml;bundle-version="4.0.0",
org.eclipse.uml2.uml.resources;bundle-version="4.0.0",
org.junit;bundle-version="4.10.0",
com.springsource.org.testng;bundle-version="[6.4.0,6.4.0]"
The project only consists of a class in the default package that uses an annotation from org.testng.annotations to test that during compilation the dependency is included.
If I'm building the project on the command line with Maven 3.0.4 everything works fine. After importing the project in Eclipse Juno, I get multiple errors. The most important one is in the manifest and it states that the bundle com.springsource.org.testng can't be resolved. There is also a compile error in the class, because the import of the annotation is not possible. The project has the Maven Nature configured. Am I missing something so that Eclipse Juno will also consider the dependencies of the pom?
You can circumvent this problem splitting your project build into two parts:
First, aggregate your POM dependencies into a p2 repository. You'll need an eclipse-feature and an eclipse-repository module for this, plus a separate parent POM that lists the POM dependencies and configures pomDependencies=consider.
In the second build, add the p2 repository from the first build to the target platform, e.g. via a jar:file: URL pointing to the build result in your local Maven repository.
Then, you can also configure your target platform in Eclipse to include the p2 repository from the first build (which depends on how you currently configure it). You'll get the best consistency between Tycho and Eclipse if you use a so-called target definition file, which you can use both as target platform in Eclipse and in Tycho.
I am aware that all this is quite a bit of effort to set up, but AFAIK there are no better solutions that fully work.
The most elegant solution to all problems that exist between maven-RCP problems is to use the
p2-maven-plugin. Here is the brief summary of those problems (cuts from the link above):
In order to add a third-party dependency to an Eclipse RCP project the
dependency has to reside in a P2 update site.
Eclipse (and other providers) provide a set of public update sites,
but obviously not all popular and publicly available dependencies are
there (that is the problem number #1).
Since Eclipse RCP is an OSGi environment in order to add a dependency
to a p2 update site the depenedncy has to be an OSGi bundle (that is
the problem number #2).
So, let’s sum up for now: all our artifacts have to be OSGi bundles,
but they are not always bundles and they have to be located in a P2
site, but we do not have that site. How do we proceed then?
It is not that difficult, there is a ‘bnd’ tool written by Peter
Kriens that can transform your jars into bundles. There is also a
convenience tool provided by Eclipse RCP that can generate a P2 site
(in a cumbersome and painful way though). Both tools assume that all
your jars/bundles are located in a local folder - which means that you
have to download them by-hand. You could use Maven to automate it a
bit, but there is a significant difference in the way how Maven
calculates a dependency tree and this is not alwyas compatible with
the OSGi way (that is the problem number #3). Let us elaborate on it a
bit more.
It allows you to define a pom-packaged project that will resolve all maven dependencies, convert all non-OSGi ones to bundles and generate a p2 site from them.
Below is the full minimal pom file including the dependency on slf4j-log4j12 (which implicitly depends on both slf4j and log4j v1.2):
<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>me.berezovskiy.project</groupId>
<artifactId>p2</artifactId>
<packaging>pom</packaging>
<version>1.0.0</version>
<build>
<plugins>
<plugin>
<groupId>org.reficio</groupId>
<artifactId>p2-maven-plugin</artifactId>
<version>1.1.1-SNAPSHOT</version>
<executions>
<execution>
<id>default-cli</id>
<configuration>
<artifacts>
<artifact>
<id>org.slf4j:slf4j-log4j12:1.7.7</id>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>8.1.12.v20130726</version>
<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
<webAppSourceDirectory>${basedir}/target/repository/</webAppSourceDirectory>
<webApp>
<contextPath>/site</contextPath>
</webApp>
</configuration>
</plugin>
</plugins>
</build>
<pluginRepositories>
<pluginRepository>
<id>reficio</id>
<url>http://repo.reficio.org/maven/</url>
</pluginRepository>
</pluginRepositories>
</project>
P.S. I usually do not post answers to old and answered questions, but in my case it took so long to resolve this issue in a clean and elegant way that I decided to write about it. Additionally, the solution has appeared in late 2013.
from the command line navigate to the folder where the pom.xml is located.
Run mvn eclipse:eclipse.
This should build a valid eclipse project.