Closed juergen-albert closed 3 years ago
It seems good in the end. The only strange thing is that I already have
pluginsService.org.osgi.framework.system.packages.extra=com.mornati.sample.commons.plugins,com.mornati.sample.commons.plugins.dto
In the application.properties. That it should be conflicting with what you add. If I remove it plugins are not working.... but keeping that line everything is fine and the Bundle is not containing the SLF4j. Seems great... but not sure I understand what is happening :)
Might be a good idea, how the list I produce looks like. As I said, I never tested the code. It actually should already contain your packages and if I read it right, my property would overwrite the one from your settings.
Quite crazy in the end, the IDE is saying that the felixProperties is init but never used 😳
Map<String, String> felixProperties = new HashMap<>(felixConfiguration.getPluginsService());
felixProperties.put("org.osgi.framework.system.packages.extra", findPackageNamesStartingWith());
So how it can work right now without the slf4j inside ? 😩 Going to make some other test to understand
It seems the real fix was the removed configuration in the bnd maven plugin. As you said, it scan the source code to find what to add... and it is adding automatically the correct SLF4J package.
It is even simpler than what I could imagine.
The result MANIFEST.MF
file
Import-Package: com.mornati.sample.commons.plugins,com.mornati.sample.
commons.plugins.dto,java.lang,org.slf4j;version="[1.7,2)"
Private-Package: com.mornati.sample.plugin.psp.scr
Provide-Capability: osgi.service;objectClass:List<String>="com.mornati
.sample.commons.plugins.IPlugin";uses:="com.mornati.sample.commons.pl
ugins"
Require-Capability: osgi.extender;filter:="(&(osgi.extender=osgi.compo
nent)(version>=1.3.0)(!(version>=2.0.0)))",osgi.ee;filter:="(&(osgi.e
e=JavaSE)(version=15))"
You made my day man. Thanks a lot !!
This I couldn't really test, but it demonstrates how you can provide classes and dependencies spring boot brings along to any bundle installed in the felix framework.
If you want to see how classloading in osgi works, you find a nice diagram here: https://docs.osgi.org/specification/osgi.core/7.0.0/framework.module.html#framework.module.overallsearchorder
Signed-off-by: Jürgen Albert j.albert@data-in-motion.biz