You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ivy-commits@incubator.apache.org by ma...@apache.org on 2007/03/27 20:44:24 UTC

svn commit: r523069 - in /incubator/ivy/core/trunk: ./ src/java/org/apache/ivy/ant/ test/java/org/apache/ivy/ant/

Author: maartenc
Date: Tue Mar 27 13:44:23 2007
New Revision: 523069

URL: http://svn.apache.org/viewvc?view=rev&rev=523069
Log:
FIX: IvyPostResolve Task doesn't use specified cache for the resolve (IVY-453)

Modified:
    incubator/ivy/core/trunk/CHANGES.txt
    incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyArtifactProperty.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyArtifactReport.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyPostResolveTask.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyTask.java
    incubator/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyCacheFilesetTest.java

Modified: incubator/ivy/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/CHANGES.txt?view=diff&rev=523069&r1=523068&r2=523069
==============================================================================
--- incubator/ivy/core/trunk/CHANGES.txt (original)
+++ incubator/ivy/core/trunk/CHANGES.txt Tue Mar 27 13:44:23 2007
@@ -18,6 +18,7 @@
 - IMPROVE: New "modules in use" section in console report at the end of resolve (IVY-373) (thanks to John Wiliams)
 - IMPROVE: Generated XML reports now contains more information about the resolved module (IVY-446)
 
+- FIX: IvyPostResolve Task doesn't use specified cache for the resolve (IVY-453)
 - FIX: XmlModuleDescriptorWriterTest not working with Java 6 (IVY-374)
 - FIX: Conflict managers ignored, when assigned to modules in Ivy configuration (setting, ivyconf.xml) (IVY-448)
 - FIX: Ivy should fail if ';' has been used in publications/artifact/@conf of ivy.xml (IVY-441)

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyArtifactProperty.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyArtifactProperty.java?view=diff&rev=523069&r1=523068&r2=523069
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyArtifactProperty.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyArtifactProperty.java Tue Mar 27 13:44:23 2007
@@ -100,7 +100,11 @@
         _organisation = getProperty(_organisation, settings, "ivy.organisation", _resolveId);
         _module = getProperty(_module, settings, "ivy.module", _resolveId);
 
