ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hi...@apache.org
Subject svn commit: r1375592 - in /ant/ivy/core/trunk: src/java/org/apache/ivy/osgi/core/BundleInfo.java src/java/org/apache/ivy/osgi/core/ManifestParser.java test/java/org/apache/ivy/osgi/core/ManifestParserTest.java
Date Tue, 21 Aug 2012 14:58:21 GMT
Author: hibou
Date: Tue Aug 21 14:58:21 2012
New Revision: 1375592

URL: http://svn.apache.org/viewvc?rev=1375592&view=rev
Log:
Parse the Bundle-Classpath in an OSGi MANIFEST

Modified:
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/BundleInfo.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/ManifestParser.java
    ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/core/ManifestParserTest.java

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/BundleInfo.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/BundleInfo.java?rev=1375592&r1=1375591&r2=1375592&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/BundleInfo.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/BundleInfo.java Tue Aug 21 14:58:21
2012
@@ -76,6 +76,8 @@ public class BundleInfo {
 
     private boolean hasInnerClasspath;
 
+    private List/* <String> */classpath;
+
     public BundleInfo(String name, Version version) {
         this.symbolicName = name;
         this.version = version;
@@ -235,6 +237,14 @@ public class BundleInfo {
         return hasInnerClasspath;
     }
 
+    public void setClasspath(List/* <String> */classpath) {
+        this.classpath = classpath;
+    }
+
+    public List/* <String> */getClasspath() {
+        return classpath;
+    }
+
     public int hashCode() {
         final int prime = 31;
         int result = 1;
@@ -325,6 +335,13 @@ public class BundleInfo {
         if (hasInnerClasspath != other.hasInnerClasspath) {
             return false;
         }
+        if (classpath == null) {
+            if (other.classpath != null) {
+                return false;
+            }
+        } else if (!classpath.equals(other.classpath)) {
+            return false;
+        }
         return true;
     }
 

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/ManifestParser.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/ManifestParser.java?rev=1375592&r1=1375591&r2=1375592&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/ManifestParser.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/ManifestParser.java Tue Aug 21 14:58:21
2012
@@ -60,6 +60,8 @@ public class ManifestParser {
 
     private static final String BUNDLE_REQUIRED_EXECUTION_ENVIRONMENT = "Bundle-RequiredExecutionEnvironment";
 
+    private static final String BUNDLE_CLASSPATH = "Bundle-ClassPath";
+
     private static final String ECLIPSE_SOURCE_BUNDLE = "Eclipse-SourceBundle";
 
     private static final String ATTR_RESOLUTION = "resolution";
@@ -194,6 +196,12 @@ public class ManifestParser {
             }
         }
 
+        String bundleClasspath = mainAttributes.getValue(BUNDLE_CLASSPATH);
+        if (bundleClasspath != null) {
+            ManifestHeaderValue bundleClasspathValue = new ManifestHeaderValue(bundleClasspath);
+            bundleInfo.setClasspath(bundleClasspathValue.getValues());
+        }
+
         return bundleInfo;
     }
 

Modified: ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/core/ManifestParserTest.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/core/ManifestParserTest.java?rev=1375592&r1=1375591&r2=1375592&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/core/ManifestParserTest.java (original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/core/ManifestParserTest.java Tue Aug
21 14:58:21 2012
@@ -17,7 +17,12 @@
  */
 package org.apache.ivy.osgi.core;
 
+import java.io.IOException;
+import java.io.InputStream;
+import java.text.ParseException;
+import java.util.Arrays;
 import java.util.HashSet;
+import java.util.List;
 import java.util.Set;
 
 import junit.framework.TestCase;
@@ -44,6 +49,7 @@ public class ManifestParserTest extends 
         assertEquals(expectedRequires, bundleInfo.getRequires());
         assertEquals(0, bundleInfo.getExports().size());
         assertEquals(2, bundleInfo.getImports().size());
+        assertNull(bundleInfo.getClasspath());
 
         final String importsList = bundleInfo.getImports().toString();
         assertTrue(importsList.indexOf("com.acme.bravo") != -1);
@@ -66,6 +72,34 @@ public class ManifestParserTest extends 
         assertTrue(bundleInfo.getImports().toString().indexOf("com.acme.charlie") != -1);
     }
 
+    public void testClasspath() throws Exception {
+        InputStream in = this.getClass().getResourceAsStream(
+            "/org/apache/ivy/osgi/core/MANIFEST_classpath.MF");
+        BundleInfo bundleInfo;
+        try {
+            bundleInfo = ManifestParser.parseManifest(in);
+        } finally {
+            in.close();
+        }
+        List/* <String> */cp = bundleInfo.getClasspath();
+        assertNotNull(cp);
+        assertEquals(4, cp.size());
+        assertEquals(
+            Arrays.asList(new String[] {"lib/ant-antlr.jar", "lib/ant-apache-bcel.jar",
+                    "lib/ant-apache-bsf.jar", "lib/ant-apache-log4j.jar"}), cp);
+
+        in = this.getClass().getResourceAsStream("/org/apache/ivy/osgi/core/MANIFEST_classpath2.MF");
+        try {
+            bundleInfo = ManifestParser.parseManifest(in);
+        } finally {
+            in.close();
+        }
+        cp = bundleInfo.getClasspath();
+        assertNotNull(cp);
+        assertEquals(1, cp.size());
+        assertEquals(Arrays.asList(new String[] {"."}), cp);
+    }
+
     public void testFormatLines() throws Exception {
         assertEquals("foo bar\n", ManifestParser.formatLines("foo bar"));
         assertEquals(



Mime
View raw message