Return-Path:
+ * 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. + *
+ */ + 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);