ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xav...@apache.org
Subject svn commit: r600411 - in /ant/ivy/core/trunk: src/example/build-a-ivy-repository/myrepository/ src/example/build-a-ivy-repository/myrepository/advanced/ src/example/build-a-ivy-repository/myrepository/advanced/apache/ src/example/build-a-ivy-repository...
Date Sun, 02 Dec 2007 23:48:46 GMT
Author: xavier
Date: Sun Dec  2 15:48:41 2007
New Revision: 600411

URL: http://svn.apache.org/viewvc?rev=600411&view=rev
Log:
FIX: download failed log when using a chain of resolver for artifact download, when any element
of the chain does not find the artifact

Added:
    ant/ivy/core/trunk/src/example/build-a-ivy-repository/myrepository/
    ant/ivy/core/trunk/src/example/build-a-ivy-repository/myrepository/advanced/
    ant/ivy/core/trunk/src/example/build-a-ivy-repository/myrepository/advanced/apache/
    ant/ivy/core/trunk/src/example/build-a-ivy-repository/myrepository/advanced/apache/commons-lang/
Modified:
    ant/ivy/core/trunk/src/java/org/apache/ivy/core/cache/CacheManager.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/core/report/ArtifactDownloadReport.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/BasicResolver.java
    ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/ChainResolverTest.java
    ant/ivy/core/trunk/test/java/org/apache/ivy/util/MockMessageLogger.java

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/cache/CacheManager.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/cache/CacheManager.java?rev=600411&r1=600410&r2=600411&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/cache/CacheManager.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/cache/CacheManager.java Sun Dec  2 15:48:41
2007
@@ -34,19 +34,15 @@
 import org.apache.ivy.core.report.ArtifactDownloadReport;
 import org.apache.ivy.core.report.DownloadStatus;
 import org.apache.ivy.core.resolve.DefaultModuleRevision;
-import org.apache.ivy.core.resolve.ResolveData;
 import org.apache.ivy.core.resolve.ResolvedModuleRevision;
 import org.apache.ivy.plugins.lock.LockStrategy;
 import org.apache.ivy.plugins.namespace.NameSpaceHelper;
-import org.apache.ivy.plugins.namespace.Namespace;
 import org.apache.ivy.plugins.parser.ModuleDescriptorParser;
 import org.apache.ivy.plugins.parser.ModuleDescriptorParserRegistry;
 import org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorParser;
 import org.apache.ivy.plugins.repository.ArtifactResourceResolver;
-import org.apache.ivy.plugins.repository.Resource;
 import org.apache.ivy.plugins.repository.ResourceDownloader;
 import org.apache.ivy.plugins.repository.ResourceHelper;
-import org.apache.ivy.plugins.resolver.BasicResolver;
 import org.apache.ivy.plugins.resolver.DependencyResolver;
 import org.apache.ivy.plugins.resolver.util.ResolvedResource;
 import org.apache.ivy.util.Message;
