Optional resolution for imports from inlined jars

231 views
Skip to first unread message

arjen

unread,
Aug 6, 2012, 8:29:23 AM8/6/12
to bndtool...@googlegroups.com
Hi all,

I'm inlining some jars into a bundle using the pattern "Include-Resource: @jar1,@jar2". Those jars have some dependencies that are now included in the "Import-Package" section of the generated manifest of the created bundle. These imports are now enforced when I try to resolve the "Run-Requirements" for this bundle with BndTools. However, for backward compatibility reasons (this bundle used to be a non-OSGi jar before) I do not want these imports to be enforced.
I know their resolution can be made optional by adding ";resolution=optional" to the "Import-Package' entry, but for this I would have to post-process the generated manifest in the jar created by bnd, which I'd rather not do. Does a possibility exist to annotate "Include-Resource" entries so that imports coming from these inlined jars are automatically tagged with ";resolution=optional"?
Thank you very much in advance!

Best regards,
Arjen

arjen

unread,
Aug 6, 2012, 8:39:42 AM8/6/12
to bndtool...@googlegroups.com
Ehm, typo, ";resolution=optional" should of course be ";resolution:=optional".

Peter Kriens

unread,
Aug 6, 2012, 9:11:03 AM8/6/12
to bndtool...@googlegroups.com

Import-Package: com.notimport.*;resolution:=optional, *

You can also remove the imports:

Import-Package: !com.notimport.*, *

Don't forget to terminate with a *, the default is Import-Package: *.

Kind regards,

Peter Kriens

arjen

unread,
Aug 6, 2012, 9:56:32 AM8/6/12
to bndtool...@googlegroups.com
Hello Peter,

Thank you for your reply.
This is a good solution for specific cases (when the imports are known). What I forgot to tell was that my case would need a generic solution. The bundle I'm generating (automatically) will be different depending on the project and the jars to embed will also differ. So the imports are not known beforehand. Is there a way to reference the imports for a certain jar in a bnd-file or does this require some preprocessing of this jar?

Thanks again,
Arjen

Peter Kriens

unread,
Aug 7, 2012, 8:12:27 AM8/7/12
to bndtool...@googlegroups.com
Well, you can always do Import-Package: *;resolution:=optional

Putting this information in a bnd file is highly recommended, if you use bndtools you even get a nice GUI and the JAR Import/Export view is unbeatable to get a feeling for your jars.

Kind regards,

Peter Kriens

arjen

unread,
Aug 8, 2012, 10:39:10 AM8/8/12
to bndtool...@googlegroups.com
Ah, yes, that will work, thanks! This will make some imports optional which should be required, but backward compatibility is more important for now. The users of our platform will not develop in OSGi-style for now anyway. We can always make it more strict in the future.
I really like the way I can use wild cards in bnd-files and that I don't have to come up with all the Import-Package entries myself. Bndtools is great for development in Eclipse, thank you guys for making those products!

Best regards,
Arjen 
Reply all
Reply to author
Forward
0 new messages