0

Inside a OSGi bundle I'm trying to remove the *;resolution=optional and specify the specific imports. When I check at the run time imports are like follows

org.apache.catalina.valves; version="8.0.20",
org.apache.catalina.util; version="8.0.20",
org.apache.catalina.session; version="8.0.20",
org.apache.catalina.realm; version="8.0.20",
org.apache.catalina.core; version="8.0.20",
org.apache.catalina.connector; version="8.0.20",
org.apache.catalina.authenticator; version="8.0.20",
org.apache.catalina; version="8.0.20",
org.apache.catalina.tribes; version="0.0.0"<unwired><optional>
org.apache.catalina.tribes.group; version="0.0.0"<unwired><optional>
org.apache.catalina.tribes.group.interceptors; version="0.0.0"<unwired><optional>
org.apache.catalina.tribes.io; version="0.0.0"<unwired><optional>
org.apache.catalina.tribes.tipis; version="0.0.0"version="0.0.0"<unwired><optional>

Can I reduce this like this?

<Import-Package>
    org.apache.catalina.*;version="8.0.20",
    org.apache.catalina.tribes.*;resolution:=optional,
</Import-Package>

Is this a good practice?

When I build the jar with later configuration, still in the MANIFEST file it shows resolution=optional next to the packages

Edited

Dependency section

<dependencies>
        <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>tomcat-catalina-ha</artifactId>
            <version>8.0.20</version>
            <optional>true</optional>
        </dependency>
</dependencies>

1 Answers1

2

You can not use * in the Manifest but you can use the maven-bundle-plugin and in its configurations * is possible.

In maven-bundle-plugin you normally do not have to specify your imports by hand at all. The plugin scans for used packages and configures the import package statements including standard version ranges. If your maven dependency is optional it will also use the optional flag.

Christian Schneider
  • 19,420
  • 2
  • 39
  • 64