You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by ge...@apache.org on 2008/09/29 15:28:31 UTC

svn commit: r700126 - /servicemix/maven-plugins/features-maven-plugin/trunk/src/main/java/org/apache/servicemix/tooling/features/GenerateFeaturesXmlMojo.java

Author: gertv
Date: Mon Sep 29 06:28:30 2008
New Revision: 700126

URL: http://svn.apache.org/viewvc?rev=700126&view=rev
Log:
SMX4-49: Looking at the OSGi imports for determining the bundles to use

Modified:
    servicemix/maven-plugins/features-maven-plugin/trunk/src/main/java/org/apache/servicemix/tooling/features/GenerateFeaturesXmlMojo.java

Modified: servicemix/maven-plugins/features-maven-plugin/trunk/src/main/java/org/apache/servicemix/tooling/features/GenerateFeaturesXmlMojo.java
URL: http://svn.apache.org/viewvc/servicemix/maven-plugins/features-maven-plugin/trunk/src/main/java/org/apache/servicemix/tooling/features/GenerateFeaturesXmlMojo.java?rev=700126&r1=700125&r2=700126&view=diff
==============================================================================
--- servicemix/maven-plugins/features-maven-plugin/trunk/src/main/java/org/apache/servicemix/tooling/features/GenerateFeaturesXmlMojo.java (original)
+++ servicemix/maven-plugins/features-maven-plugin/trunk/src/main/java/org/apache/servicemix/tooling/features/GenerateFeaturesXmlMojo.java Mon Sep 29 06:28:30 2008
@@ -30,6 +30,7 @@
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
+import java.util.Properties;
 import java.util.Set;
 import java.util.Stack;
 import java.util.zip.ZipEntry;
@@ -108,15 +109,11 @@
      */
     private Map<String, Map<VersionRange, Artifact>> bundleExports = new HashMap<String, Map<VersionRange, Artifact>>();
 
-    private String[] systemExports = {"javax.crypto", "javax.crypto.spec", "javax.management", "javax.management.loading",
-                                      "javax.management.modelmbean", "javax.management.monitor", "javax.management.remote",
-                                      "javax.net", "javax.net.ssl", "javax.security.cert", "javax.sql", "javax.naming",
-                                      "javax.naming.spi", "javax.xml.bind.annotation", "javax.xml.namespace", "javax.xml.parsers",
-                                      "javax.xml.stream", "javax.xml.transform", "javax.xml.transform.dom",
-                                      "javax.xml.transform.sax", "javax.xml.transform.stream", "javax.xml.validation",
-                                      "javax.xml.xpath", "org.osgi.framework", "org.w3c.dom", "org.xml.sax", "org.xml.sax.ext",
-                                      "org.xml.sax.helpers"};
-
+    /*
+     * The set of system exports
+     */
+    private List<String> systemExports = new LinkedList<String>();
+    
     /*
      * These bundles are the features that will be built
      */
@@ -126,6 +123,7 @@
         PrintStream out = null;
         try {
             out = new PrintStream(new FileOutputStream(outputFile));
+            readSystemPackages();
             readKernelBundles();
             readBundles();
             writeFeatures(out);
@@ -141,6 +139,20 @@
         }
     }
 
+    private void readSystemPackages() throws IOException {
+        Properties properties = new Properties();
+        properties.load(getClass().getClassLoader().getResourceAsStream("config.properties"));
+        readSystemPackages(properties, "jre-1.5");
+        readSystemPackages(properties, "osgi");
+    }
+
+    private void readSystemPackages(Properties properties, String key) {
+        String packages = (String) properties.get(key);
+        for (String pkg : packages.split(";")) {
+            systemExports.add(pkg.trim());
+        }
+    }
+
     /*
      * Download a Kernel distro and check the list of bundles provided by the Kernel
      */
@@ -322,10 +334,8 @@
         }
         // remove imports for packages exported by the system bundle
         for (ManifestEntry entry : input) {
-            for (String export : systemExports) {
-                if (entry.getName().equals(export)) {
-                    output.remove(entry);
-                }
+            if (systemExports.contains(entry.getName())) {
+                output.remove(entry);
             }
         }
         return output;
@@ -388,10 +398,10 @@
             while (!artifacts.isEmpty()) {
                 Artifact next = artifacts.pop();
                 if (isFeature(next)) {
-                    out.println(String.format("    <feature>%s</feature>", artifact.getArtifactId()));
+                    out.println(String.format("    <feature>%s</feature>", next.getArtifactId()));
                 } else {
-                    out.println(String.format("    <bundle>mvn:%s/%s/%s</feature>", 
-                                              artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion()));
+                    out.println(String.format("    <bundle>mvn:%s/%s/%s</bundle>", 
+                                              next.getGroupId(), next.getArtifactId(), next.getBaseVersion()));
                 }
             }
             out.println("  </feature>");