in src/java/org/apache/ivy/osgi/core/BundleInfoAdapter.java [89:179]
public static DefaultModuleDescriptor toModuleDescriptor(ModuleDescriptorParser parser,
URI baseUri, BundleInfo bundle, Manifest manifest,
ExecutionEnvironmentProfileProvider profileProvider) throws ProfileNotFoundException {
DefaultModuleDescriptor md = new DefaultModuleDescriptor(parser, null);
md.addExtraAttributeNamespace("o", Ivy.getIvyHomeURL() + "osgi");
ModuleRevisionId mrid = asMrid(BundleInfo.BUNDLE_TYPE, bundle.getSymbolicName(),
bundle.getVersion());
md.setResolvedPublicationDate(new Date());
md.setModuleRevisionId(mrid);
md.addConfiguration(CONF_DEFAULT);
md.addConfiguration(CONF_OPTIONAL);
md.addConfiguration(CONF_TRANSITIVE_OPTIONAL);
Set<String> exportedPkgNames = new HashSet<>(bundle.getExports().size());
for (ExportPackage exportPackage : bundle.getExports()) {
md.getExtraInfos().add(
new ExtraInfoHolder(EXTRA_INFO_EXPORT_PREFIX + exportPackage.getName(),
exportPackage.getVersion().toString()));
exportedPkgNames.add(exportPackage.getName());
String[] confDependencies = new String[exportPackage.getUses().size() + 1];
int i = 0;
for (String use : exportPackage.getUses()) {
confDependencies[i++] = CONF_USE_PREFIX + use;
}
confDependencies[i] = CONF_NAME_DEFAULT;
md.addConfiguration(new Configuration(CONF_USE_PREFIX + exportPackage.getName(),
PUBLIC, "Exported package " + exportPackage.getName(),
confDependencies, true, null));
}
requirementAsDependency(md, bundle, exportedPkgNames);
if (baseUri != null) {
for (BundleArtifact bundleArtifact : bundle.getArtifacts()) {
String type = "jar";
String ext = "jar";
String packaging = null;
if (bundle.hasInnerClasspath() && !bundleArtifact.isSource()) {
packaging = "bundle";
}
if ("packed".equals(bundleArtifact.getFormat())) {
ext = "jar.pack.gz";
if (packaging != null) {
packaging += ",pack200";
} else {
packaging = "pack200";
}
}
if (bundleArtifact.isSource()) {
type = "source";
}
URI uri = bundleArtifact.getUri();
if (uri != null) {
DefaultArtifact artifact = buildArtifact(mrid, baseUri, uri, type, ext,
packaging);
md.addArtifact(CONF_NAME_DEFAULT, artifact);
}
}
}
if (profileProvider != null) {
for (String env : bundle.getExecutionEnvironments()) {
ExecutionEnvironmentProfile profile = profileProvider.getProfile(env);
if (profile == null) {
throw new ProfileNotFoundException("Execution environment profile " + env
+ " not found");
}
for (String pkg : profile.getPkgNames()) {
ArtifactId id = new ArtifactId(ModuleId.newInstance(BundleInfo.PACKAGE_TYPE,
pkg), PatternMatcher.ANY_EXPRESSION, PatternMatcher.ANY_EXPRESSION,
PatternMatcher.ANY_EXPRESSION);
DefaultExcludeRule rule = new DefaultExcludeRule(id,
ExactOrRegexpPatternMatcher.INSTANCE, null);
for (String conf : md.getConfigurationsNames()) {
rule.addConfiguration(conf);
}
md.addExcludeRule(rule);
}
}
}
if (manifest != null) {
for (Map.Entry<Object, Object> entries : manifest.getMainAttributes().entrySet()) {
md.addExtraInfo(new ExtraInfoHolder(entries.getKey().toString(), entries.getValue()
.toString()));
}
}
return md;
}