ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maart...@apache.org
Subject svn commit: r1376406 - in /ant/ivy/core/branches/2.3.x: ./ src/java/org/apache/ivy/plugins/parser/xml/ test/java/org/apache/ivy/core/resolve/ test/repositories/IVY-1347/ test/repositories/IVY-1347/childone/ test/repositories/IVY-1347/childone/childtwo/...
Date Thu, 23 Aug 2012 08:39:47 GMT
Author: maartenc
Date: Thu Aug 23 08:39:46 2012
New Revision: 1376406

URL: http://svn.apache.org/viewvc?rev=1376406&view=rev
Log:
- FIX: Unnecessary warning when parent ivy.xml is not found (IVY-1346) (merged from trunk)
- FIX: StackOverflowError when using <extends> and ../ivy.xml is not the parent ivy.xml
(IVY-1437) (merged from trunk)

Added:
    ant/ivy/core/branches/2.3.x/test/repositories/IVY-1347/
      - copied from r1374774, ant/ivy/core/trunk/test/repositories/IVY-1347/
    ant/ivy/core/branches/2.3.x/test/repositories/IVY-1347/childone/
      - copied from r1374774, ant/ivy/core/trunk/test/repositories/IVY-1347/childone/
    ant/ivy/core/branches/2.3.x/test/repositories/IVY-1347/childone/childtwo/
      - copied from r1374774, ant/ivy/core/trunk/test/repositories/IVY-1347/childone/childtwo/
    ant/ivy/core/branches/2.3.x/test/repositories/IVY-1347/childone/childtwo/ivy.xml
      - copied unchanged from r1374774, ant/ivy/core/trunk/test/repositories/IVY-1347/childone/childtwo/ivy.xml
    ant/ivy/core/branches/2.3.x/test/repositories/IVY-1347/childone/ivy.xml
      - copied unchanged from r1374774, ant/ivy/core/trunk/test/repositories/IVY-1347/childone/ivy.xml
    ant/ivy/core/branches/2.3.x/test/repositories/IVY-1347/ivysettings.xml
      - copied unchanged from r1374774, ant/ivy/core/trunk/test/repositories/IVY-1347/ivysettings.xml
    ant/ivy/core/branches/2.3.x/test/repositories/IVY-1347/repo/
      - copied from r1374774, ant/ivy/core/trunk/test/repositories/IVY-1347/repo/
    ant/ivy/core/branches/2.3.x/test/repositories/IVY-1347/repo/foo/
      - copied from r1374774, ant/ivy/core/trunk/test/repositories/IVY-1347/repo/foo/
    ant/ivy/core/branches/2.3.x/test/repositories/IVY-1347/repo/foo/parent/
      - copied from r1374774, ant/ivy/core/trunk/test/repositories/IVY-1347/repo/foo/parent/
    ant/ivy/core/branches/2.3.x/test/repositories/IVY-1347/repo/foo/parent/1.0/
      - copied from r1374774, ant/ivy/core/trunk/test/repositories/IVY-1347/repo/foo/parent/1.0/
    ant/ivy/core/branches/2.3.x/test/repositories/IVY-1347/repo/foo/parent/1.0/ivys/
      - copied from r1374774, ant/ivy/core/trunk/test/repositories/IVY-1347/repo/foo/parent/1.0/ivys/
    ant/ivy/core/branches/2.3.x/test/repositories/IVY-1347/repo/foo/parent/1.0/ivys/ivy.xml
      - copied unchanged from r1374774, ant/ivy/core/trunk/test/repositories/IVY-1347/repo/foo/parent/1.0/ivys/ivy.xml
Modified:
    ant/ivy/core/branches/2.3.x/   (props changed)
    ant/ivy/core/branches/2.3.x/CHANGES.txt
    ant/ivy/core/branches/2.3.x/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java
    ant/ivy/core/branches/2.3.x/test/java/org/apache/ivy/core/resolve/ResolveTest.java

Propchange: ant/ivy/core/branches/2.3.x/
------------------------------------------------------------------------------
  Merged /ant/ivy/core/trunk:r1374774,1374859,1374917-1374922

Modified: ant/ivy/core/branches/2.3.x/CHANGES.txt
URL: http://svn.apache.org/viewvc/ant/ivy/core/branches/2.3.x/CHANGES.txt?rev=1376406&r1=1376405&r2=1376406&view=diff
==============================================================================
--- ant/ivy/core/branches/2.3.x/CHANGES.txt (original)
+++ ant/ivy/core/branches/2.3.x/CHANGES.txt Thu Aug 23 08:39:46 2012
@@ -133,6 +133,8 @@ for detailed view of each issue, please 
 - FIX: Maven 'hk2-jar' packaging is now supported (IVY-1357)
 - FIX: Maven 'orbit' and 'pear' packaging is now supported (IVY-899)
 - FIX: Memory leak and infinite loop in ModuleId.java (IVY-1362)
