You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by ds...@apache.org on 2009/07/21 17:54:27 UTC

svn commit: r796353 - /felix/trunk/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/SigilResolver.java

Author: dsavage
Date: Tue Jul 21 15:54:27 2009
New Revision: 796353

URL: http://svn.apache.org/viewvc?rev=796353&view=rev
Log:
patch for FELIX-1392 + some minor logging improvements

Modified:
    felix/trunk/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/SigilResolver.java

Modified: felix/trunk/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/SigilResolver.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/SigilResolver.java?rev=796353&r1=796352&r2=796353&view=diff
==============================================================================
--- felix/trunk/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/SigilResolver.java (original)
+++ felix/trunk/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/SigilResolver.java Tue Jul 21 15:54:27 2009
@@ -32,6 +32,7 @@
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Properties;
+import java.util.jar.JarEntry;
 import java.util.jar.JarInputStream;
 import java.util.jar.Manifest;
 
@@ -142,6 +143,7 @@
 
 		ISigilBundle bundle = resolve(id);
 		if (bundle == null) {
+			Log.error( "Failed to find bundle for module " + id );
 			return null;
 		}
 
@@ -208,6 +210,8 @@
 		bundle.setSymbolicName(id.getName());
 		bundle.setVersions(VersionRange.parseVersionRange(range));
 
+		Log.verbose("searching for " + bundle);
+		
 		try {
 			IResolution resolution = resolveOrFail(bundle, false);
 			ISigilBundle[] bundles = resolution.getBundles().toArray(new ISigilBundle[0]);
@@ -215,6 +219,7 @@
 				return bundles[0];
 			}
 		} catch (ResolutionException e) {
+			Log.warn( e.getMessage() );
 			return null;
 		}
 		return null;
@@ -295,9 +300,8 @@
     			for (String j : bcp.split(",\\s*")) {
     				if (j.equals(".")) {
             			content.append("<artifact/>\n");
-    				} else if (!j.endsWith("component-activator.jar")) {
-    					if (j.endsWith(".jar"))
-    						j = j.substring(0, j.length() - 4);
+        			} else if (j.endsWith(".jar") && bundleContains(bundle, j)) {
+        				j = j.substring(0, j.length() - 4);
             			content.append(format("<artifact name=\"%s!%s\"/>\n", module, j));
         			}
     			}
@@ -313,7 +317,32 @@
 			content.append("</ivy-module>\n");
 		}
 		
-        private String readBundleClassPath(ISigilBundle bundle) {
+        private boolean bundleContains(ISigilBundle bundle, String j) {
+        	URI uri = bundle.getBundleInfo().getUpdateLocation();
+            InputStream is = null;
+			try {
+    			URL url =  (uri != null) ? uri.toURL() : bundle.getLocation().toFile().toURL();
+				is = url.openStream();
+            	JarInputStream js = new JarInputStream(is, false);
+            	JarEntry entry;
+            	while ( (entry = js.getNextJarEntry()) != null ) {
+            		if ( j.equals( entry.getName() ) ) {
+            			return true;
+            		}
+            	}
+			} catch (IOException e) {
+			} finally {
+				if (is != null) {
+					try {
+						is.close();
+					} catch (IOException e2) {
+					}
+				}
+			}
+        	return false;
+		}
+
+		private String readBundleClassPath(ISigilBundle bundle) {
         	if (bundle == null)
         		return null;