@@ -427,8 +423,9 @@
                             adr.setDownloadedFile(archiveFile);
                         }
                     } else {
-                        // this exception is catched below and result in a download failed
status
-                        throw new Exception("artifact missing");
+                        adr.setDownloadStatus(DownloadStatus.FAILED);
+                        adr.setDownloadDetails(ArtifactDownloadReport.MISSING_ARTIFACT);
+                        adr.setDownloadTimeMillis(System.currentTimeMillis() - start);
                     }
                 } catch (Exception ex) {
                     adr.setDownloadStatus(DownloadStatus.FAILED);
@@ -437,8 +434,7 @@
                 }
             }
             if (listener != null) {
-                listener.endArtifactDownload(this, artifact, adr,
-                    archiveFile);
+                listener.endArtifactDownload(this, artifact, adr, archiveFile);
             }
             return adr;
         } finally {

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/report/ArtifactDownloadReport.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/report/ArtifactDownloadReport.java?rev=600411&r1=600410&r2=600411&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/report/ArtifactDownloadReport.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/report/ArtifactDownloadReport.java Sun
Dec  2 15:48:41 2007
@@ -30,6 +30,17 @@
  * </p>
  */
 public class ArtifactDownloadReport {
+    /**
+     * download details used when the download "fails" when the artifact is simply missing
on the
+     * remote repository.
+     * <p>
+     * For historical reason the status can't be used to distinguish a real failure from
a missing
+     * artifact by using the status, in both cases it's DownloadStatus.FAILED. The details
message
+     * can be used for this purpose though.
+     * </p>
+     */
+    public static final String MISSING_ARTIFACT = "missing artifact";
+    
     private Artifact artifact;
 
     private ArtifactOrigin origin;
@@ -108,7 +119,7 @@
         if (downloadStatus == DownloadStatus.SUCCESSFUL) {
             return "[SUCCESSFUL ] " + artifact + " (" + downloadTimeMillis + "ms)";
         } else if (downloadStatus == DownloadStatus.FAILED) {
-            return "[FAILED     ] " + artifact + " : " + downloadDetails
+            return "[FAILED     ] " + artifact + ": " + downloadDetails
                 + " (" + downloadTimeMillis + "ms)";
         } else if (downloadStatus == DownloadStatus.NO) {
             return "[NOT REQUIRED] " + artifact;

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/BasicResolver.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/BasicResolver.java?rev=600411&r1=600410&r2=600411&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/BasicResolver.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/BasicResolver.java Sun Dec
 2 15:48:41 2007
@@ -619,7 +619,13 @@
                 artifacts[i], artifactResourceResolver, downloader, 
                 new CacheDownloadOptions().setListener(downloadListener)
                     .setUseOrigin(options.isUseOrigin()));
-            Message.info("\t" + adr);
+            if (DownloadStatus.FAILED == adr.getDownloadStatus()) {
+                if (!ArtifactDownloadReport.MISSING_ARTIFACT.equals(adr.getDownloadDetails()))
{
+                    Message.warn("\t" + adr);
+                }
+            } else {
+                Message.info("\t" + adr);
+            }
             dr.addArtifactReport(adr);
             checkInterrupted();
         }

Modified: ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/ChainResolverTest.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/ChainResolverTest.java?rev=600411&r1=600410&r2=600411&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/ChainResolverTest.java (original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/ChainResolverTest.java Sun
Dec  2 15:48:41 2007
@@ -19,16 +19,23 @@
 
 import java.io.File;
 import java.util.Arrays;
+import java.util.Date;
 import java.util.GregorianCalendar;
 import java.util.List;
 
 import junit.framework.TestCase;
 
+import org.apache.ivy.core.IvyContext;
 import org.apache.ivy.core.cache.CacheManager;
 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.DefaultDependencyDescriptor;
 import org.apache.ivy.core.module.descriptor.DependencyDescriptor;
 import org.apache.ivy.core.module.id.ModuleRevisionId;
+import org.apache.ivy.core.report.DownloadReport;
+import org.apache.ivy.core.report.DownloadStatus;
+import org.apache.ivy.core.resolve.DownloadOptions;
 import org.apache.ivy.core.resolve.ResolveData;
 import org.apache.ivy.core.resolve.ResolveEngine;
 import org.apache.ivy.core.resolve.ResolveOptions;
@@ -38,6 +45,8 @@
 import org.apache.ivy.core.sort.SortEngine;
 import org.apache.ivy.plugins.latest.LatestRevisionStrategy;
 import org.apache.ivy.plugins.latest.LatestTimeStrategy;
+import org.apache.ivy.util.Message;
+import org.apache.ivy.util.MockMessageLogger;
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.taskdefs.Delete;
 
@@ -446,4 +455,45 @@
         assertEquals("chain", rmr.getArtifactResolver().getName());
     }
 
+    public void testDownloadWithDual() throws Exception {
+        ChainResolver chain = new ChainResolver();
+        chain.setName("chain");
+        chain.setSettings(settings);
+        chain.setDual(true);
+
+        // first resolver has only an artifact pattern which don't lead to anything: it won't
find the module
+        FileSystemResolver resolver = new FileSystemResolver();
+        resolver.setName("1");
+        resolver.setSettings(settings);
+        resolver.addArtifactPattern(
+            "test/repositories/nowhere/[organisation]/[module]/[type]s/[artifact]-[revision].[type]");
+
+        chain.add(resolver);
+
+        resolver = new FileSystemResolver();
+        resolver.setName("2");
+        resolver.setSettings(settings);
+
+        resolver.addIvyPattern(
+            "test/repositories/1/[organisation]/[module]/ivys/ivy-[revision].xml");
+        resolver.addArtifactPattern(
+            "test/repositories/1/[organisation]/[module]/[type]s/[artifact]-[revision].[type]");
+        chain.add(resolver);
+
+        settings.addResolver(chain);
+
+        MockMessageLogger mockLogger = new MockMessageLogger();
+        IvyContext.getContext().getIvy().getLoggerEngine().setDefaultLogger(mockLogger);
+        DownloadReport report = chain.download(
+            new Artifact[] {new DefaultArtifact(
+                ModuleRevisionId.parse("org1#mod1.1;1.0"),
+                new Date(), "mod1.1", "jar", "jar")}, 
+            new DownloadOptions(CacheManager.getInstance(settings)));
+        assertNotNull(report);
+        assertEquals(1, report.getArtifactsReports().length);
+        assertEquals(DownloadStatus.SUCCESSFUL, report.getArtifactsReports()[0].getDownloadStatus());
+        mockLogger.assertLogDoesntContain("[FAILED     ] org1#mod1.1;1.0!mod1.1.jar");
+    }
+
+    
 }

Modified: ant/ivy/core/trunk/test/java/org/apache/ivy/util/MockMessageLogger.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/util/MockMessageLogger.java?rev=600411&r1=600410&r2=600411&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/util/MockMessageLogger.java (original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/util/MockMessageLogger.java Sun Dec  2 15:48:41
2007
@@ -81,9 +81,17 @@
         }
         throw new AssertionFailedError("logs do not contain expected message: expected='"
+ message
                 + "' logs='\n" + join(_logs) + "'");
-
     }
 
+    public void assertLogDoesntContain(String message) {
+        for (Iterator iter = _logs.iterator(); iter.hasNext();) {
+            String log = (String) iter.next();
+            if (log.indexOf(message) != -1) {
+                throw new AssertionFailedError("logs contain unexpected message: '" + message
+                    + "' logs='\n" + join(_logs) + "'");
+            }
+        }
+    }
 
     public void assertLogVerboseContains(String message) {
         assertLogContains(Message.MSG_VERBOSE + " " + message);



Mime
View raw message