Author: maartenc
Date: Fri Mar 23 16:23:50 2007
New Revision: 521937

URL: http://svn.apache.org/viewvc?view=rev&rev=521937
Log:
Fixed another problem with resolveId and added extra junit test for IVY-366.

Modified:
    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/IvyCachePathTest.java

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=521937&r1=521936&r2=521937
==============================================================================
--- 
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 
Fri Mar 23 16:23:50 2007
@@ -110,7 +110,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"));
+                       ensureResolved(isHaltonfailure(), isUseOrigin(), 
isTransitive(), getOrganisation(), getModule(), getProperty(_conf, settings, 
"ivy.resolved.configurations"), _resolveId);
                }
                
                _conf = getProperty(_conf, settings, 
"ivy.resolved.configurations");

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=521937&r1=521936&r2=521937
==============================================================================
--- 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 Fri Mar 
23 16:23:50 2007
@@ -135,15 +135,9 @@
        }
     }
     
-       protected void ensureResolved(boolean haltOnFailure, boolean useOrigin, 
String org, String module) {
-               ensureResolved(haltOnFailure, useOrigin, org, module, null);
-       }
        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, 
boolean transitive, String org, String module, String conf) {
-       ensureResolved(haltOnFailure, useOrigin, true, org, module, conf, null);
-    }
     protected void ensureResolved(boolean haltOnFailure, boolean useOrigin, 
boolean transitive, String org, String module, String conf, String resolveId) {
         ensureMessageInitialised();
         
@@ -170,7 +164,12 @@
     }
     
     protected String[] getConfsToResolve(String resolveId, String conf) {
-        ModuleDescriptor reference = (ModuleDescriptor) 
getResolvedDescriptor(resolveId);
+        ModuleDescriptor reference = (ModuleDescriptor) 
getResolvedDescriptor(resolveId, false);
+        if (reference == null) {
+               // assume the module has been resolved outside this build
+               // TODO: find a way to discover which confs were resolved by 
that previous resolve
+               return new String[0];
+        }
         String[] rconfs = (String[]) 
getProject().getReference("ivy.resolved.configurations.ref." + resolveId);
         return getConfsToResolve(reference, conf, rconfs);
     }
@@ -211,8 +210,12 @@
        }
     
     protected Object getResolvedDescriptor(String resolveId) {
+       return getResolvedDescriptor(resolveId, true);
+    }
+    
+    protected Object getResolvedDescriptor(String resolveId, boolean strict) {
        Object result = getProject().getReference("ivy.resolved.descriptor." + 
resolveId);
-        if (result == null) {
+        if (strict && (result == null)) {
                throw new BuildException("ModuleDescriptor for resolve with id 
'" + resolveId + "' not found.");
         }
         return result;

Modified: 
incubator/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyCachePathTest.java
URL: 
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyCachePathTest.java?view=diff&rev=521937&r1=521936&r2=521937
==============================================================================
--- incubator/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyCachePathTest.java 
(original)
+++ incubator/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyCachePathTest.java 
Fri Mar 23 16:23:50 2007
@@ -184,6 +184,37 @@
                 new File(p.list()[0]).getAbsolutePath());
     }
 
+    public void testWithResolveIdWithoutResolve() throws Exception {
+       Project project = new Project();
+        project.setProperty("ivy.settings.file", 
"test/repositories/ivysettings.xml");
+
+       IvyResolve resolve = new IvyResolve();
+       resolve.setProject(project);
+       resolve.setCache(_cache);
+       resolve.setFile(new 
File("test/java/org/apache/ivy/ant/ivy-simple.xml"));
+       resolve.setResolveId("withResolveId");
+       resolve.execute();
+       
+       // resolve another ivy file
+       resolve = new IvyResolve();
+       resolve.setProject(_project);
+       resolve.setCache(_cache);
+       resolve.setFile(new 
File("test/java/org/apache/ivy/ant/ivy-latest.xml"));
+       resolve.execute();
+       
+       _path.setResolveId("withResolveId");
+       _path.setPathid("withresolveid-pathid");
+       _path.execute();
+
+        Object ref = _project.getReference("withresolveid-pathid");
+        assertNotNull(ref);
+        assertTrue(ref instanceof Path);
+        Path p = (Path)ref;
+        assertEquals(1, p.size());
+        assertEquals(getArchiveFileInCache("org1", "mod1.2", "2.0", "mod1.2", 
"jar", "jar").getAbsolutePath(),
+                new File(p.list()[0]).getAbsolutePath());
+    }
+
     private File getArchiveFileInCache(String organisation, String module, 
String revision, String artifact, String type, String ext) {
                return TestHelper.getArchiveFileInCache(_path.getIvyInstance(), 
_cache, 
                                organisation, module, revision, artifact, type, 
ext);


Reply via email to