From a0a6a865e02dc43ef5e02a6e6fa4c906c60fd9a9 Mon Sep 17 00:00:00 2001 From: rfeng Date: Thu, 18 Jun 2009 20:44:41 +0000 Subject: Add the support to override 3rd party bundles as plain jars git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@786257 13f79535-47bb-0310-9956-ffa450edef68 --- .../bundle/plugin/ModuleBundlesBuildMojo.java | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'maven-plugins/trunk/maven-bundle-plugin/src/main/java/org/apache/tuscany/maven/bundle/plugin/ModuleBundlesBuildMojo.java') diff --git a/maven-plugins/trunk/maven-bundle-plugin/src/main/java/org/apache/tuscany/maven/bundle/plugin/ModuleBundlesBuildMojo.java b/maven-plugins/trunk/maven-bundle-plugin/src/main/java/org/apache/tuscany/maven/bundle/plugin/ModuleBundlesBuildMojo.java index a13734e316..7e9d0faea0 100644 --- a/maven-plugins/trunk/maven-bundle-plugin/src/main/java/org/apache/tuscany/maven/bundle/plugin/ModuleBundlesBuildMojo.java +++ b/maven-plugins/trunk/maven-bundle-plugin/src/main/java/org/apache/tuscany/maven/bundle/plugin/ModuleBundlesBuildMojo.java @@ -20,6 +20,7 @@ package org.apache.tuscany.maven.bundle.plugin; import static org.apache.tuscany.maven.bundle.plugin.BundleUtil.write; import static org.osgi.framework.Constants.BUNDLE_CLASSPATH; +import static org.osgi.framework.Constants.BUNDLE_VERSION; import java.io.File; import java.io.FileInputStream; @@ -323,6 +324,28 @@ public class ModuleBundlesBuildMojo extends AbstractMojo { is.close(); getLog().info("MANIFEST.MF found for " + artifact + " (" + mf + ")"); return manifest; + } else { + getLog().info("Overriding the manifest for "+artifact); + Manifest manifest = BundleUtil.getManifest(artifact.getFile()); + Set jarFiles = new HashSet(); + jarFiles.add(artifact.getFile()); + String symbolicName = BundleUtil.getBundleSymbolicName(manifest); + if (symbolicName == null) { + // Not a bundle + continue; + } + String version = manifest.getMainAttributes().getValue(BUNDLE_VERSION); + manifest = + BundleUtil.libraryManifest(jarFiles, + symbolicName, + symbolicName, + version, + null, + this.eclipseBuddyPolicy, + this.executionEnvironment); + // Remove it as it will be added later on + manifest.getMainAttributes().remove(new Attributes.Name(BUNDLE_CLASSPATH)); + return manifest; } } } @@ -761,6 +784,7 @@ public class ModuleBundlesBuildMojo extends AbstractMojo { } ps.print(" "); ps.print(f); + // FIXME: We should not add @start for fragments if (generateBundleStart) { ps.print("@:start"); } -- cgit v1.2.3