You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by xa...@apache.org on 2008/07/04 12:53:52 UTC

svn commit: r673998 - in /ant/ivy/core/trunk: ./ src/java/org/apache/ivy/plugins/namespace/ src/java/org/apache/ivy/plugins/resolver/ test/java/org/apache/ivy/ant/ test/repositories/

Author: xavier
Date: Fri Jul  4 03:53:51 2008
New Revision: 673998

URL: http://svn.apache.org/viewvc?rev=673998&view=rev
Log:
FIX: NPE in Ivy:install task if the repository cache dir has been cleared (IVY-843)

Added:
    ant/ivy/core/trunk/test/repositories/ivysettings-IVY843.xml   (with props)
Modified:
    ant/ivy/core/trunk/CHANGES.txt
    ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/namespace/NameSpaceHelper.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/AbstractResolver.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/BasicResolver.java
    ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyInstallTest.java

Modified: ant/ivy/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=673998&r1=673997&r2=673998&view=diff
==============================================================================
--- ant/ivy/core/trunk/CHANGES.txt (original)
+++ ant/ivy/core/trunk/CHANGES.txt Fri Jul  4 03:53:51 2008
@@ -91,6 +91,7 @@
 - IMPROVEMENT: Change allownomd and skipbuildwithoutivy into a more semantically correct name (IVY-297)
 - IMPROVEMENT: Smarter determination if an expression is exact or not for RegexpPatternMatcher and GlobPatternMatcher
 
+- FIX: NPE in Ivy:install task if the repository cache dir has been cleared (IVY-843)
 - FIX: Maven version ranges with ( ) are not supported (IVY-678) (thanks to Michael Kebe)
 - FIX: Ignore maven metadata files when listing revisions (IVY-765)
 - FIX: haltonmissing on publish task does not prevent the other files to be published, even with an atomic publisher (IVY-656)

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/namespace/NameSpaceHelper.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/namespace/NameSpaceHelper.java?rev=673998&r1=673997&r2=673998&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/namespace/NameSpaceHelper.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/namespace/NameSpaceHelper.java Fri Jul  4 03:53:51 2008
@@ -26,6 +26,7 @@
 import org.apache.ivy.core.module.id.ArtifactId;
 import org.apache.ivy.core.module.id.ModuleId;
 import org.apache.ivy.core.module.id.ModuleRevisionId;
+import org.apache.ivy.core.report.MetadataArtifactDownloadReport;
 import org.apache.ivy.core.resolve.ResolvedModuleRevision;
 
 public final class NameSpaceHelper {
@@ -54,7 +55,8 @@
             return rmr;
         }
         return new ResolvedModuleRevision(
-            rmr.getResolver(), rmr.getArtifactResolver(), md, rmr.getReport());
+            rmr.getResolver(), rmr.getArtifactResolver(), md, 
+            transform(rmr.getReport(), ns.getToSystemTransformer()));
     }
 
     public static Artifact transform(Artifact artifact, NamespaceTransformer t) {
@@ -70,6 +72,24 @@
                         .getQualifiedExtraAttributes());
     }
 
+    public static MetadataArtifactDownloadReport transform(
+            MetadataArtifactDownloadReport report, NamespaceTransformer t) {
+        if (t.isIdentity()) {
+            return report;
+        }
+        MetadataArtifactDownloadReport madr = 
+            new MetadataArtifactDownloadReport(transform(report.getArtifact(), t));
+        madr.setSearched(report.isSearched());
+        madr.setDownloadStatus(report.getDownloadStatus());
+        madr.setDownloadDetails(report.getDownloadDetails());
+        madr.setArtifactOrigin(report.getArtifactOrigin());
+        madr.setDownloadTimeMillis(report.getDownloadTimeMillis());
+        madr.setOriginalLocalFile(report.getOriginalLocalFile());
+        madr.setLocalFile(report.getLocalFile());
+        madr.setSize(report.getSize());
+        return madr;
+    }
+
     public static ArtifactId transform(ArtifactId artifactId, NamespaceTransformer t) {
         if (t.isIdentity()) {
             return artifactId;

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/AbstractResolver.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/AbstractResolver.java?rev=673998&r1=673997&r2=673998&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/AbstractResolver.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/AbstractResolver.java Fri Jul  4 03:53:51 2008
@@ -40,6 +40,7 @@
 import org.apache.ivy.core.report.ArtifactDownloadReport;
 import org.apache.ivy.core.report.DownloadReport;
 import org.apache.ivy.core.report.DownloadStatus;
+import org.apache.ivy.core.report.MetadataArtifactDownloadReport;
 import org.apache.ivy.core.resolve.DownloadOptions;
 import org.apache.ivy.core.resolve.IvyNode;
 import org.apache.ivy.core.resolve.ResolveData;
@@ -290,6 +291,10 @@
         return NameSpaceHelper.transform(artifact, getNamespace().getToSystemTransformer());
     }
 
+    protected MetadataArtifactDownloadReport toSystem(MetadataArtifactDownloadReport report) {
+        return NameSpaceHelper.transform(report, getNamespace().getToSystemTransformer());
+    }
+
     protected ResolvedModuleRevision toSystem(ResolvedModuleRevision rmr) {
         return NameSpaceHelper.toSystem(rmr, getNamespace());
     }

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=673998&r1=673997&r2=673998&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 Fri Jul  4 03:53:51 2008
@@ -241,7 +241,8 @@
                         throw new UnresolvedDependencyException();
                     }
                 }
