ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maart...@apache.org
Subject svn commit: r643180 - in /ant/ivy/core/trunk: CHANGES.txt src/java/org/apache/ivy/plugins/resolver/RepositoryResolver.java test/java/org/apache/ivy/ant/IvyResolveTest.java test/repositories/norev/ivy.xml
Date Mon, 31 Mar 2008 22:15:53 GMT
Author: maartenc
Date: Mon Mar 31 15:15:41 2008
New Revision: 643180

URL: http://svn.apache.org/viewvc?rev=643180&view=rev
Log:
FIX: resolve fails to put metadata in cache (IVY-779)

Modified:
    ant/ivy/core/trunk/CHANGES.txt
    ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/RepositoryResolver.java
    ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyResolveTest.java
    ant/ivy/core/trunk/test/repositories/norev/ivy.xml

Modified: ant/ivy/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=643180&r1=643179&r2=643180&view=diff
==============================================================================
--- ant/ivy/core/trunk/CHANGES.txt (original)
+++ ant/ivy/core/trunk/CHANGES.txt Mon Mar 31 15:15:41 2008
@@ -75,6 +75,7 @@
 - IMPROVEMENT: Parse description and home page from poms (IVY-767)
 - IMPROVEMENT: Smarter determination if an expression is exact or not for RegexpPatternMatcher
and GlobPatternMatcher
 
+- FIX: resolve fails to put metadata in cache (IVY-779)
 - FIX: multiple cleancache and inline retrieve error (IVY-778)
 - FIX: buildlist evicts modules with the same name, but different organisation (IVY-731)
 - FIX: Out of memory/Stack overflow for new highly coupled project (IVY-595)

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/RepositoryResolver.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/RepositoryResolver.java?rev=643180&r1=643179&r2=643180&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/RepositoryResolver.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/RepositoryResolver.java Mon
Mar 31 15:15:41 2008
@@ -20,6 +20,7 @@
 import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.IOException;
+import java.text.ParseException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -32,9 +33,12 @@
 import org.apache.ivy.core.event.EventManager;
 import org.apache.ivy.core.module.descriptor.Artifact;
 import org.apache.ivy.core.module.descriptor.DefaultArtifact;
+import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
 import org.apache.ivy.core.module.id.ModuleRevisionId;
 import org.apache.ivy.core.report.DownloadReport;
 import org.apache.ivy.core.resolve.DownloadOptions;
+import org.apache.ivy.plugins.parser.ModuleDescriptorParser;
+import org.apache.ivy.plugins.parser.ModuleDescriptorParserRegistry;
 import org.apache.ivy.plugins.repository.AbstractRepository;
 import org.apache.ivy.plugins.repository.Repository;
 import org.apache.ivy.plugins.repository.Resource;
@@ -85,8 +89,26 @@
                 Resource res = repository.getResource(resourceName);
                 boolean reachable = res.exists();
                 if (reachable) {
-                    String revision = pattern.indexOf(IvyPatternHelper.REVISION_KEY) == -1

-                        ? "working@" + name : mrid.getRevision();
+                    String revision;
+                    if (pattern.indexOf(IvyPatternHelper.REVISION_KEY) == -1) {
+                        if ("ivy".equals(artifact.getType()) || "pom".equals(artifact.getType()))
{
+                            // we can't determine the revision from the pattern, get it
+                            // from the moduledescriptor itself
+                            File temp = File.createTempFile("ivy", artifact.getExt());
+                            temp.deleteOnExit();
+                            repository.get(res.getName(), temp);
+                            ModuleDescriptorParser parser = ModuleDescriptorParserRegistry.getInstance().getParser(res);
+                            ModuleDescriptor md = parser.parseDescriptor(getSettings(), temp.toURL(),
res, false);
+                            revision = md.getRevision();
+                            if ((revision == null) || (revision.length() == 0)) {
+                                revision = "working@" + name;
+                            }
+                        } else {
+                            revision = "working@" + name;
+                        }
+                    } else {
+                        revision = mrid.getRevision();
+                    }
                     return new ResolvedResource(res, revision);
                 } else if (versionMatcher.isDynamic(mrid)) {
                     return findDynamicResourceUsingPattern(
@@ -100,6 +122,9 @@
                 return findDynamicResourceUsingPattern(rmdparser, mrid, pattern, artifact,
date);
             }
         } catch (IOException ex) {
+            throw new RuntimeException(name + ": unable to get resource for " + mrid + ":
res="
+                    + IvyPatternHelper.substitute(pattern, mrid, artifact) + ": " + ex, ex);
+        } catch (ParseException ex) {
             throw new RuntimeException(name + ": unable to get resource for " + mrid + ":
res="
                     + IvyPatternHelper.substitute(pattern, mrid, artifact) + ": " + ex, ex);
         }

Modified: ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyResolveTest.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyResolveTest.java?rev=643180&r1=643179&r2=643180&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyResolveTest.java (original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyResolveTest.java Mon Mar 31 15:15:41
2008
@@ -24,6 +24,9 @@
 import org.apache.ivy.Ivy;
 import org.apache.ivy.TestHelper;
 import org.apache.ivy.core.module.id.ModuleRevisionId;
+import org.apache.ivy.core.report.ResolveReport;
+import org.apache.ivy.util.DefaultMessageLogger;
+import org.apache.ivy.util.Message;
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.taskdefs.Delete;
@@ -57,6 +60,24 @@
         del.setProject(new Project());
         del.setDir(cache);
         del.execute();
+    }
+    
+    public void testIVY779() throws Exception {
+        Project project = new Project();
+        project.setProperty("ivy.local.default.root", "test/repositories/norev");
+        project.setProperty("ivy.local.default.ivy.pattern", "[module]/[artifact].[ext]");
+        project.setProperty("ivy.local.default.artifact.pattern", "[module]/[artifact].[ext]");
+
+        resolve.setProject(project);
+        project.setProperty("ivy.cache.dir", cache.getAbsolutePath());
+        resolve.setFile(new File("test/repositories/norev/ivy.xml"));
+        resolve.setKeep(true);
+        resolve.execute();
+        
+        ResolveReport report = (ResolveReport) project.getReference("ivy.resolved.report");
+        assertNotNull(report);
+        assertFalse(report.hasError());
+        assertEquals(1, report.getArtifacts().size());
     }
 
     public void testSimple() throws Exception {

Modified: ant/ivy/core/trunk/test/repositories/norev/ivy.xml
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/norev/ivy.xml?rev=643180&r1=643179&r2=643180&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/repositories/norev/ivy.xml (original)
+++ ant/ivy/core/trunk/test/repositories/norev/ivy.xml Mon Mar 31 15:15:41 2008
@@ -22,6 +22,6 @@
     	<conf name="myconf"/>
     </configurations>
     <dependencies>
-        <dependency conf="myconf -> *" org="myorg" name="module2" rev="latest.integration"
/>
+        <dependency conf="myconf -> *" org="myorg" name="module2" rev="2.0" />
 	</dependencies>
 </ivy-module>



Mime
View raw message