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/02/07 15:28:20 UTC

svn commit: r619425 - in /ant/ivy/core/trunk: CHANGES.txt doc/use/info.html src/java/org/apache/ivy/ant/IvyInfo.java test/java/org/apache/ivy/ant/IvyInfoTest.java test/java/org/apache/ivy/ant/ivy-info-all.xml

Author: xavier
Date: Thu Feb  7 06:28:09 2008
New Revision: 619425

URL: http://svn.apache.org/viewvc?rev=619425&view=rev
Log:
IMPROVEMENT: branch and extra attributes missing from info Ant task (IVY-721)

Added:
    ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyInfoTest.java   (with props)
    ant/ivy/core/trunk/test/java/org/apache/ivy/ant/ivy-info-all.xml   (with props)
Modified:
    ant/ivy/core/trunk/CHANGES.txt
    ant/ivy/core/trunk/doc/use/info.html
    ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyInfo.java

Modified: ant/ivy/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=619425&r1=619424&r2=619425&view=diff
==============================================================================
--- ant/ivy/core/trunk/CHANGES.txt (original)
+++ ant/ivy/core/trunk/CHANGES.txt Thu Feb  7 06:28:09 2008
@@ -67,6 +67,7 @@
 - NEW: Cache dynamic revision resolution (IVY-694)
 - NEW: Make resolve console output configurable per resolve (IVY-715)
 
+- IMPROVEMENT: branch and extra attributes missing from info Ant task (IVY-721)
 - IMPROVEMENT: Review settings loading in Ant (IVY-703)
 - IMPROVEMENT: Move useOrigin to repository cache manager (IVY-700)
 - IMPROVEMENT: Make IBiblio resolver compatible with maven proxy (IVY-466)

Modified: ant/ivy/core/trunk/doc/use/info.html
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/doc/use/info.html?rev=619425&r1=619424&r2=619425&view=diff
==============================================================================
--- ant/ivy/core/trunk/doc/use/info.html (original)
+++ ant/ivy/core/trunk/doc/use/info.html Thu Feb  7 06:28:09 2008
@@ -32,7 +32,10 @@
 <table>
 <tr><td>ivy.organisation</td><td>The organisation of the module, as found in the <a href="../ivyfile/info.html">info</a> tag of the ivy file parsed</td></tr>
 <tr><td>ivy.module</td><td>The name of the module, as found in the <a href="../ivyfile/info.html">info</a> tag of the ivy file parsed</td></tr>
+<tr><td>ivy.branch</td><td>The branch of the module if any, as found in the <a href="../ivyfile/info.html">info</a> tag of the ivy file parsed</td></tr>
 <tr><td>ivy.revision</td><td>The revision of the module, as found in the <a href="../ivyfile/info.html">info</a> tag of the ivy file parsed</td></tr>
+<tr><td>ivy.status</td><td>The status of the module, as found in the <a href="../ivyfile/info.html">info</a> tag of the ivy file parsed</td></tr>
+<tr><td>ivy.extra.<i>[any extra attribute]</i></td><td>Corresponding extra attribute value, as found in the <a href="../ivyfile/info.html">info</a> tag of the ivy file parsed</td></tr>
 <tr><td>ivy.configurations</td><td>A comma separated list of configurations of the module, as declared in the <a href="../ivyfile/configurations.html">configurations</a> section</td></tr>
 <tr><td>ivy.public.configurations</td><td>A comma separated list of public configurations of the module, as declared in the <a href="../ivyfile/configurations.html">configurations</a> section</td></tr>
 </table>
@@ -48,10 +51,40 @@
 <tr><td>settingsRef</td><td>A reference to the ivy settings that must be used by this task <span class="since">(since 2.0)</span></td><td>No, 'ivy.instance' is taken by default.</td></tr></tbody>
 </table>
 <h1>Examples</h1>
+Given this ivy.xml file:
+<code>
+<ivy-module version="1.0" xmlns:e="http://ant.apache.org/ivy/extra"> 
+	<info organisation="apache"
+	       module="info-all"
+	       branch="trunk"
+	       revision="1.0"
+	       status="release"
+	       e:myextraatt="myvalue"
+	/>
+	<configurations>
+		<conf name="default" />
+		<conf name="test" />
+		<conf name="private" visibility="private"/>
+	</configurations>
+	<dependencies>
+		<dependency org="org1" name="mod1.2" rev="2.0"/>
+	</dependencies>
+</ivy-module>
+</code>
 <code type="xml">
 <ivy:info file="${basedir}/path/to/ivy.xml" />
 </code>
-Parses ${basedir}/path/to/ivy.xml and set properties as described above accordingly.
+Parses ${basedir}/path/to/ivy.xml and set properties as described above accordingly:
+<code>
+ivy.organisation=apache
+ivy.module=info-all
+ivy.branch=trunk
+ivy.revision=1.0
+ivy.status=release
+ivy.extra.myextraatt=myvalue
+ivy.configurations=default, test, private
+ivy.public.configurations=default, test
+</code>
 
 	</textarea>
 <script type="text/javascript">xooki.postProcess();</script>

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyInfo.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyInfo.java?rev=619425&r1=619424&r2=619425&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyInfo.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyInfo.java Thu Feb  7 06:28:09 2008
@@ -21,12 +21,16 @@
 import java.net.MalformedURLException;
 import java.text.ParseException;
 import java.util.ArrayList;
