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/03/01 14:01:46 UTC

svn commit: r632587 - in /ant/ivy/core/trunk: CHANGES.txt doc/use/install.html src/java/org/apache/ivy/ant/IvyInstall.java test/java/org/apache/ivy/ant/IvyInstallTest.java test/repositories/branches/ivysettings.xml

Author: xavier
Date: Sat Mar  1 05:01:45 2008
New Revision: 632587

URL: http://svn.apache.org/viewvc?rev=632587&view=rev
Log:
IMPROVEMENT: add branch attribute in ivy:install task (IVY-727)

Modified:
    ant/ivy/core/trunk/CHANGES.txt
    ant/ivy/core/trunk/doc/use/install.html
    ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyInstall.java
    ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyInstallTest.java
    ant/ivy/core/trunk/test/repositories/branches/ivysettings.xml

Modified: ant/ivy/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=632587&r1=632586&r2=632587&view=diff
==============================================================================
--- ant/ivy/core/trunk/CHANGES.txt (original)
+++ ant/ivy/core/trunk/CHANGES.txt Sat Mar  1 05:01:45 2008
@@ -65,6 +65,7 @@
    trunk version
 =====================================
 - IMPROVEMENT: Make Ivy standalone runnable with no required dependencies (IVY-757)
+- IMPROVEMENT: add branch attribute in ivy:install task (IVY-727)
 
 - FIX: XML schema ambiguity (IVY-750)
 - FIX: ivy-resolve fails when a project has different dependencies in different branches (IVY-717)

Modified: ant/ivy/core/trunk/doc/use/install.html
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/doc/use/install.html?rev=632587&r1=632586&r2=632587&view=diff
==============================================================================
--- ant/ivy/core/trunk/doc/use/install.html (original)
+++ ant/ivy/core/trunk/doc/use/install.html Sat Mar  1 05:01:45 2008
@@ -46,6 +46,8 @@
         <td>Yes</td></tr>
     <tr><td>module</td><td>the name of the module to install</td>
         <td>Yes</td></tr>
+    <tr><td>branch</td><td>the branch of the module to install <span class="since">since 2.0</span></td>
+        <td>No, defaults to default branch with exact matcher, '*' with any other matcher</td></tr>
     <tr><td>revision</td><td>the revision of the module to install</td>
         <td>Yes</td></tr>
     <tr><td>validate</td><td>true to force ivy files validation against ivy.xsd, false to force no validation</td>

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyInstall.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyInstall.java?rev=632587&r1=632586&r2=632587&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyInstall.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyInstall.java Sat Mar  1 05:01:45 2008
@@ -20,6 +20,7 @@
 import java.io.File;
 
 import org.apache.ivy.Ivy;
+import org.apache.ivy.core.module.id.ModuleId;
 import org.apache.ivy.core.module.id.ModuleRevisionId;
 import org.apache.ivy.core.report.ResolveReport;
 import org.apache.ivy.core.settings.IvySettings;
@@ -37,6 +38,8 @@
 
     private String revision;
 
+    private String branch;
+
     private boolean overwrite = false;
 
     private String from;
@@ -76,6 +79,11 @@
         } else if (revision == null && !PatternMatcher.EXACT.equals(matcher)) {
             revision = PatternMatcher.ANY_EXPRESSION;
         }
+      if (branch == null && PatternMatcher.EXACT.equals(matcher)) {
+          branch = settings.getDefaultBranch(ModuleId.newInstance(organisation, module));
+      } else if (branch == null && !PatternMatcher.EXACT.equals(matcher)) {
+          branch = PatternMatcher.ANY_EXPRESSION;
+      }
         if (from == null) {
             throw new BuildException(
                     "no from resolver name: please provide it through parameter 'from'");
@@ -84,7 +92,9 @@
             throw new BuildException(
                     "no to resolver name: please provide it through parameter 'to'");
         }