+- FIX: Unnecessary warning when parent ivy.xml is not found (IVY-1346)
+- FIX: StackOverflowError when using <extends> and ../ivy.xml is not the parent ivy.xml
(IVY-1437)
 - FIX: NullPointerExeption in AbstractOSGiResolver (IVY-1343) (thanks to Thomas Kurpick)
 - FIX: Delivered ivy descriptor inconsistent with resolve report / retrieve and other post-resolve
actions (IVY-1300) (thanks to Ed Burcher)
 - FIX: The Updatesite resolver is downloading Eclipse features instead of Eclipse bundle/plugin

Modified: ant/ivy/core/branches/2.3.x/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/branches/2.3.x/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java?rev=1376406&r1=1376405&r2=1376406&view=diff
==============================================================================
--- ant/ivy/core/branches/2.3.x/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java
(original)
+++ ant/ivy/core/branches/2.3.x/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java
Thu Aug 23 08:39:46 2012
@@ -21,10 +21,11 @@ import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
 import java.net.URL;
 import java.text.ParseException;
 import java.util.Arrays;
-import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Locale;
@@ -58,7 +59,6 @@ import org.apache.ivy.core.resolve.Resol
 import org.apache.ivy.core.resolve.ResolveEngine;
 import org.apache.ivy.core.resolve.ResolveOptions;
 import org.apache.ivy.core.resolve.ResolvedModuleRevision;
-import org.apache.ivy.core.settings.IvySettings;
 import org.apache.ivy.plugins.conflict.ConflictManager;
 import org.apache.ivy.plugins.conflict.FixedConflictManager;
 import org.apache.ivy.plugins.matcher.PatternMatcher;
@@ -70,7 +70,8 @@ import org.apache.ivy.plugins.parser.Par
 import org.apache.ivy.plugins.repository.Resource;
 import org.apache.ivy.plugins.repository.url.URLResource;
 import org.apache.ivy.plugins.resolver.DependencyResolver;
-import org.apache.ivy.plugins.resolver.URLResolver;
+import org.apache.ivy.plugins.resolver.FileSystemResolver;
+import org.apache.ivy.util.FileUtil;
 import org.apache.ivy.util.DateUtil;
 import org.apache.ivy.util.Message;
 import org.apache.ivy.util.XMLHelper;
@@ -405,15 +406,15 @@ public class XmlModuleDescriptorParser e
 
             //check on filesystem based on location attribute (for dev ONLY)
             try {
-                checkParentModuleOnFilesystem(location, parentMrid);
+                DependencyResolver parentResolver = checkParentModuleOnFilesystem(location,
parentMrid);
+                if (parentResolver != null) {
+                    parent = resolveParentFromModuleInheritanceRepository(parentResolver,
parentMrid);
+                }
             } catch (IOException e) {
                 Message.warn("Unable to parse included ivy file " + location + ": " 
                     + e.getMessage());
             }
             
-            // Resolve parent module descriptor from module inheritance repository
-            parent = resolveParentFromModuleInheritanceRepository(parentMrid);
-            
             // if not found, tries to resolve using repositories
             if (parent == null) {
                 try {
@@ -597,28 +598,32 @@ public class XmlModuleDescriptorParser e
          * @throws IOException
          * @throws ParseException 
          */
-        protected void checkParentModuleOnFilesystem(String location, ModuleRevisionId parentMrid)
throws IOException, ParseException {
-            IvyContext ivyContext = IvyContext.getContext();
-            File file = new File(location);
-            URL url = null;
-            if (file.isAbsolute()) {
-                url = getSettings().getRelativeUrlResolver().getURL(descriptorURL,
-                    file.getAbsolutePath(), location);
-            } else {
-                url = getSettings().getRelativeUrlResolver().getURL(descriptorURL, location);
+        protected DependencyResolver checkParentModuleOnFilesystem(String location, ModuleRevisionId
parentMrid) throws IOException {
+            if (!"file".equals(descriptorURL.getProtocol())) {
+                return null;
             }
-            // Is parent module reachable using location attribute?
-            if (url.openConnection().getContentLength() > 0) {
-                String urlString = url.toExternalForm();
-                if (!ivyContext.getSettings().hasResolver(getModuleInheritanceRepositoryParentResolverName(parentMrid)))
{
-                    Message.debug("Registering parent module into module inheritance repository
map. Parent module location: " + urlString);
-                    URLResolver parentModuleResolver = new URLResolver();
-                    parentModuleResolver.setName(getModuleInheritanceRepositoryParentResolverName(parentMrid));
-                    parentModuleResolver.addIvyPattern(url.toExternalForm());
-                    // Do we even need to be adding this resolver to the Ivy settings considering
that it's being placed in the map and not being used elsewhere?
-                    ivyContext.getSettings().addResolver(parentModuleResolver);
+            
+            File file = new File(location);
+            if (!file.isAbsolute()) {
+                URL url = new URL(descriptorURL, location);
+                try {
+                    file = new File(new URI(url.toExternalForm()));
+                } catch (URISyntaxException e) {
+                    file = new File(url.getPath());
                 }
             }
+            
+            file = FileUtil.normalize(file.getAbsolutePath());
+            if (!file.exists()) {
+                Message.verbose("Parent module doesn't exist on the filesystem: " + file.getAbsolutePath());
+                return null;
+            }
+            
+            FileSystemResolver parentModuleResolver = new FileSystemResolver();
+            parentModuleResolver.setName(getModuleInheritanceRepositoryParentResolverName(parentMrid));
+            parentModuleResolver.addIvyPattern(file.getAbsolutePath());
+            parentModuleResolver.setSettings(IvyContext.getContext().getSettings());
+            return parentModuleResolver;
         }
 
         /**
@@ -655,7 +660,7 @@ public class XmlModuleDescriptorParser e
          * @return a {@link ModuleDescriptor} if found. Return null if no {@link ModuleDescriptor}
was found
          * @throws ParseException
          */
-        protected ModuleDescriptor resolveParentFromModuleInheritanceRepository(ModuleRevisionId
parentMrid) throws ParseException {
+        protected ModuleDescriptor resolveParentFromModuleInheritanceRepository(DependencyResolver
resolver, ModuleRevisionId parentMrid) throws ParseException {
             Message.debug("Trying to resolve included ivy file from module inheritance repository
" );
             DependencyDescriptor dd = new DefaultDependencyDescriptor(parentMrid, true);
             ResolveEngine engine = IvyContext.getContext().getIvy().getResolveEngine();
@@ -664,14 +669,6 @@ public class XmlModuleDescriptorParser e
             options.setDownload(false);
             ResolveData data = new ResolveData(engine, options);
 
-            IvySettings settings = IvyContext.getContext().getSettings();
-            String resolverName = getModuleInheritanceRepositoryParentResolverName(parentMrid);
-            if (!settings.hasResolver(resolverName)) {
-                // The parent resolver will not exist if its dev-only filesystem path hasn't
been specified via the location attribute of the extends element. 
-                return null;
-            }
-            
-            DependencyResolver resolver = settings.getResolver(resolverName);
             dd = NameSpaceHelper.toSystem(dd, getSettings().getContextNamespace());
             ResolvedModuleRevision otherModule = resolver.getDependency(dd, data);
             if (otherModule != null) {

Modified: ant/ivy/core/branches/2.3.x/test/java/org/apache/ivy/core/resolve/ResolveTest.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/branches/2.3.x/test/java/org/apache/ivy/core/resolve/ResolveTest.java?rev=1376406&r1=1376405&r2=1376406&view=diff
==============================================================================
--- ant/ivy/core/branches/2.3.x/test/java/org/apache/ivy/core/resolve/ResolveTest.java (original)
+++ ant/ivy/core/branches/2.3.x/test/java/org/apache/ivy/core/resolve/ResolveTest.java Thu
Aug 23 08:39:46 2012
@@ -44,6 +44,7 @@ import org.apache.ivy.core.deliver.Deliv
 import org.apache.ivy.core.module.descriptor.Artifact;
 import org.apache.ivy.core.module.descriptor.DefaultArtifact;
 import org.apache.ivy.core.module.descriptor.DependencyDescriptor;
+import org.apache.ivy.core.module.descriptor.ExtendsDescriptor;
 import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
 import org.apache.ivy.core.module.id.ModuleId;
 import org.apache.ivy.core.module.id.ModuleRevisionId;
@@ -3398,6 +3399,24 @@ public class ResolveTest extends TestCas
         assertTrue(modRevIds.contains(ModuleRevisionId.newInstance("org", "badArtifact",
"1.0.0.m4", extra)));
     }
 
+    public void testIVY1347() throws Exception {
+        Ivy ivy = new Ivy();
+        ivy.configure(new File("test/repositories/IVY-1347/ivysettings.xml"));
+        ivy.getSettings().setDefaultCache(cache);
+
+        ResolveReport rr = ivy.resolve(new File("test/repositories/IVY-1347/childone/childtwo/ivy.xml").toURI().toURL(),
+            getResolveOptions(new String[] {"*"}));
+        ModuleDescriptor md = rr.getModuleDescriptor();
+        assertNotNull(md);
+        
+        ExtendsDescriptor[] parents = md.getInheritedDescriptors();
+        assertNotNull(parents);
+        assertEquals(1, parents.length);
+        
+        ModuleRevisionId parent = parents[0].getParentRevisionId();
+        assertEquals(ModuleRevisionId.newInstance("foo", "parent", "1.0"), parent);
+    }
+
     public void testIVY999() throws Exception {
         Ivy ivy = new Ivy();
         ivy.configure(new File("test/repositories/IVY-999/ivysettings.xml"));



Mime
View raw message