I’ve just started using this and am wondering how to handle the following situation. We have a number of instances where in a project’s build.gradle we do something like this:
jar {
from (zipTree(file(‘foo-stuff.jar’))) {
exclude ‘bar/**’
exclude ‘META-INF/INDEX.LIST’
exclude ‘META-INF/MANIFEST.MF’
} }
However, when I do this to a project where the apply plugin: ‘bundle’ has been done, all I get in the jar is the manifest generated by bnd. How do I handle this?
I’ve tried the plugin posted by Simon, and while I truly appreciate the effort, my conclusion on using it for a few days is that it will require far too many changes to our build because of its use of bnd for creating the jar. The example I posted 3 days ago is just one of the cases. There are numerous others where it’s a force-fit to transform jar closures into bnd instructions and get what we need. In some cases I couldn’t get the jar contents to be complete.
I have around 90 modules that I need to generate, so its a significant effort to get this right using our existing gradle build (of 500+ modules).
I’d like to see the gradle folks work with Peter as they tried to do some months ago to improve upon, or replace the gradle osgi plugin so that this can be accomplished in a style that is more in concert with the existing jar task but does not circumvent the bnd tool analysis.
If Simon’s tool could do that instead, that’s fine too
Unfortunately we don’t have any capacity on our side to take this on over the coming months. I think it would be better for OSGi Gradle users to build something outside of Gradle core. We just don’t have the OSGi experience, use cases, or resources to do this properly.
The existing OSGi plugin is one of the oldest Gradle plugins. My opinion is that the best thing to do here would be to start again.
If you like, you can try out this similar plugin: https://github.com/jruyi/osgibnd-gradle-plugin. Your problem should be able to be solved by configuring those in task processResources. The jar foo-stuff.jar will be unpacked into the resource dest dir.
Thanks, Agemo. I ended up writing my own plugin, while not as general as yours, meets our needs for now. If we need more in the future I’ll take a look at yours. I appreciate it.