-                if (!rmr.getReport().isDownloaded()) {
+                if (!rmr.getReport().isDownloaded() 
+                        && rmr.getReport().getLocalFile() != null) {
                     return toSystem(rmr);
                 } else {
                     nsMd = rmr.getDescriptor();
@@ -264,16 +265,8 @@
                             checkDescriptorConsistency(systemMrid, systemMd, ivyRef);
                         }
                     }
-                    MetadataArtifactDownloadReport madr = 
-                        new MetadataArtifactDownloadReport(systemMd.getMetadataArtifact());
-                    madr.setDownloadStatus(rmr.getReport().getDownloadStatus());
-                    madr.setDownloadDetails(rmr.getReport().getDownloadDetails());
-                    madr.setArtifactOrigin(rmr.getReport().getArtifactOrigin());
-                    madr.setDownloadTimeMillis(rmr.getReport().getDownloadTimeMillis());
-                    madr.setSize(rmr.getReport().getSize());
-                    madr.setOriginalLocalFile(rmr.getReport().getOriginalLocalFile());
-                    madr.setSearched(true);
-                    rmr = new ResolvedModuleRevision(this, this, systemMd, madr);
+                    rmr = new ResolvedModuleRevision(
+                        this, this, systemMd, toSystem(rmr.getReport()));
                 }
             }
 

Modified: ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyInstallTest.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyInstallTest.java?rev=673998&r1=673997&r2=673998&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyInstallTest.java (original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyInstallTest.java Fri Jul  4 03:53:51 2008
@@ -59,6 +59,7 @@
 
     private void cleanInstall() {
         FileUtil.forceDelete(new File("build/test/install"));
+        FileUtil.forceDelete(new File("build/test/install2"));
     }
 
     public void testInstallDummyDefault() {
@@ -81,6 +82,25 @@
         assertTrue(new File("build/test/install/org1/mod1.2/mod1.2-2.2.jar").exists());
     }
 
+    public void testIVY843() {
+        project.setProperty("ivy.settings.file", "test/repositories/ivysettings-IVY843.xml");
+        install.setOrganisation("org1");
+        install.setModule("mod1.4");
+        install.setRevision("1.0.1");
+        install.setFrom("test");
+        install.setTo("install");
+
+        install.execute();
+        
+        cleanCache();
+        
+        install.setFrom("install");
+        install.setTo("install2");
+        install.execute();
+
+        assertTrue(new File("build/test/install2/org1/mod1.4/ivy-1.0.1.xml").exists());
+    }
+
     public void testInstallWithBranch() {
         project.setProperty("ivy.settings.file", "test/repositories/branches/ivysettings.xml");
         install.setOrganisation("foo");

Added: ant/ivy/core/trunk/test/repositories/ivysettings-IVY843.xml
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/ivysettings-IVY843.xml?rev=673998&view=auto
==============================================================================
--- ant/ivy/core/trunk/test/repositories/ivysettings-IVY843.xml (added)
+++ ant/ivy/core/trunk/test/repositories/ivysettings-IVY843.xml Fri Jul  4 03:53:51 2008
@@ -0,0 +1,52 @@
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+   distributed with this work for additional information
+   regarding copyright ownership.  The ASF licenses this file
+   to you under the Apache License, Version 2.0 (the
+   "License"); you may not use this file except in compliance
+   with the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing,
+   software distributed under the License is distributed on an
+   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+   KIND, either express or implied.  See the License for the
+   specific language governing permissions and limitations
+   under the License.    
+-->
+<ivysettings>
+	<properties file="${ivy.settings.dir}/ivysettings.properties" />
+	<settings defaultResolver="dummy" />
+	<caches defaultCacheDir="${cache.dir}" useOrigin="true" />
+	<resolvers>
+		<chain name="test">
+			<filesystem name="1">
+				<ivy pattern="${ivy.settings.dir}/1/[organisation]/[module]/ivys/ivy-[revision].xml"/>
+				<artifact pattern="${ivy.settings.dir}/1/[organisation]/[module]/[type]s/[artifact]-[revision].[ext]"/>
+			</filesystem>
+			<dual name="2">
+				<filesystem name="2-ivy">
+					<ivy pattern="${ivy.settings.dir}/2/[module]/ivy-[revision].xml"/>
+				</filesystem>
+				<filesystem name="2-artifact">
+					<artifact pattern="${ivy.settings.dir}/2/[module]/[artifact]-[revision].[ext]"/>
+					<artifact pattern="${ivy.settings.dir}/2/[module]/[artifact].[ext]"/>
+				</filesystem>
+			</dual>
+		</chain>
+		<filesystem name="dummy">
+			<ivy pattern="dummy/[organisation]/[module]/[artifact]-[revision].[ext]"/>
+			<artifact pattern="dummy/[organisation]/[module]/[artifact]-[revision].[ext]"/>
+		</filesystem>
+		<filesystem name="install">
+			<ivy pattern="build/test/install/[organisation]/[module]/[artifact]-[revision].[ext]"/>
+			<artifact pattern="build/test/install/[organisation]/[module]/[artifact]-[revision].[ext]"/>
+		</filesystem>
+		<filesystem name="install2">
+			<ivy pattern="build/test/install2/[organisation]/[module]/[artifact]-[revision].[ext]"/>
+			<artifact pattern="build/test/install2/[organisation]/[module]/[artifact]-[revision].[ext]"/>
+		</filesystem>
+	</resolvers>
+</ivysettings>

Propchange: ant/ivy/core/trunk/test/repositories/ivysettings-IVY843.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/ivy/core/trunk/test/repositories/ivysettings-IVY843.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain