You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by ma...@apache.org on 2014/05/05 22:02:18 UTC

svn commit: r1592626 - in /ant/ivy/core/branches/2.4.x: ./ doc/ src/java/org/apache/ivy/ant/ src/java/org/apache/ivy/core/module/id/ src/java/org/apache/ivy/core/pack/ src/java/org/apache/ivy/osgi/core/ src/java/org/apache/ivy/osgi/repo/ src/java/org/a...

Author: maartenc
Date: Mon May  5 20:02:17 2014
New Revision: 1592626

URL: http://svn.apache.org/r1592626
Log:
Merging several changes from trunk to the 2.4.x branch.

Added:
    ant/ivy/core/branches/2.4.x/src/java/org/apache/ivy/core/module/id/MatcherLookup.java
      - copied unchanged from r1592238, ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/MatcherLookup.java
    ant/ivy/core/branches/2.4.x/src/java/org/apache/ivy/core/pack/OsgiBundlePacking.java
      - copied unchanged from r1587305, ant/ivy/core/trunk/src/java/org/apache/ivy/core/pack/OsgiBundlePacking.java
    ant/ivy/core/branches/2.4.x/test/java/org/apache/ivy/plugins/conflict/ivysettings-evicted.xml
      - copied unchanged from r1592238, ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/conflict/ivysettings-evicted.xml
    ant/ivy/core/branches/2.4.x/test/repositories/IVY-1399/
      - copied from r1592238, ant/ivy/core/trunk/test/repositories/IVY-1399/
    ant/ivy/core/branches/2.4.x/test/repositories/IVY-1399/MyCompany/
      - copied from r1592238, ant/ivy/core/trunk/test/repositories/IVY-1399/MyCompany/
    ant/ivy/core/branches/2.4.x/test/repositories/IVY-1399/MyCompany/A/
      - copied from r1592238, ant/ivy/core/trunk/test/repositories/IVY-1399/MyCompany/A/
    ant/ivy/core/branches/2.4.x/test/repositories/IVY-1399/MyCompany/A/ivy-1.xml
      - copied unchanged from r1592238, ant/ivy/core/trunk/test/repositories/IVY-1399/MyCompany/A/ivy-1.xml
    ant/ivy/core/branches/2.4.x/test/repositories/IVY-1399/MyCompany/B/
      - copied from r1592238, ant/ivy/core/trunk/test/repositories/IVY-1399/MyCompany/B/
    ant/ivy/core/branches/2.4.x/test/repositories/IVY-1399/MyCompany/B/ivy-1.xml
      - copied unchanged from r1592238, ant/ivy/core/trunk/test/repositories/IVY-1399/MyCompany/B/ivy-1.xml
    ant/ivy/core/branches/2.4.x/test/repositories/IVY-1399/MyCompany/C/
      - copied from r1592238, ant/ivy/core/trunk/test/repositories/IVY-1399/MyCompany/C/
    ant/ivy/core/branches/2.4.x/test/repositories/IVY-1399/MyCompany/C/ivy-1.xml
      - copied unchanged from r1592238, ant/ivy/core/trunk/test/repositories/IVY-1399/MyCompany/C/ivy-1.xml
    ant/ivy/core/branches/2.4.x/test/repositories/IVY-1399/MyCompany/target/
      - copied from r1592238, ant/ivy/core/trunk/test/repositories/IVY-1399/MyCompany/target/
    ant/ivy/core/branches/2.4.x/test/repositories/IVY-1399/MyCompany/target/ivy-1.xml
      - copied unchanged from r1592238, ant/ivy/core/trunk/test/repositories/IVY-1399/MyCompany/target/ivy-1.xml
    ant/ivy/core/branches/2.4.x/test/repositories/IVY-1399/OtherCompany/
      - copied from r1592238, ant/ivy/core/trunk/test/repositories/IVY-1399/OtherCompany/
    ant/ivy/core/branches/2.4.x/test/repositories/IVY-1399/OtherCompany/prefers-later/
      - copied from r1592238, ant/ivy/core/trunk/test/repositories/IVY-1399/OtherCompany/prefers-later/
    ant/ivy/core/branches/2.4.x/test/repositories/IVY-1399/OtherCompany/prefers-later/ivy-1.xml
      - copied unchanged from r1592238, ant/ivy/core/trunk/test/repositories/IVY-1399/OtherCompany/prefers-later/ivy-1.xml
    ant/ivy/core/branches/2.4.x/test/repositories/IVY-1399/conflicting-dependency/
      - copied from r1592238, ant/ivy/core/trunk/test/repositories/IVY-1399/conflicting-dependency/
    ant/ivy/core/branches/2.4.x/test/repositories/IVY-1399/conflicting-dependency/dep/
      - copied from r1592238, ant/ivy/core/trunk/test/repositories/IVY-1399/conflicting-dependency/dep/
    ant/ivy/core/branches/2.4.x/test/repositories/IVY-1399/conflicting-dependency/dep/ivy-1.xml
      - copied unchanged from r1592238, ant/ivy/core/trunk/test/repositories/IVY-1399/conflicting-dependency/dep/ivy-1.xml
    ant/ivy/core/branches/2.4.x/test/repositories/IVY-1399/conflicting-dependency/dep/ivy-2.xml
      - copied unchanged from r1592238, ant/ivy/core/trunk/test/repositories/IVY-1399/conflicting-dependency/dep/ivy-2.xml
Modified:
    ant/ivy/core/branches/2.4.x/   (props changed)
    ant/ivy/core/branches/2.4.x/CHANGES.txt
    ant/ivy/core/branches/2.4.x/doc/concept.html
    ant/ivy/core/branches/2.4.x/src/java/org/apache/ivy/ant/ConvertManifestTask.java
    ant/ivy/core/branches/2.4.x/src/java/org/apache/ivy/core/module/id/ModuleRules.java
    ant/ivy/core/branches/2.4.x/src/java/org/apache/ivy/core/pack/Pack200Packing.java
    ant/ivy/core/branches/2.4.x/src/java/org/apache/ivy/core/pack/PackingRegistry.java
    ant/ivy/core/branches/2.4.x/src/java/org/apache/ivy/core/pack/ZipPacking.java
    ant/ivy/core/branches/2.4.x/src/java/org/apache/ivy/osgi/core/BundleInfoAdapter.java
    ant/ivy/core/branches/2.4.x/src/java/org/apache/ivy/osgi/core/ManifestParser.java
    ant/ivy/core/branches/2.4.x/src/java/org/apache/ivy/osgi/core/OSGiManifestParser.java
    ant/ivy/core/branches/2.4.x/src/java/org/apache/ivy/osgi/repo/AbstractOSGiResolver.java
    ant/ivy/core/branches/2.4.x/src/java/org/apache/ivy/plugins/conflict/LatestConflictManager.java
    ant/ivy/core/branches/2.4.x/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java
    ant/ivy/core/branches/2.4.x/src/java/org/apache/ivy/util/FileUtil.java
    ant/ivy/core/branches/2.4.x/test/java/org/apache/ivy/osgi/obr/OBRResolverTest.java
    ant/ivy/core/branches/2.4.x/test/java/org/apache/ivy/osgi/p2/P2DescriptorTest.java
    ant/ivy/core/branches/2.4.x/test/java/org/apache/ivy/plugins/conflict/LatestConflictManagerTest.java

Propchange: ant/ivy/core/branches/2.4.x/
------------------------------------------------------------------------------
  Merged /ant/ivy/core/trunk:r1587110-1587305,1590442-1592238

Modified: ant/ivy/core/branches/2.4.x/CHANGES.txt
URL: http://svn.apache.org/viewvc/ant/ivy/core/branches/2.4.x/CHANGES.txt?rev=1592626&r1=1592625&r2=1592626&view=diff
==============================================================================
--- ant/ivy/core/branches/2.4.x/CHANGES.txt (original)
+++ ant/ivy/core/branches/2.4.x/CHANGES.txt Mon May  5 20:02:17 2014
@@ -126,6 +126,7 @@ for detailed view of each issue, please 
 	John Tinetti
 	Erwin Tratar
 	Jason Trump
+	David Turner
 	Tjeerd Verhagen
 	Richard Vowles
 	Sven Walter
@@ -137,7 +138,15 @@ for detailed view of each issue, please 
 	Jaroslaw Wypychowski
 	Sven Zethelius
 	Aleksey Zhukov
+	Zhong Wang
 	
+   2.4.x
+=====================================
+- IMPROVEMENT: Add support for packed jar within an OSGi bundle
+- IMPROVEMENT: ModuleRules.getRule is O(n) leading to resolution slowness (IVY-1465) (Thanks to Zhong Wang aka Kewpie)
+
+- FIX: impossible to get artifacts when data has not been loaded. (IVY-1399) (Thanks to David Turner)
+
    2.4.0-rc1
 =====================================
 - DOCUMENTATION: Broken link in <dependency> documentation (IVY-1405)

Modified: ant/ivy/core/branches/2.4.x/doc/concept.html
URL: http://svn.apache.org/viewvc/ant/ivy/core/branches/2.4.x/doc/concept.html?rev=1592626&r1=1592625&r2=1592626&view=diff
==============================================================================
--- ant/ivy/core/branches/2.4.x/doc/concept.html (original)
+++ ant/ivy/core/branches/2.4.x/doc/concept.html Mon May  5 20:02:17 2014
@@ -289,6 +289,7 @@ A <i>packaged</i> artifact needs to be d
 <ul>
     <li><tt>zip</tt>, <tt>jar</tt> or <tt>war</tt>: the artifact will be uncompressed as a folder</li>
     <li><tt>pack200</tt>: the artifact will be unpacked to a file via the <a href="http://docs.oracle.com/javase/7/docs/technotes/tools/share/pack200.html">pack200</a> algorithm</li>
+    <li><tt>bundle</tt>: the OSGi artifact will be uncompressed as a folder, and every embedded jar file entry which is packed via the the <a href="http://docs.oracle.com/javase/7/docs/technotes/tools/share/pack200.html">pack200</a> algorithm will be unpacked</li>
 </ul>
 
 So, if in an <tt>ivy.xml</tt>, there would be declared a such artifact:

Modified: ant/ivy/core/branches/2.4.x/src/java/org/apache/ivy/ant/ConvertManifestTask.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/branches/2.4.x/src/java/org/apache/ivy/ant/ConvertManifestTask.java?rev=1592626&r1=1592625&r2=1592626&view=diff
==============================================================================
--- ant/ivy/core/branches/2.4.x/src/java/org/apache/ivy/ant/ConvertManifestTask.java (original)
+++ ant/ivy/core/branches/2.4.x/src/java/org/apache/ivy/ant/ConvertManifestTask.java Mon May  5 20:02:17 2014
@@ -84,7 +84,7 @@ public class ConvertManifestTask extends
             throw new BuildException("Incorrect manifest file '" + manifest + "'", e);
         }
         ModuleDescriptor md = BundleInfoAdapter.toModuleDescriptor(
-            OSGiManifestParser.getInstance(), null, bundleInfo, profileProvider);
+            OSGiManifestParser.getInstance(), null, bundleInfo, m, profileProvider);
 
         try {
             XmlModuleDescriptorWriter.write(md, ivyFile);

Modified: ant/ivy/core/branches/2.4.x/src/java/org/apache/ivy/core/module/id/ModuleRules.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/branches/2.4.x/src/java/org/apache/ivy/core/module/id/ModuleRules.java?rev=1592626&r1=1592625&r2=1592626&view=diff
==============================================================================
--- ant/ivy/core/branches/2.4.x/src/java/org/apache/ivy/core/module/id/ModuleRules.java (original)
+++ ant/ivy/core/branches/2.4.x/src/java/org/apache/ivy/core/module/id/ModuleRules.java Mon May  5 20:02:17 2014
@@ -23,7 +23,6 @@ import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Map.Entry;
 
 import org.apache.ivy.plugins.matcher.MapMatcher;
 import org.apache.ivy.util.Checks;
@@ -53,6 +52,8 @@ import org.apache.ivy.util.filter.NoFilt
 public class ModuleRules {
     private Map/* <MapMatcher,Object> */rules = new LinkedHashMap();
 
+    private MatcherLookup matcher_lookup = new MatcherLookup();
+
     /**
      * Constructs an empty ModuleRules.
      */
@@ -61,6 +62,9 @@ public class ModuleRules {
 
     private ModuleRules(Map/* <MapMatcher,Object> */rules) {
         this.rules = new LinkedHashMap(rules);
+        for (Iterator iter = rules.keySet().iterator(); iter.hasNext();) {
+            matcher_lookup.add((MapMatcher) iter.next());
+        }
     }
 
     /**
@@ -76,6 +80,7 @@ public class ModuleRules {
         Checks.checkNotNull(rule, "rule");
 
         rules.put(condition, rule);
+        matcher_lookup.add(condition);
     }
 
     /**
@@ -123,7 +128,7 @@ public class ModuleRules {
      * Returns the rule object matching the given {@link ModuleId} and accepted by the given
      * {@link Filter}, or <code>null</code> if no rule applies.
      * 
-     * @param mrid
+     * @param mid
      *            the {@link ModuleRevisionId} to search the rule for. Must not be <code>null</code>
      *            .
      * @param filter
@@ -164,14 +169,12 @@ public class ModuleRules {
     }
 
     private Object getRule(Map moduleAttributes, Filter filter) {
-        for (Iterator iter = rules.entrySet().iterator(); iter.hasNext();) {
-            Map.Entry ruleEntry = (Entry) iter.next();
-            MapMatcher midm = (MapMatcher) ruleEntry.getKey();
-            if (midm.matches(moduleAttributes)) {
-                Object rule = ruleEntry.getValue();
-                if (filter.accept(rule)) {
-                    return rule;
-                }
+        List matchers = matcher_lookup.get(moduleAttributes);
+        for (Iterator iter = matchers.iterator(); iter.hasNext();) {
+            MapMatcher midm = (MapMatcher) iter.next();
+            Object rule = rules.get(midm);
+            if (filter.accept(rule)) {
+                return rule;
             }
         }
         return null;
@@ -198,15 +201,13 @@ public class ModuleRules {
     }
 
     private Object[] getRules(Map moduleAttributes, Filter filter) {
+        List matchers = matcher_lookup.get(moduleAttributes);
         List matchingRules = new ArrayList();
-        for (Iterator iter = rules.entrySet().iterator(); iter.hasNext();) {
-            Map.Entry ruleEntry = (Entry) iter.next();
-            MapMatcher midm = (MapMatcher) ruleEntry.getKey();
-            if (midm.matches(moduleAttributes)) {
-                Object rule = ruleEntry.getValue();
-                if (filter.accept(rule)) {
-                    matchingRules.add(rule);
-                }
+        for (Iterator iter = matchers.iterator(); iter.hasNext();) {
+            MapMatcher midm = (MapMatcher) iter.next();
+            Object rule = rules.get(midm);
+            if (filter.accept(rule)) {
+                matchingRules.add(rule);
             }
         }
         return matchingRules.toArray();

Modified: ant/ivy/core/branches/2.4.x/src/java/org/apache/ivy/core/pack/Pack200Packing.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/branches/2.4.x/src/java/org/apache/ivy/core/pack/Pack200Packing.java?rev=1592626&r1=1592625&r2=1592626&view=diff
==============================================================================
--- ant/ivy/core/branches/2.4.x/src/java/org/apache/ivy/core/pack/Pack200Packing.java (original)
+++ ant/ivy/core/branches/2.4.x/src/java/org/apache/ivy/core/pack/Pack200Packing.java Mon May  5 20:02:17 2014
@@ -17,15 +17,10 @@
  */
 package org.apache.ivy.core.pack;
 
-import java.io.BufferedInputStream;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.util.jar.JarOutputStream;
-import java.util.jar.Pack200;
-import java.util.jar.Pack200.Unpacker;
-import java.util.zip.GZIPInputStream;
+
+import org.apache.ivy.util.FileUtil;
 
 public class Pack200Packing extends StreamPacking {
 
@@ -54,25 +49,7 @@ public class Pack200Packing extends Stre
 
     @Override
     public InputStream unpack(InputStream packed) throws IOException {
-        BufferedInputStream buffered = new BufferedInputStream(packed);
-        buffered.mark(4);
-        byte[] magic = new byte[4];
-        buffered.read(magic, 0, 4);
-        buffered.reset();
-
-        InputStream in = buffered;
-
-        if (magic[0] == (byte) 0x1F && magic[1] == (byte) 0x8B && magic[2] == (byte) 0x08) {
-            // this is a gziped pack200
-            in = new GZIPInputStream(in);
-        }
-
-        Unpacker unpacker = Pack200.newUnpacker();
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        JarOutputStream jar = new JarOutputStream(baos);
-        unpacker.unpack(in, jar);
-        jar.close();
-        return new ByteArrayInputStream(baos.toByteArray());
+        return FileUtil.unwrapPack200(packed);
     }
 
 }

Modified: ant/ivy/core/branches/2.4.x/src/java/org/apache/ivy/core/pack/PackingRegistry.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/branches/2.4.x/src/java/org/apache/ivy/core/pack/PackingRegistry.java?rev=1592626&r1=1592625&r2=1592626&view=diff
==============================================================================
--- ant/ivy/core/branches/2.4.x/src/java/org/apache/ivy/core/pack/PackingRegistry.java (original)
+++ ant/ivy/core/branches/2.4.x/src/java/org/apache/ivy/core/pack/PackingRegistry.java Mon May  5 20:02:17 2014
@@ -28,6 +28,7 @@ public class PackingRegistry {
         // register defaults
         register(new ZipPacking());
         register(new Pack200Packing());
+        register(new OsgiBundlePacking());
     }
 
     public void register(ArchivePacking packing) {

Modified: ant/ivy/core/branches/2.4.x/src/java/org/apache/ivy/core/pack/ZipPacking.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/branches/2.4.x/src/java/org/apache/ivy/core/pack/ZipPacking.java?rev=1592626&r1=1592625&r2=1592626&view=diff
==============================================================================
--- ant/ivy/core/branches/2.4.x/src/java/org/apache/ivy/core/pack/ZipPacking.java (original)
+++ ant/ivy/core/branches/2.4.x/src/java/org/apache/ivy/core/pack/ZipPacking.java Mon May  5 20:02:17 2014
@@ -18,6 +18,7 @@
 package org.apache.ivy.core.pack;
 
 import java.io.File;
+import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
@@ -66,16 +67,7 @@ public class ZipPacking extends ArchiveP
                 if (entry.isDirectory()) {
                     f.mkdirs();
                 } else {
-                    FileOutputStream out = new FileOutputStream(f);
-                    try {
-                        FileUtil.copy(zip, out, null, false);
-                    } finally {
-                        try {
-                            out.close();
-                        } catch (IOException e) {
-                            // ignore
-                        }
-                    }
+                    writeFile(zip, f);
                 }
 
                 f.setLastModified(entry.getTime());
@@ -91,4 +83,17 @@ public class ZipPacking extends ArchiveP
         }
     }
 
+    protected void writeFile(InputStream zip, File f) throws FileNotFoundException, IOException {
+        FileOutputStream out = new FileOutputStream(f);
+        try {
+            FileUtil.copy(zip, out, null, false);
+        } finally {
+            try {
+                out.close();
+            } catch (IOException e) {
+                // ignore
+            }
+        }
+    }
+
 }

Modified: ant/ivy/core/branches/2.4.x/src/java/org/apache/ivy/osgi/core/BundleInfoAdapter.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/branches/2.4.x/src/java/org/apache/ivy/osgi/core/BundleInfoAdapter.java?rev=1592626&r1=1592625&r2=1592626&view=diff
==============================================================================
--- ant/ivy/core/branches/2.4.x/src/java/org/apache/ivy/osgi/core/BundleInfoAdapter.java (original)
+++ ant/ivy/core/branches/2.4.x/src/java/org/apache/ivy/osgi/core/BundleInfoAdapter.java Mon May  5 20:02:17 2014
@@ -27,7 +27,9 @@ import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.Set;
+import java.util.jar.Manifest;
 
 import org.apache.ivy.Ivy;
 import org.apache.ivy.core.module.descriptor.Artifact;
@@ -68,19 +70,21 @@ public class BundleInfoAdapter {
 
     public static final String EXTRA_INFO_EXPORT_PREFIX = "_osgi_export_";
 
+    public static DefaultModuleDescriptor toModuleDescriptor(ModuleDescriptorParser parser,
+            URI baseUri, BundleInfo bundle, ExecutionEnvironmentProfileProvider profileProvider) {
+        return toModuleDescriptor(parser, baseUri, bundle, null, profileProvider);
+    }
+
     /**
      * 
      * @param baseUri
      *            uri to help build the absolute url if the bundle info has a relative uri.
-     * @param bundle
-     * @param profileProvider
-     * @param parser
      * @return
      * @throws ProfileNotFoundException
      */
     public static DefaultModuleDescriptor toModuleDescriptor(ModuleDescriptorParser parser,
-            URI baseUri, BundleInfo bundle, ExecutionEnvironmentProfileProvider profileProvider)
-            throws ProfileNotFoundException {
+            URI baseUri, BundleInfo bundle, Manifest manifest,
+            ExecutionEnvironmentProfileProvider profileProvider) throws ProfileNotFoundException {
         DefaultModuleDescriptor md = new DefaultModuleDescriptor(parser, null);
         md.addExtraAttributeNamespace("o", Ivy.getIvyHomeURL() + "osgi");
         ModuleRevisionId mrid = asMrid(BundleInfo.BUNDLE_TYPE, bundle.getSymbolicName(),
@@ -115,8 +119,8 @@ public class BundleInfoAdapter {
                 String type = "jar";
                 String ext = "jar";
                 String packaging = null;
-                if (bundle.hasInnerClasspath()) {
-                    packaging = "zip";
+                if (bundle.hasInnerClasspath() && !bundleArtifact.isSource()) {
+                    packaging = "bundle";
                 }
                 if ("packed".equals(bundleArtifact.getFormat())) {
                     ext = "jar.pack.gz";
@@ -160,6 +164,12 @@ public class BundleInfoAdapter {
             }
         }
 
+        if (manifest != null) {
+            for (Entry<Object, Object> entries : manifest.getMainAttributes().entrySet()) {
+                md.addExtraInfo(entries.getKey().toString(), entries.getValue().toString());
+            }
+        }
+
         return md;
     }
 

Modified: ant/ivy/core/branches/2.4.x/src/java/org/apache/ivy/osgi/core/ManifestParser.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/branches/2.4.x/src/java/org/apache/ivy/osgi/core/ManifestParser.java?rev=1592626&r1=1592625&r2=1592626&view=diff
==============================================================================
--- ant/ivy/core/branches/2.4.x/src/java/org/apache/ivy/osgi/core/ManifestParser.java (original)
+++ ant/ivy/core/branches/2.4.x/src/java/org/apache/ivy/osgi/core/ManifestParser.java Mon May  5 20:02:17 2014
@@ -204,6 +204,7 @@ public class ManifestParser {
         if (bundleClasspath != null) {
             ManifestHeaderValue bundleClasspathValue = new ManifestHeaderValue(bundleClasspath);
             bundleInfo.setClasspath(bundleClasspathValue.getValues());
+            bundleInfo.setHasInnerClasspath(true);
         }
 
         return bundleInfo;

Modified: ant/ivy/core/branches/2.4.x/src/java/org/apache/ivy/osgi/core/OSGiManifestParser.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/branches/2.4.x/src/java/org/apache/ivy/osgi/core/OSGiManifestParser.java?rev=1592626&r1=1592625&r2=1592626&view=diff
==============================================================================
--- ant/ivy/core/branches/2.4.x/src/java/org/apache/ivy/osgi/core/OSGiManifestParser.java (original)
+++ ant/ivy/core/branches/2.4.x/src/java/org/apache/ivy/osgi/core/OSGiManifestParser.java Mon May  5 20:02:17 2014
@@ -69,7 +69,7 @@ public class OSGiManifestParser implemen
         } catch (URISyntaxException e) {
             throw new RuntimeException("Unsupported repository, resources names are not uris", e);
         }
-        return BundleInfoAdapter.toModuleDescriptor(this, null, bundleInfo, profileProvider);
+        return BundleInfoAdapter.toModuleDescriptor(this, null, bundleInfo, m, profileProvider);
     }
 
     public void toIvyFile(InputStream is, Resource res, File destFile, ModuleDescriptor md)

Modified: ant/ivy/core/branches/2.4.x/src/java/org/apache/ivy/osgi/repo/AbstractOSGiResolver.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/branches/2.4.x/src/java/org/apache/ivy/osgi/repo/AbstractOSGiResolver.java?rev=1592626&r1=1592625&r2=1592626&view=diff
==============================================================================
--- ant/ivy/core/branches/2.4.x/src/java/org/apache/ivy/osgi/repo/AbstractOSGiResolver.java (original)
+++ ant/ivy/core/branches/2.4.x/src/java/org/apache/ivy/osgi/repo/AbstractOSGiResolver.java Mon May  5 20:02:17 2014
@@ -234,6 +234,9 @@ public abstract class AbstractOSGiResolv
     public ResolvedResource findResource(ResolvedResource[] rress, ResourceMDParser rmdparser,
             ModuleRevisionId mrid, Date date) {
         ResolvedResource found = super.findResource(rress, rmdparser, mrid, date);
+        if (found == null) {
+            return null;
+        }
 
         String osgiType = mrid.getOrganisation();
         // for non bundle requirement : log the selected bundle

Modified: ant/ivy/core/branches/2.4.x/src/java/org/apache/ivy/plugins/conflict/LatestConflictManager.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/branches/2.4.x/src/java/org/apache/ivy/plugins/conflict/LatestConflictManager.java?rev=1592626&r1=1592625&r2=1592626&view=diff
==============================================================================
--- ant/ivy/core/branches/2.4.x/src/java/org/apache/ivy/plugins/conflict/LatestConflictManager.java (original)
+++ ant/ivy/core/branches/2.4.x/src/java/org/apache/ivy/plugins/conflict/LatestConflictManager.java Mon May  5 20:02:17 2014
@@ -103,6 +103,16 @@ public class LatestConflictManager exten
             }
         }
 
+        ArrayList unevicted = new ArrayList();
+        for (Iterator iter = conflicts.iterator(); iter.hasNext();) {
+            IvyNode node = (IvyNode) iter.next();
+            if (!node.isCompletelyEvicted())
+                unevicted.add(node);
+        }
+        if (unevicted.size() > 0) {
+            conflicts = unevicted;
+        }
+
         try {
             IvyNodeArtifactInfo latest = (IvyNodeArtifactInfo) getStrategy().findLatest(
                 toArtifactInfo(conflicts), null);

Modified: ant/ivy/core/branches/2.4.x/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/branches/2.4.x/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java?rev=1592626&r1=1592625&r2=1592626&view=diff
==============================================================================
--- ant/ivy/core/branches/2.4.x/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java (original)
+++ ant/ivy/core/branches/2.4.x/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java Mon May  5 20:02:17 2014
@@ -561,6 +561,8 @@ public class XmlModuleDescriptorParser e
                 Namespace parentNamespace = ((DefaultModuleDescriptor) parent).getNamespace();
                 descriptor.setNamespace(parentNamespace);
             }
+
+            descriptor.getExtraInfo().putAll(parent.getExtraInfo());
         }
 
         private static String mergeRevisionValue(String inherited, String override) {

Modified: ant/ivy/core/branches/2.4.x/src/java/org/apache/ivy/util/FileUtil.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/branches/2.4.x/src/java/org/apache/ivy/util/FileUtil.java?rev=1592626&r1=1592625&r2=1592626&view=diff
==============================================================================
--- ant/ivy/core/branches/2.4.x/src/java/org/apache/ivy/util/FileUtil.java (original)
+++ ant/ivy/core/branches/2.4.x/src/java/org/apache/ivy/util/FileUtil.java Mon May  5 20:02:17 2014
@@ -17,7 +17,10 @@
  */
 package org.apache.ivy.util;
 
+import java.io.BufferedInputStream;
 import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
@@ -36,7 +39,12 @@ import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Stack;
 import java.util.StringTokenizer;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Pack200;
+import java.util.jar.Pack200.Unpacker;
 import java.util.regex.Pattern;
+import java.util.zip.GZIPInputStream;
+import java.util.zip.ZipInputStream;
 
 import org.apache.ivy.util.url.URLHandlerRegistry;
 
@@ -637,4 +645,87 @@ public final class FileUtil {
         return l;
     }
 
+    public static InputStream unwrapPack200(InputStream packed) throws IOException {
+        BufferedInputStream buffered = new BufferedInputStream(packed);
+        buffered.mark(4);
+        byte[] magic = new byte[4];
+        buffered.read(magic, 0, 4);
+        buffered.reset();
+
+        InputStream in = buffered;
+
+        if (magic[0] == (byte) 0x1F && magic[1] == (byte) 0x8B && magic[2] == (byte) 0x08) {
+            // this is a gziped pack200
+            in = new GZIPInputStream(in);
+        }
+
+        Unpacker unpacker = Pack200.newUnpacker();
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        JarOutputStream jar = new JarOutputStream(baos);
+        unpacker.unpack(new UncloseInputStream(in), jar);
+        jar.close();
+        return new ByteArrayInputStream(baos.toByteArray());
+    }
+
+    /**
+     * Wrap an input stream and do not close the stream on call to close(). Used to avoid closing a
+     * {@link ZipInputStream} used with {@link Unpacker#unpack(File, JarOutputStream)}
+     */
+    private static final class UncloseInputStream extends InputStream {
+
+        private InputStream wrapped;
+
+        public UncloseInputStream(InputStream wrapped) {
+            this.wrapped = wrapped;
+        }
+
+        public void close() throws IOException {
+            // do not close
+        }
+
+        public int read() throws IOException {
+            return wrapped.read();
+        }
+
+        public int hashCode() {
+            return wrapped.hashCode();
+        }
+
+        public int read(byte[] b) throws IOException {
+            return wrapped.read(b);
+        }
+
+        public boolean equals(Object obj) {
+            return wrapped.equals(obj);
+        }
+
+        public int read(byte[] b, int off, int len) throws IOException {
+            return wrapped.read(b, off, len);
+        }
+
+        public long skip(long n) throws IOException {
+            return wrapped.skip(n);
+        }
+
+        public String toString() {
+            return wrapped.toString();
+        }
+
+        public int available() throws IOException {
+            return wrapped.available();
+        }
+
+        public void mark(int readlimit) {
+            wrapped.mark(readlimit);
+        }
+
+        public void reset() throws IOException {
+            wrapped.reset();
+        }
+
+        public boolean markSupported() {
+            return wrapped.markSupported();
+        }
+
+    }
 }

Modified: ant/ivy/core/branches/2.4.x/test/java/org/apache/ivy/osgi/obr/OBRResolverTest.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/branches/2.4.x/test/java/org/apache/ivy/osgi/obr/OBRResolverTest.java?rev=1592626&r1=1592625&r2=1592626&view=diff
==============================================================================
--- ant/ivy/core/branches/2.4.x/test/java/org/apache/ivy/osgi/obr/OBRResolverTest.java (original)
+++ ant/ivy/core/branches/2.4.x/test/java/org/apache/ivy/osgi/obr/OBRResolverTest.java Mon May  5 20:02:17 2014
@@ -25,6 +25,7 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 import java.util.jar.JarInputStream;
+import java.util.jar.Manifest;
 
 import junit.framework.AssertionFailedError;
 import junit.framework.TestCase;
@@ -294,9 +295,9 @@ public class OBRResolverTest extends Tes
 
     private void genericTestResolve(String jarName, String conf, ModuleRevisionId[] expectedMrids,
             ModuleRevisionId[] expected2Mrids) throws Exception {
-        JarInputStream in = new JarInputStream(new FileInputStream("test/test-repo/bundlerepo/"
-                + jarName));
-        BundleInfo bundleInfo = ManifestParser.parseManifest(in.getManifest());
+        Manifest manifest = new JarInputStream(new FileInputStream("test/test-repo/bundlerepo/"
+                + jarName)).getManifest();
+        BundleInfo bundleInfo = ManifestParser.parseManifest(manifest);
         bundleInfo.addArtifact(new BundleArtifact(false, new File("test/test-repo/bundlerepo/"
                 + jarName).toURI(), null));
         DefaultModuleDescriptor md = BundleInfoAdapter.toModuleDescriptor(
@@ -326,13 +327,13 @@ public class OBRResolverTest extends Tes
     }
 
     private void genericTestFailingResolve(String jarName, String conf) throws Exception {
-        JarInputStream in = new JarInputStream(new FileInputStream("test/test-repo/bundlerepo/"
-                + jarName));
-        BundleInfo bundleInfo = ManifestParser.parseManifest(in.getManifest());
+        Manifest manifest = new JarInputStream(new FileInputStream("test/test-repo/bundlerepo/"
+                + jarName)).getManifest();
+        BundleInfo bundleInfo = ManifestParser.parseManifest(manifest);
         bundleInfo.addArtifact(new BundleArtifact(false, new File("test/test-repo/bundlerepo/"
                 + jarName).toURI(), null));
         DefaultModuleDescriptor md = BundleInfoAdapter.toModuleDescriptor(
-            OSGiManifestParser.getInstance(), null, bundleInfo, profileProvider);
+            OSGiManifestParser.getInstance(), null, bundleInfo, manifest, profileProvider);
         ResolveReport resolveReport = ivy.resolve(md,
             new ResolveOptions().setConfs(new String[] {conf}).setOutputReport(false));
         assertTrue(resolveReport.hasError());

Modified: ant/ivy/core/branches/2.4.x/test/java/org/apache/ivy/osgi/p2/P2DescriptorTest.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/branches/2.4.x/test/java/org/apache/ivy/osgi/p2/P2DescriptorTest.java?rev=1592626&r1=1592625&r2=1592626&view=diff
==============================================================================
--- ant/ivy/core/branches/2.4.x/test/java/org/apache/ivy/osgi/p2/P2DescriptorTest.java (original)
+++ ant/ivy/core/branches/2.4.x/test/java/org/apache/ivy/osgi/p2/P2DescriptorTest.java Mon May  5 20:02:17 2014
@@ -195,7 +195,12 @@ public class P2DescriptorTest extends Te
 
             assertEquals(artifact, ar.getArtifact());
             assertEquals(DownloadStatus.SUCCESSFUL, ar.getDownloadStatus());
-            assertNotNull(ar.getUnpackedLocalFile());
+            // only the binary get unpacked
+            if (ar.getArtifact().getType().equals("source")) {
+                assertNull(ar.getUnpackedLocalFile());
+            } else {
+                assertNotNull(ar.getUnpackedLocalFile());
+            }
         }
     }
 

Modified: ant/ivy/core/branches/2.4.x/test/java/org/apache/ivy/plugins/conflict/LatestConflictManagerTest.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/branches/2.4.x/test/java/org/apache/ivy/plugins/conflict/LatestConflictManagerTest.java?rev=1592626&r1=1592625&r2=1592626&view=diff
==============================================================================
--- ant/ivy/core/branches/2.4.x/test/java/org/apache/ivy/plugins/conflict/LatestConflictManagerTest.java (original)
+++ ant/ivy/core/branches/2.4.x/test/java/org/apache/ivy/plugins/conflict/LatestConflictManagerTest.java Mon May  5 20:02:17 2014
@@ -187,6 +187,37 @@ public class LatestConflictManagerTest e
         }
     }
 
+    /*
+     * Test case for issue IVY-1399:
+     * Dependency tree:
+     * Mycompany#target;1
+     *     MyCompany#A;1
+     *         conflicting-dependency#dep;1
+     *         OtherCompany#prefers-later;1
+     *             conflicting-dependency#dep;2
+     *     MyCompany#B;1
+     *         MyCompany#A;1
+     *             ...
+     *         OtherCompany#prefers-later;1
+     *             ...
+     *         MyCompany#C;1
+     *             conflicting-dependency#dep;1
+     */
+    public void testEvictedModules() throws Exception {
+        ivy.configure(LatestConflictManagerTest.class
+                .getResource("ivysettings-evicted.xml"));
+
+        ivy.getSettings().setVariable("ivy.log.conflict.resolution", "true", true);
+        try {
+            ResolveReport report = ivy.resolve(
+                new File("test/repositories/IVY-1399/MyCompany/target/ivy-1.xml"),
+                getResolveOptions());
+            report.getConfigurationReport("all");
+        } catch (IllegalStateException e) {
+            fail("Resolving target should not throw an exception");
+        }
+    }
+
     private ResolveOptions getResolveOptions() {
         return new ResolveOptions().setValidate(false);
     }