-        ModuleRevisionId mrid = ModuleRevisionId.newInstance(organisation, module, revision);
+        ModuleRevisionId mrid = 
+            ModuleRevisionId.newInstance(organisation, module, branch, revision);
+        
         ResolveReport report;
         try {
             report = ivy.install(mrid, from, to, transitive, doValidate(settings), overwrite,
@@ -118,6 +128,14 @@
     public void setModule(String module) {
         this.module = module;
     }
+
+  public String getBranch() {
+      return branch;
+  }
+
+  public void setBranch(String branch) {
+      this.branch = branch;
+  }
 
     public String getOrganisation() {
         return organisation;

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=632587&r1=632586&r2=632587&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 Sat Mar  1 05:01:45 2008
@@ -21,9 +21,9 @@
 
 import junit.framework.TestCase;
 
+import org.apache.ivy.util.FileUtil;
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Project;
-import org.apache.tools.ant.taskdefs.Delete;
 
 public class IvyInstallTest extends TestCase {
     private File cache;
@@ -34,7 +34,7 @@
 
     protected void setUp() throws Exception {
         createCache();
-        cleanTestLib();
+        cleanInstall();
         project = new Project();
         project.setProperty("ivy.settings.file", "test/repositories/ivysettings.xml");
 
@@ -50,21 +50,29 @@
 
     protected void tearDown() throws Exception {
         cleanCache();
-        cleanTestLib();
+        cleanInstall();
     }
 
     private void cleanCache() {
-        Delete del = new Delete();
-        del.setProject(new Project());
-        del.setDir(cache);
-        del.execute();
+        FileUtil.forceDelete(cache);
     }
 
-    private void cleanTestLib() {
-        Delete del = new Delete();
-        del.setProject(new Project());
-        del.setDir(new File("build/test/lib"));
-        del.execute();
+    private void cleanInstall() {
+        FileUtil.forceDelete(new File("build/test/install"));
+    }
+
+    public void testInstallWithBranch() {
+        project.setProperty("ivy.settings.file", "test/repositories/branches/ivysettings.xml");
+        install.setOrganisation("foo");
+        install.setModule("foo1");
+        install.setBranch("branch1");
+        install.setRevision("2");
+        install.setFrom("default");
+        install.setTo("install");
+
+        install.execute();
+
+        assertTrue(new File("build/test/install/foo/foo1/branch1/ivy-2.xml").exists());
     }
 
     public void testDependencyNotFoundFailure() {
@@ -72,11 +80,11 @@
         install.setModule("yyy");
         install.setRevision("zzz");
         install.setFrom("test");
-        install.setTo("1");
+        install.setTo("install");
 
         try {
             install.execute();
-            fail("unknown dependency, failure expected (haltunresolved=true)");
+            fail("unknown dependency, failure expected (haltonfailure=true)");
         } catch (BuildException be) {
             // success
         }
@@ -93,7 +101,7 @@
         try {
             install.execute();
         } catch (BuildException be) {
-            fail("unknown dependency, failure unexepected (haltunresolved=false)");
+            fail("unknown dependency, failure unexpected (haltonfailure=false). Failure: " + be);
         }
     }
 }

Modified: ant/ivy/core/trunk/test/repositories/branches/ivysettings.xml
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/branches/ivysettings.xml?rev=632587&r1=632586&r2=632587&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/repositories/branches/ivysettings.xml (original)
+++ ant/ivy/core/trunk/test/repositories/branches/ivysettings.xml Sat Mar  1 05:01:45 2008
@@ -23,5 +23,9 @@
 			<ivy pattern="${ivy.settings.dir}/[organisation]/[module]/[branch]/[revision]/[artifact].[ext]" />
 			<artifact pattern="${ivy.settings.dir}/[organisation]/[module]/[branch]/[revision]/[artifact].[ext]" />
 		</filesystem>
+		<filesystem name="install">
+			<ivy pattern="build/test/install/[organisation]/[module]/[branch]/[artifact]-[revision].[ext]"/>
+			<artifact pattern="build/test/install/[organisation]/[module]/[branch]/[artifact]-[revision].[ext]"/>
+		</filesystem>
     </resolvers>
 </ivysettings>