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/04/02 21:17:38 UTC

svn commit: r524924 - in /incubator/ivy/core/trunk: CHANGES.txt doc/doc/use/postresolvetask.html src/java/org/apache/ivy/ant/IvyPostResolveTask.java test/java/org/apache/ivy/ant/IvyCachePathTest.java

Author: maartenc
Date: Mon Apr  2 14:17:37 2007
New Revision: 524924

URL: http://svn.apache.org/viewvc?view=rev&rev=524924
Log:
IMPROVE: Let user specify Ivy file when using a post-resolve task (IVY-455)

Modified:
    incubator/ivy/core/trunk/CHANGES.txt
    incubator/ivy/core/trunk/doc/doc/use/postresolvetask.html
    incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyPostResolveTask.java
    incubator/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyCachePathTest.java

Modified: incubator/ivy/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/CHANGES.txt?view=diff&rev=524924&r1=524923&r2=524924
==============================================================================
--- incubator/ivy/core/trunk/CHANGES.txt (original)
+++ incubator/ivy/core/trunk/CHANGES.txt Mon Apr  2 14:17:37 2007
@@ -48,6 +48,7 @@
 =====================================
 - NEW: define artifacts not declared by the dependency module descriptor (IVY-419)
 
+- IMPROVE: Let user specify Ivy file when using a post-resolve task (IVY-455)
 - IMPROVE: IvyArtifactProperty and IvyArtifactReport tasks should be a post resolve task (IVY-452)
 - IMPROVE: Rename ivy configuration in settings to remove ambiguity on configuration meaning (IVY-438)
 - IMPROVE: Please typedef CacheResolver as "cache" for us (IVY-359)

Modified: incubator/ivy/core/trunk/doc/doc/use/postresolvetask.html
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/doc/doc/use/postresolvetask.html?view=diff&rev=524924&r1=524923&r2=524924
==============================================================================
--- incubator/ivy/core/trunk/doc/doc/use/postresolvetask.html (original)
+++ incubator/ivy/core/trunk/doc/doc/use/postresolvetask.html Mon Apr  2 14:17:37 2007
@@ -31,8 +31,8 @@
 <li>[[ant:retrieve]]</li>
 <li>[[ant:cachefileset]]</li>
 <li>[[ant:cachepath]]</li>
-<li>[[ant:artifactproperty]] <span class="since">(since 1.5)</span></li>
-<li>[[ant:artifactreport]] <span class="since">(since 1.5)</span></li>
+<li>[[ant:artifactproperty]] <span class="since">(since 2.0)</span></li>
+<li>[[ant:artifactreport]] <span class="since">(since 2.0)</span></li>
 </ul>
 
 All these tasks will trigger automatically a resolve if:
@@ -63,6 +63,7 @@
     <tr><td>transitive</td><td>true to resolve dependencies transitively, false otherwise <span class="since">since 1.4</span></td><td>No. Defaults to true</td></tr>
     <tr><td>haltonfailure</td><td>true to halt the build on ivy failure, false to continue</td><td>No. Defaults to true</td></tr>
     <tr><td>validate</td><td>true to force ivy files validation against ivy.xsd, false to force no validation</td><td>No. Defaults to default ivy value (as configured in configuration file)</td></tr>
+    <tr><td>file</td><td>the file to resolve if a resolve is necessary <span class="since">since 2.0</span></td><td>No. Defaults to the previous resolved Ivy file or to ${ivy.dep.file}</td></tr>
 </tbody>
 </table>
 <h1>Examples</h1>

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=524924&r1=524923&r2=524924
==============================================================================
--- 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 Mon Apr  2 14:17:37 2007
@@ -184,9 +184,14 @@
     protected String[] getConfsToResolve(String resolveId, String conf) {
         ModuleDescriptor reference = (ModuleDescriptor) getResolvedDescriptor(resolveId, false);
         if (reference == null) {
-        	// assume the module has been resolved outside this build
+        	// assume the module has been resolved outside this build, resolve the required
+        	// configurations again
         	// TODO: find a way to discover which confs were resolved by that previous resolve
-        	return new String[0];
+        	if (conf == null) {
+        		return new String[] {"*"};
+        	} else {
+        		return splitConfs(conf);
+        	}
         }
         String[] rconfs = (String[]) getProject().getReference("ivy.resolved.configurations.ref." + resolveId);
         return getConfsToResolve(reference, conf, rconfs);
@@ -321,6 +326,14 @@
 	
 	public String getResolveId() {
 		return _resolveId;
+	}
+	
+	public void setFile(File file) {
+		_file = file;
+	}
+	
+	public File getFile() {
+		return _file;
 	}
 
 }

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=524924&r1=524923&r2=524924
==============================================================================
--- 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 Mon Apr  2 14:17:37 2007
@@ -204,6 +204,7 @@
     	
     	_path.setResolveId("withResolveId");
     	_path.setPathid("withresolveid-pathid");
+    	_path.setFile(new File("test/java/org/apache/ivy/ant/ivy-simple.xml"));
     	_path.execute();
 
         Object ref = _project.getReference("withresolveid-pathid");
@@ -213,6 +214,34 @@
         assertEquals(1, p.size());
         assertEquals(getArchiveFileInCache("org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").getAbsolutePath(),
                 new File(p.list()[0]).getAbsolutePath());
+    }
+    
+    public void testWithResolveIdAndMissingConfs() 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-multiconf.xml"));
+    	resolve.setResolveId("testWithResolveIdAndMissingConfs");
+    	resolve.setConf("default");
+    	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();
+    	
+        _project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-multiconf.xml");
+
+    	_path.setResolveId("testWithResolveIdAndMissingConfs");
+    	_path.setPathid("withresolveid-pathid");
+    	_path.setConf("default,compile");
+    	_path.setFile(new File("test/java/org/apache/ivy/ant/ivy-multiconf.xml"));
+    	_path.execute();
     }
 
     private File getArchiveFileInCache(String organisation, String module, String revision, String artifact, String type, String ext) {