Let’s take Micrometer: https://mvnrepository.com/artifact/io.micrometer/micrometer-core/1.12.0
- Micrometer specifies lots of
DynamicImport-Package
s because it supports all kinds of systems in the world
- unfortunately no all bundles of Micrometer are valid OSGI bundles so I decided to wrap them in an own bundle via -includeresource with lib option:
-includeresource: \
${repo;io.micrometer:micrometer-core;latest}; lib:=true,\
${repo;io.micrometer:micrometer-commons;latest}; lib:=true,\
${repo;io.micrometer:micrometer-observation;latest}; lib:=true,\
${repo;io.micrometer:context-propagation;latest}; lib:=true,\
This creates mybundle.jar
with mandatory Import-Packages
like this, basically requiring the whole world.
The Resolver then says “Nooooo”.
To make the resolver happy and start my app I ended up with excluding everything we don’t use:
Version A
Import-Package: \
com.codahale.*;resolution:=optional,\
com.mongodb.*;resolution:=optional,\
com.netflix.*;resolution:=optional,\
io.grpc.*;resolution:=optional,\
javax.annotation.meta;resolution:=optional,\
javax.cache.*;resolution:=optional,\
kotlinx.*;resolution:=optional,\
net.sf.*;resolution:=optional,\
org.HdrHistogram.*;resolution:=optional,\
org.LatencyUtils.*;resolution:=optional,\
org.apache.catalina.*;resolution:=optional,\
org.apache.hc.*;resolution:=optional,\
org.apache.kafka.*;resolution:=optional,\
org.apache.logging.log4j.*;resolution:=optional,\
org.aspectj.*;resolution:=optional,\
org.bson.*;resolution:=optional,\
org.glassfish.*;resolution:=optional,\
org.hibernate.*;resolution:=optional,\
org.jooq.*;resolution:=optional,\
*
Alternatively I could have made everything optional:
Version B
Import-Package: \
*;resolution:=optional,\
Questions:
Is there another way?
Option A took me lots of trial and error.
Option B is a wildcard with less trial and error, but I guess at the cost that the resolver has more work todo.
Would it (theoretically) make sense that ${repo;io.micrometer:micrometer-core;latest}; lib:=true
would treat all packages as if they were;resolution:=optional
which are a DynamicImport-Package
in micrometer:micrometer-core
?
Or is there already some macro?
Or am I doing stupid stuff?