Return-Path: Delivered-To: apmail-ant-notifications-archive@locus.apache.org Received: (qmail 89240 invoked from network); 28 Aug 2008 15:58:08 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 28 Aug 2008 15:58:08 -0000 Received: (qmail 3959 invoked by uid 500); 28 Aug 2008 15:58:06 -0000 Delivered-To: apmail-ant-notifications-archive@ant.apache.org Received: (qmail 3937 invoked by uid 500); 28 Aug 2008 15:58:06 -0000 Mailing-List: contact notifications-help@ant.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ant.apache.org Delivered-To: mailing list notifications@ant.apache.org Received: (qmail 3928 invoked by uid 99); 28 Aug 2008 15:58:06 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 28 Aug 2008 08:58:06 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 28 Aug 2008 15:57:03 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 854F4238896C; Thu, 28 Aug 2008 08:56:56 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r689864 - in /ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse: CHANGES.txt src/java/org/apache/ivyde/eclipse/cpcontainer/IvyResolveJob.java Date: Thu, 28 Aug 2008 15:56:56 -0000 To: notifications@ant.apache.org From: xavier@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080828155656.854F4238896C@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: xavier Date: Thu Aug 28 08:56:55 2008 New Revision: 689864 URL: http://svn.apache.org/viewvc?rev=689864&view=rev Log: FIX: same jar files get downloaded 3 times (binary, javadoc and sources jar files are identical) (IVYDE-117) Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/CHANGES.txt ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyResolveJob.java Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/CHANGES.txt URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/CHANGES.txt?rev=689864&r1=689863&r2=689864&view=diff ============================================================================== --- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/CHANGES.txt (original) +++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/CHANGES.txt Thu Aug 28 08:56:55 2008 @@ -11,6 +11,7 @@ - IMPROVE: Retrieve after resolve feature does not clean target directory first (IVYDE-105) +- FIX: same jar files get downloaded 3 times (binary, javadoc and sources jar files are identical) (IVYDE-117) - FIX: IvyDE crashes during resolve due to an incompatibility with Eclipse 3.2 (IVYDE-108) - FIX: Ivy preferences page mentions ivyconf not ivysettings (IVYDE-103) - FIX: Resolve is not triggered anymore with Eclipse 3.4 (IVYDE-110) Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyResolveJob.java URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyResolveJob.java?rev=689864&r1=689863&r2=689864&view=diff ============================================================================== --- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyResolveJob.java (original) +++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyResolveJob.java Thu Aug 28 08:56:55 2008 @@ -35,6 +35,7 @@ import java.util.Set; import org.apache.ivy.Ivy; +import org.apache.ivy.core.cache.ArtifactOrigin; import org.apache.ivy.core.cache.DefaultRepositoryCacheManager; import org.apache.ivy.core.cache.RepositoryCacheManager; import org.apache.ivy.core.event.IvyEvent; @@ -569,41 +570,68 @@ .getPublicationDate(), artifact.getName(), metaType, "jar", extraAtt); RepositoryCacheManager cache = ivy.getSettings() .getResolver(artifact.getModuleRevisionId()).getRepositoryCacheManager(); - if (cache instanceof DefaultRepositoryCacheManager) { - File metaArtifactFile = ((DefaultRepositoryCacheManager) cache) - .getArchiveFileInCache(metaArtifact); - File attempt = new File(metaArtifactFile.getAbsolutePath() + ".notfound"); - if (metaArtifactFile.exists()) { - return new Path(metaArtifactFile.getAbsolutePath()); - } else if (attempt.exists()) { - return null; - } else { - Message.info("checking " + metaType + " for " + artifact); - ivy.getResolveEngine().download(metaArtifact, new DownloadOptions()); - if (metaArtifactFile.exists()) { - return new Path(metaArtifactFile.getAbsolutePath()); - } - // meta artifact not found, we store this information to avoid other - // attempts later - Message.info(metaType + " not found for " + artifact); - try { - attempt.getParentFile().mkdirs(); - attempt.createNewFile(); - } catch (IOException e) { - Message.error("impossible to create attempt file " + attempt + ": " + e); - } - return null; - } + if (! (cache instanceof DefaultRepositoryCacheManager)) { + /* + * we're not using a default implementation of repository cache manager, so we don't + * cache attempts to locate metadata artifacts + */ + Path metaArtifactLocalPath = downloadMetaArtifact(adr, metaType, metaArtifact); + if (metaArtifactLocalPath != null) { + return metaArtifactLocalPath; + } + Message.info(metaType + " not found for " + artifact); + Message.verbose( + "Attempt not stored in cache because a non Default cache implementation is used."); + return null; } - Message.info("checking " + metaType + " for " + artifact); - ArtifactDownloadReport metaAdr = ivy.getResolveEngine().download(metaArtifact, - new DownloadOptions()); - if (metaAdr.getLocalFile() != null && metaAdr.getLocalFile().exists()) { - return new Path(metaAdr.getLocalFile().getAbsolutePath()); + + File metaArtifactFile = ((DefaultRepositoryCacheManager) cache) + .getArchiveFileInCache(metaArtifact); + File attempt = new File(metaArtifactFile.getAbsolutePath() + ".notfound"); + if (metaArtifactFile.exists()) { + return new Path(metaArtifactFile.getAbsolutePath()); + } else if (attempt.exists()) { + return null; + } + Path metaArtifactLocalPath = downloadMetaArtifact(adr, metaType, metaArtifact); + if (metaArtifactLocalPath != null) { + return metaArtifactLocalPath; } Message.info(metaType + " not found for " + artifact); - Message - .verbose("Attempt not stored in cache because a non Default cache implementation is used."); + /* + * meta artifact not found, we store this information to avoid other attempts later + */ + try { + attempt.getParentFile().mkdirs(); + attempt.createNewFile(); + } catch (IOException e) { + Message.error("impossible to create attempt file " + attempt + ": " + e); + } + return null; + } + + private Path downloadMetaArtifact(ArtifactDownloadReport adr, String metaType, + Artifact metaArtifact) { + Artifact artifact = adr.getArtifact(); + Message.info("checking " + metaType + " for " + artifact ); + ArtifactOrigin origin = ivy.getResolveEngine().locate(metaArtifact); + if (!ArtifactOrigin.isUnknown(origin)) { + /* + * fix for IVYDE-117: we need to check that the location of this metadata + * artifact is different from the original artifact + */ + if (adr.getArtifactOrigin() != null + && (ArtifactOrigin.isUnknown(adr.getArtifactOrigin()) + || !origin.getLocation() + .equals(adr.getArtifactOrigin().getLocation()))) { + ArtifactDownloadReport metaAdr = ivy.getResolveEngine() + .download(origin, new DownloadOptions()); + File localFile = metaAdr.getLocalFile(); + if (localFile != null && localFile.exists()) { + return new Path(localFile.getAbsolutePath()); + } + } + } return null; }