Instrument OSGi plugin Import-Package sequential order


(Robert Saenger) #1

In the past I’ve sometimes included a

*;resolution:=optional

statement as last element of the Import-Package list. The intention was to have a fail-safe option for classes that are referenced via dynamic class loading and not always known at compile time or accidentally not explicitly specified.

I finally achieved to persuade the OSGi gradle plugin to use the star character by embracing it with single quotes, i.e.

jar {
    manifest {
  instruction 'Import-Package',
     '*',
     "'*';resolution:=optional"
 }
}

However, if I now look into the generated MANIFEST.MF file, the fail-safe option is listed at the beginning and not the end of all imported packages, i.e.

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

Now I’m afraid but not sure, that this first import takes precedence over the rest.

If that holds true, does anyone knows if it is possible to control the order of imported packages. I already tried to split the import instructions, but this didn’t help.

If there is no such option, would it than be possible to somehow post-process the generated MANIFEST file?


(Chandler Zhang) #2

Seems to be a bug in osgi plugin. As mentioned in http://forums.gradle.org/gradle/topics/the_osgi_plugin_has_several_flaws

number 5