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.