-        ensureResolved(isHaltonfailure(), false, getOrganisation(), getModule(), _resolveId);
+        if (_cache == null) {
+            _cache = settings.getDefaultCache();
+        }
+
+        ensureResolved(isHaltonfailure(), false, getOrganisation(), getModule(), _resolveId, _cache);
         
         _conf = getProperty(_conf, settings, "ivy.resolved.configurations", _resolveId);
         if ("*".equals(_conf)) {
@@ -113,9 +117,6 @@
         _organisation = getProperty(_organisation, settings, "ivy.organisation", _resolveId);
         _module = getProperty(_module, settings, "ivy.module", _resolveId);
         
-        if (_cache == null) {
-            _cache = settings.getDefaultCache();
-        }
         
         if ((_organisation == null) && (_resolveId == null)) {
             throw new BuildException("no organisation provided for ivy artifactproperty: It can either be set explicitely via the attribute 'organisation' or via 'ivy.organisation' property or a prior call to <resolve/>");

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyArtifactReport.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyArtifactReport.java?view=diff&rev=523069&r1=523068&r2=523069
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyArtifactReport.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyArtifactReport.java Tue Mar 27 13:44:23 2007
@@ -105,16 +105,16 @@
 
         Ivy ivy = getIvyInstance();
         IvySettings settings = ivy.getSettings();
+        if (_cache == null) {
+            _cache = settings.getDefaultCache();
+        }
 
-        ensureResolved(isHaltonfailure(), false, null, null, _resolveId);
+        ensureResolved(isHaltonfailure(), false, null, null, _resolveId, _cache);
 
         String organisation = getProperty(null, settings, "ivy.organisation", _resolveId);
         String module = getProperty(null, settings, "ivy.module", _resolveId);
         String revision = getProperty(Ivy.getWorkingRevision(), settings, "ivy.revision", _resolveId);
 
-        if (_cache == null) {
-            _cache = settings.getDefaultCache();
-        }
         _pattern = getProperty(_pattern, settings, "ivy.retrieve.pattern");
         _conf = getProperty(_conf, settings, "ivy.resolved.configurations", _resolveId);
         if ("*".equals(_conf)) {

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyPostResolveTask.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyPostResolveTask.java?view=diff&rev=523069&r1=523068&r2=523069
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyPostResolveTask.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyPostResolveTask.java Tue Mar 27 13:44:23 2007
@@ -74,6 +74,10 @@
         _organisation = getProperty(_organisation, settings, "ivy.organisation");
         _module = getProperty(_module, settings, "ivy.module");
         
+        if (_cache == null) {
+            _cache = settings.getDefaultCache();
+        }
+
         if (isInline()) {
         	_conf = _conf == null ? "*" : _conf;
             if (_organisation == null) {
@@ -110,7 +114,7 @@
         	// there (TODO: maybe we can check which reports exist and extract the configurations
         	// from these report names?)
         	if (!orgAndModSetManually) {
-        		ensureResolved(isHaltonfailure(), isUseOrigin(), isTransitive(), getOrganisation(), getModule(), getProperty(_conf, settings, "ivy.resolved.configurations"), _resolveId);
+        		ensureResolved(isHaltonfailure(), isUseOrigin(), isTransitive(), getOrganisation(), getModule(), getProperty(_conf, settings, "ivy.resolved.configurations"), _resolveId, _cache);
         	}
         	
 	        _conf = getProperty(_conf, settings, "ivy.resolved.configurations");
@@ -131,9 +135,6 @@
         }
         if (_conf == null) {
             throw new BuildException("no conf provided for ivy cache task: It can either be set explicitely via the attribute 'conf' or via 'ivy.resolved.configurations' property or a prior call to <resolve/>");
-        }
-        if (_cache == null) {
-            _cache = settings.getDefaultCache();
         }
         if (_resolveId == null) {
         	_resolveId = ResolveOptions.getDefaultResolveId(getResolvedModuleId());

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyTask.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyTask.java?view=diff&rev=523069&r1=523068&r2=523069
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyTask.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyTask.java Tue Mar 27 13:44:23 2007
@@ -17,6 +17,7 @@
  */
 package org.apache.ivy.ant;
 
+import java.io.File;
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.util.Arrays;
@@ -135,10 +136,10 @@
     	}
     }
     
-	protected void ensureResolved(boolean haltOnFailure, boolean useOrigin, String org, String module, String resolveId) {
-    	ensureResolved(haltOnFailure, useOrigin, true, org, module, null, resolveId);
+	protected void ensureResolved(boolean haltOnFailure, boolean useOrigin, String org, String module, String resolveId, File cache) {
+    	ensureResolved(haltOnFailure, useOrigin, true, org, module, null, resolveId, cache);
     }
-    protected void ensureResolved(boolean haltOnFailure, boolean useOrigin, boolean transitive, String org, String module, String conf, String resolveId) {
+    protected void ensureResolved(boolean haltOnFailure, boolean useOrigin, boolean transitive, String org, String module, String conf, String resolveId, File cache) {
         ensureMessageInitialised();
         
         String[] confs = null;
@@ -150,6 +151,7 @@
         
         if (confs.length > 0)  {
         	IvyResolve resolve = createResolve(haltOnFailure, useOrigin);
+        	resolve.setCache(cache);
         	resolve.setTransitive(transitive);
         	resolve.setConf(StringUtils.join(confs, ", "));
         	resolve.setResolveId(resolveId);

Modified: incubator/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyCacheFilesetTest.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyCacheFilesetTest.java?view=diff&rev=523069&r1=523068&r2=523069
==============================================================================
--- incubator/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyCacheFilesetTest.java (original)
+++ incubator/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyCacheFilesetTest.java Tue Mar 27 13:44:23 2007
@@ -78,6 +78,11 @@
 				organisation, module, revision, artifact, type, ext);
 	}
 
+    private File getArchiveFileInCache(String organisation, String module, String revision, String artifact, String type, String ext, File cache) {
+		return TestHelper.getArchiveFileInCache(_fileset.getIvyInstance(), cache, 
+				organisation, module, revision, artifact, type, ext);
+	}
+
 	public void testEmptyConf() throws Exception {
         _project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-108.xml");
         _fileset.setSetid("emptyconf-setid");
@@ -112,4 +117,30 @@
             fail("failure raised an exception with haltonfailure set to false");
         }
     }
+    
+    public void testWithoutPreviousResolveAndNonDefaultCache() throws Exception {
+    	File cache2 = new File("build/cache2");
+    	cache2.mkdirs();
+    	
+    	try {
+	        _project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-simple.xml");
+	        _fileset.setSetid("simple-setid");
+	        _fileset.setCache(cache2);
+	        _fileset.execute();
+	        Object ref = _project.getReference("simple-setid");
+	        assertNotNull(ref);
+	        assertTrue(ref instanceof FileSet);
+	        FileSet fs = (FileSet)ref;
+	        DirectoryScanner directoryScanner = fs.getDirectoryScanner(_project);
+	        assertEquals(1, directoryScanner.getIncludedFiles().length);
+	        assertEquals(getArchiveFileInCache("org1", "mod1.2", "2.0", "mod1.2", "jar", "jar", cache2).getAbsolutePath(),
+	                new File("build/cache2/"+directoryScanner.getIncludedFiles()[0]).getAbsolutePath());
+    	} finally {
+            Delete del = new Delete();
+            del.setProject(new Project());
+            del.setDir(cache2);
+            del.execute();
+    	}
+    }
+    
 }