问题
Currently, to set up configuration for Pax Exam, I find that I need to include all dependencies. E.g. something like
@Configuration
public Option[] сonfig() {
MavenArtifactProvisionOption commonsDbcp = mavenBundle("commons-dbcp",
"commons-dbcp");
MavenArtifactProvisionOption commonsPool = mavenBundle("commons-pool",
"commons-pool");
...
return options(
felix(),
provision(commonsDbcp, commonsPool));
}
But since commons-dbcp
depends on commons-pool
, this feels like duplicate information. Is it possible for Pax Exam to figure out that commons-dbcp
is needed without adding it explicitly?
回答1:
Not really...
- Not every Maven dependency of an OSGi bundle is an OSGi bundle.
- A dependency may be an interface-only, and at run-time, you want to provision an implementation bundle instead.
Listing all bundles explicitly is the only safe way of provisioning your framework. At least, you can use the versionAsInPom() option method to avoid duplicating the artifact versions.
来源:https://stackoverflow.com/questions/10312102/pax-exam-provisioning-bundle-with-all-dependencies