+import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
 
 import org.apache.ivy.Ivy;
 import org.apache.ivy.core.module.descriptor.Configuration;
 import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
 import org.apache.ivy.core.module.descriptor.Configuration.Visibility;
+import org.apache.ivy.core.module.id.ModuleRevisionId;
 import org.apache.ivy.core.settings.IvySettings;
 import org.apache.ivy.plugins.parser.ModuleDescriptorParserRegistry;
 import org.apache.tools.ant.BuildException;
@@ -56,10 +60,21 @@
         try {
             ModuleDescriptor md = ModuleDescriptorParserRegistry.getInstance().parseDescriptor(
                 settings, file.toURL(), doValidate(settings));
-            getProject()
-                    .setProperty("ivy.organisation", md.getModuleRevisionId().getOrganisation());
-            getProject().setProperty("ivy.module", md.getModuleRevisionId().getName());
-            getProject().setProperty("ivy.revision", md.getModuleRevisionId().getRevision());
+            ModuleRevisionId mrid = md.getModuleRevisionId();
+            getProject().setProperty("ivy.organisation", mrid.getOrganisation());
+            getProject().setProperty("ivy.module", mrid.getName());
+            if (mrid.getBranch() != null) {
+                getProject().setProperty("ivy.branch", mrid.getBranch());
+            }
+            getProject().setProperty("ivy.revision", mrid.getRevision());
+            getProject().setProperty("ivy.status", md.getStatus());
+            
+            Map extra = mrid.getExtraAttributes();
+            for (Iterator iter = extra.entrySet().iterator(); iter.hasNext();) {
+                Entry entry = (Entry) iter.next();
+                getProject().setProperty("ivy.extra." + entry.getKey(), (String) entry.getValue());
+            }
+            
             getProject().setProperty("ivy.configurations", mergeConfs(md.getConfigurationsNames()));
 
             // store the public configurations in a separate property

Added: ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyInfoTest.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyInfoTest.java?rev=619425&view=auto
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyInfoTest.java (added)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyInfoTest.java Thu Feb  7 06:28:09 2008
@@ -0,0 +1,61 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.ivy.ant;
+
+import java.io.File;
+
+import junit.framework.TestCase;
+
+import org.apache.tools.ant.Project;
+
+public class IvyInfoTest extends TestCase {
+    private IvyInfo info;
+
+    protected void setUp() throws Exception {
+        Project project = new Project();
+
+        info = new IvyInfo();
+        info.setProject(project);
+    }
+
+    public void testSimple() throws Exception {
+        info.setFile(new File("test/java/org/apache/ivy/ant/ivy-simple.xml"));
+        info.execute();
+        
+        assertEquals("apache", info.getProject().getProperty("ivy.organisation"));
+        assertEquals("resolve-simple", info.getProject().getProperty("ivy.module"));
+        assertEquals("1.0", info.getProject().getProperty("ivy.revision"));
+        assertEquals("default", info.getProject().getProperty("ivy.configurations"));
+        assertEquals("default", info.getProject().getProperty("ivy.public.configurations"));
+    }
+
+    public void testAll() throws Exception {
+        info.setFile(new File("test/java/org/apache/ivy/ant/ivy-info-all.xml"));
+        info.execute();
+        
+        assertEquals("apache", info.getProject().getProperty("ivy.organisation"));
+        assertEquals("info-all", info.getProject().getProperty("ivy.module"));
+        assertEquals("1.0", info.getProject().getProperty("ivy.revision"));
+        assertEquals("release", info.getProject().getProperty("ivy.status"));
+        assertEquals("default, test, private", info.getProject().getProperty("ivy.configurations"));
+        assertEquals("default, test", info.getProject().getProperty("ivy.public.configurations"));
+        assertEquals("trunk", info.getProject().getProperty("ivy.branch"));
+        assertEquals("myvalue", info.getProject().getProperty("ivy.extra.myextraatt"));
+    }
+
+}
\ No newline at end of file

Propchange: ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyInfoTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: ant/ivy/core/trunk/test/java/org/apache/ivy/ant/ivy-info-all.xml
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/ant/ivy-info-all.xml?rev=619425&view=auto
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/ant/ivy-info-all.xml (added)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/ant/ivy-info-all.xml Thu Feb  7 06:28:09 2008
@@ -0,0 +1,35 @@
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+   distributed with this work for additional information
+   regarding copyright ownership.  The ASF licenses this file
+   to you under the Apache License, Version 2.0 (the
+   "License"); you may not use this file except in compliance
+   with the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing,
+   software distributed under the License is distributed on an
+   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+   KIND, either express or implied.  See the License for the
+   specific language governing permissions and limitations
+   under the License.    
+-->
+<ivy-module version="1.0" xmlns:e="http://ant.apache.org/ivy/extra"> 
+	<info organisation="apache"
+	       module="info-all"
+	       branch="trunk"
+	       revision="1.0"
+	       status="release"
+	       e:myextraatt="myvalue"
+	/>
+	<configurations>
+		<conf name="default" />
+		<conf name="test" />
+		<conf name="private" visibility="private"/>
+	</configurations>
+	<dependencies>
+		<dependency org="org1" name="mod1.2" rev="2.0"/>
+	</dependencies>
+</ivy-module>

Propchange: ant/ivy/core/trunk/test/java/org/apache/ivy/ant/ivy-info-all.xml
------------------------------------------------------------------------------
    svn:eol-style = native