ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hi...@apache.org
Subject svn commit: r1373350 - in /ant/ivy/core/trunk: CHANGES.txt doc/use/resolve.html src/java/org/apache/ivy/ant/IvyResolve.java test/java/org/apache/ivy/ant/IvyResolveTest.java
Date Wed, 15 Aug 2012 11:43:11 GMT
Author: hibou
Date: Wed Aug 15 11:43:10 2012
New Revision: 1373350

URL: http://svn.apache.org/viewvc?rev=1373350&view=rev
Log:
IVY-1288: Exposing some parent metadata (organisation, module, revision, branch) as properties
(Thanks to Jean-Louis Boudart)

Modified:
    ant/ivy/core/trunk/CHANGES.txt
    ant/ivy/core/trunk/doc/use/resolve.html
    ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyResolve.java
    ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyResolveTest.java

Modified: ant/ivy/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=1373350&r1=1373349&r2=1373350&view=diff
==============================================================================
--- ant/ivy/core/trunk/CHANGES.txt (original)
+++ ant/ivy/core/trunk/CHANGES.txt Wed Aug 15 11:43:10 2012
@@ -138,6 +138,7 @@ for detailed view of each issue, please 
 - FIX: Buildnumber and IvyFindRevision Ant tasks should honour defaultBranch setting (IVY-1344)
(Thanks to Ales Nosek)
 
 - NEW: Support Conditional Setting of a Property (IVY-1367)
+- NEW: Exposing some parent metadata (organisation, module, revision, branch) as properties
(IVY-1288) (Thanks to Jean-Louis Boudart)
 
 - IMPROVEMENT: add support for source bundles from p2 repositories
 - IMPROVEMENT: add support for source URI from OBR repositories

Modified: ant/ivy/core/trunk/doc/use/resolve.html
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/doc/use/resolve.html?rev=1373350&r1=1373349&r2=1373350&view=diff
==============================================================================
--- ant/ivy/core/trunk/doc/use/resolve.html (original)
+++ ant/ivy/core/trunk/doc/use/resolve.html Wed Aug 15 11:43:10 2012
@@ -54,6 +54,22 @@ In addition, if the <i>resolveId</i> att
 <li>ivy.deps.changed.${resolveId}</li>
 </ul>
 
+<b>Since 2.4</b>
+If current module extends other modules 
+<ul>
+<li>ivy.parents.count</li>
+number of parents module
+<li>ivy.parent[index].organisation</li>
+set to the organisation name found in the parent ivyfile which was used for resolve
+<li>ivy.parent[index].module</li>
+set to the module name found in the parent ivyfile which was used for resolve
+<li>ivy.parent[index].revision</li>
+set to the revision name found in the parent ivyfile which was used for resolve
+<li>ivy.parent[index].branch</li>
+set to the branch name found in the parent ivyfile which was used for resolve
+</ul>
+Where <i>index</i> represent the index of extends module.
+
 When ivy has finished the resolve task, it outputs a summary of what has been resolved. This
summary looks like this:
 <pre>
 ---------------------------------------------------------------------

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyResolve.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyResolve.java?rev=1373350&r1=1373349&r2=1373350&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyResolve.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyResolve.java Wed Aug 15 11:43:10 2012
@@ -31,6 +31,7 @@ import org.apache.ivy.core.LogOptions;
 import org.apache.ivy.core.module.descriptor.DefaultExcludeRule;
 import org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor;
 import org.apache.ivy.core.module.descriptor.DependencyDescriptor;
+import org.apache.ivy.core.module.descriptor.ExtendsDescriptor;
 import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
 import org.apache.ivy.core.module.id.ModuleRevisionId;
 import org.apache.ivy.core.report.ResolveReport;
@@ -350,6 +351,24 @@ public class IvyResolve extends IvyTask 
                 settings.setVariable("ivy.module", mdName);
                 getProject().setProperty("ivy.revision", mdRev);
                 settings.setVariable("ivy.revision", mdRev);
+                for (int i = 0; i < md.getInheritedDescriptors().length; i++) {
+                    ExtendsDescriptor parent = md.getInheritedDescriptors()[i];
+                    String parentOrg = parent.getResolvedParentRevisionId().getOrganisation();
+                    String parentModule = parent.getResolvedParentRevisionId().getName();
+                    String parentRevision = parent.getResolvedParentRevisionId().getRevision();
+                    String parentBranch = parent.getResolvedParentRevisionId().getBranch();
+                    getProject().setProperty("ivy.parent["+i+"].organisation", parentOrg);
+                    settings.setVariable("ivy.parent["+i+"].organisation", parentOrg);
+                    getProject().setProperty("ivy.parent["+i+"].module", parentModule);
+                    settings.setVariable("ivy.parent["+i+"].module", parentModule);
+                    getProject().setProperty("ivy.parent["+i+"].revision", parentRevision);
+                    settings.setVariable("ivy.parent["+i+"].revision", parentRevision);
+                    getProject().setProperty("ivy.parent["+i+"].branch", parentBranch);
+                    settings.setVariable("ivy.parent["+i+"].branch", parentBranch);
+                }
+                getProject().setProperty("ivy.parents.count", String.valueOf(md.getInheritedDescriptors().length));
+                settings.setVariable("ivy.parents.count", String.valueOf(md.getInheritedDescriptors().length));
+
                 Boolean hasChanged = null;
                 if (getCheckIfChanged()) {
                     hasChanged = Boolean.valueOf(report.hasChanged());

Modified: ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyResolveTest.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyResolveTest.java?rev=1373350&r1=1373349&r2=1373350&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyResolveTest.java (original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyResolveTest.java Wed Aug 15 11:43:10
2012
@@ -18,7 +18,6 @@
 package org.apache.ivy.ant;
 
 import java.io.File;
-import java.util.List;
 
 import junit.framework.TestCase;
 
@@ -586,5 +585,15 @@ public class IvyResolveTest extends Test
             // ok
         }
     }
+    
+    public void testSimpleExtends() throws Exception {
+        resolve.setFile(new File("test/java/org/apache/ivy/ant/ivy-extends-multiconf.xml"));
+        resolve.execute();
+        assertEquals("1", resolve.getProject().getProperty("ivy.parents.count"));
+        assertEquals("apache", resolve.getProject().getProperty("ivy.parent[0].organisation"));
+        assertEquals("resolve-simple", resolve.getProject().getProperty("ivy.parent[0].module"));
+        assertEquals("1.0", resolve.getProject().getProperty("ivy.parent[0].revision"));
+        assertEquals(null, resolve.getProject().getProperty("ivy.parent[0].branch"));
+    }
 
 }



Mime
View raw message