You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by rf...@apache.org on 2009/06/18 22:44:42 UTC

svn commit: r786257 - /tuscany/maven-plugins/trunk/maven-bundle-plugin/src/main/java/org/apache/tuscany/maven/bundle/plugin/ModuleBundlesBuildMojo.java

Author: rfeng
Date: Thu Jun 18 20:44:41 2009
New Revision: 786257

URL: http://svn.apache.org/viewvc?rev=786257&view=rev
Log:
Add the support to override 3rd party bundles as plain jars

Modified:
    tuscany/maven-plugins/trunk/maven-bundle-plugin/src/main/java/org/apache/tuscany/maven/bundle/plugin/ModuleBundlesBuildMojo.java

Modified: tuscany/maven-plugins/trunk/maven-bundle-plugin/src/main/java/org/apache/tuscany/maven/bundle/plugin/ModuleBundlesBuildMojo.java
URL: http://svn.apache.org/viewvc/tuscany/maven-plugins/trunk/maven-bundle-plugin/src/main/java/org/apache/tuscany/maven/bundle/plugin/ModuleBundlesBuildMojo.java?rev=786257&r1=786256&r2=786257&view=diff
==============================================================================
--- tuscany/maven-plugins/trunk/maven-bundle-plugin/src/main/java/org/apache/tuscany/maven/bundle/plugin/ModuleBundlesBuildMojo.java (original)
+++ tuscany/maven-plugins/trunk/maven-bundle-plugin/src/main/java/org/apache/tuscany/maven/bundle/plugin/ModuleBundlesBuildMojo.java Thu Jun 18 20:44:41 2009
@@ -20,6 +20,7 @@
 
 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 @@
                     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<File> jarFiles = new HashSet<File>();
+                    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 @@
                     }
                     ps.print("    ");
                     ps.print(f);
+                    // FIXME: We should not add @start for fragments
                     if (generateBundleStart) {
                         ps.print("@:start");
                     }