1

I'm working one an Eclipse RCP project. Currently we create a dependencies plug-in project and put all jars libraries into that project and export all packages. This method will give a huge repo, thus we want to use Tycho/Maven and let it figure out the dependencies for us.

The first approach is removing dependenciec project and use p2-maven-pluging to transform existing jars libraries to p2 format repo. Install all libraries from p2 repos and add required bundle in Require-Bundle section in each MANIFEST.MF. This is a little bit tedious since in every project having dependencies in Require-Bundle, I have to manually replace it to corresponding bundle names. And in the end, the project build using Tycho could successfully run, but in Eclipse it gives me java.lan.NoClassDefFoundError: Could not initialize class X.

I think there are few configuration files, where Tycho depends on some of them and Eclipse depends on the rest, but I'm not sure what it is.

The second approach is removing all jars in dependencies project but adding them in Require-Bundle or Import-Package. However, both won't work since in Export-Package section Eclipse will complain these packages are not existed. Thus other projects depends on this dependencies project won't find those packages they need, which causing more errors in Eclipse.

Does anyone know the best practice to deal with this issue?


Update:

I'm using basically the first approach, but add dependencies in Import-Package in each project instead of Require-Bundle. This would eliminate the need to specify the specific bundle version, as long as they provide the same API and they are compatible, your application would work. So everytimes I update private p2 repository, I don't need to change MANIFEST.MF in each project.

The only MANIFEST.MF I need to manually add dependencies in Require-Bundle is a library developed by our self. Without it, Tycho won't fetch required dependencies from private p2 repository. If still get NoClassDefFoundError, try adding all plugins in Run -> Run Configuration .. -> plug-ins, it may help.

Ray Wu
  • 993
  • 16
  • 34
  • What is the purpose of creating a project with all the dependent jars? Couldn't you use a feature.xml instead? – nbz Oct 15 '13 at 13:28
  • What you are describing is probably doable - but you are doing something wrong. However you description is so vague that we can only guess. Please add more details, e.g. MANIFESTS – oberlies May 09 '14 at 21:43

1 Answers1

0

I definitely not apply your approach 1, with the mega-plugin of exports. There's a related discussion here: Handling non-OSGi dependencies when integrating Maven, Tycho and Eclipse

As a rule, use Import-Package instead of Require-Bundle.

To get bundles will appear in the Export-Package section Eclipse:

  • if they are non-Eclipse (maven libraries), then build the project and reference the libraries in the Eclipse runtime section.
  • if they are Eclipse dependences, they should be in your workspace or Target Platform.

More generally, it may help for you to define a Target Platform. You can build/deploy all of your locally created plugins into a local p2 repository (see http://www.sonatype.org/nexus/). Then add that p2 site to your Target Platform.

Community
  • 1
  • 1
B. Robinson
  • 106
  • 1
  • 6