ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maart...@apache.org
Subject svn commit: r965284 - in /ant/ivy/core/trunk: CHANGES.txt src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorWriter.java test/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorWriterTest.java
Date Sun, 18 Jul 2010 20:56:30 GMT
Author: maartenc
Date: Sun Jul 18 20:56:30 2010
New Revision: 965284

URL: http://svn.apache.org/viewvc?rev=965284&view=rev
Log:
FIX: XmlModuleDescriptorWriter does not write the transitive attribute (IVY-1207) (thanks
to Abel Muino)

Modified:
    ant/ivy/core/trunk/CHANGES.txt
    ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorWriter.java
    ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorWriterTest.java

Modified: ant/ivy/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=965284&r1=965283&r2=965284&view=diff
==============================================================================
--- ant/ivy/core/trunk/CHANGES.txt (original)
+++ ant/ivy/core/trunk/CHANGES.txt Sun Jul 18 20:56:30 2010
@@ -69,6 +69,7 @@ for detailed view of each issue, please 
 	Sakari Maaranen
 	Jan Materne
 	Markus M. May
+	Abel Muino
 	J. Lewis Muir
 	Stephen Nesbitt
 	Joshua Nichols
@@ -111,6 +112,7 @@ for detailed view of each issue, please 
 =====================================
 - IMPROVEMENT: ivy:makepom now accepts a list of configurations to include (IVY-1005) (thanks
to Jesper Pedersen)
 
+- FIX: XmlModuleDescriptorWriter does not write the transitive attribute (IVY-1207) (thanks
to Abel Muino)
 - FIX: Ivy info/extends/extendsType attribute is misspelled by XmlModuleDescriptorWriter
(IVY-1203) (thanks to Jason Trump)
 
    2.2.0-rc1

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorWriter.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorWriter.java?rev=965284&r1=965283&r2=965284&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorWriter.java
(original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorWriter.java
Sun Jul 18 20:56:30 2010
@@ -425,6 +425,9 @@ public final class XmlModuleDescriptorWr
             }
             out.print("\"");
         }
+        if (!conf.isTransitive()) {
+            out.println(" transitive=\"false\"");
+        }
         if (conf.getDeprecated() != null) {
             out.print(" deprecated=\"" + XMLHelper.escape(conf.getDeprecated()) + "\"");
         }

Modified: ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorWriterTest.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorWriterTest.java?rev=965284&r1=965283&r2=965284&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorWriterTest.java
(original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorWriterTest.java
Sun Jul 18 20:56:30 2010
@@ -22,13 +22,17 @@ import java.io.File;
 import java.io.FileReader;
 import java.io.IOException;
 import java.io.InputStreamReader;
+import java.util.Date;
 import java.util.GregorianCalendar;
 
 import junit.framework.TestCase;
 
 import org.apache.ivy.Ivy;
+import org.apache.ivy.core.module.descriptor.Configuration;
 import org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor;
 import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
+import org.apache.ivy.core.module.descriptor.Configuration.Visibility;
+import org.apache.ivy.core.module.id.ModuleId;
 import org.apache.ivy.core.module.id.ModuleRevisionId;
 import org.apache.ivy.core.settings.IvySettings;
 import org.apache.ivy.util.FileUtil;
@@ -121,6 +125,55 @@ public class XmlModuleDescriptorWriterTe
 		assertEquals(expected, wrote);
 	}
 
+    /**
+     * Test that the transitive attribute is written for non-transitive configurations.
+     * 
+     * <code><conf ... transitive="false" ... /></code>
+     * 
+     * @see <a href="https://issues.apache.org/jira/browse/IVY-1207">IVY-1207</a>
+     * @throws Exception
+     */
+    public void testTransitiveAttributeForNonTransitiveConfs() throws Exception {
+        // Given a ModuleDescriptor with a non-transitive configuration
+        DefaultModuleDescriptor md = new DefaultModuleDescriptor(new ModuleRevisionId(new
ModuleId(
+                "myorg", "myname"), "1.0"), "integration", new Date());
+        Configuration conf = new Configuration("conf", Visibility.PUBLIC, "desc", null, false,
null);
+        md.addConfiguration(conf);
+
+        // When the ModuleDescriptor is written
+        XmlModuleDescriptorWriter.write(md, LICENSE, dest);
+
+        // Then the transitive attribute must be set to false
+        String output = FileUtil.readEntirely(dest);
+        String writtenConf = output.substring(output.indexOf("<configurations>") +
16, output.indexOf("</configurations>")).trim();
+        assertTrue("Transitive attribute not set to false: " + writtenConf, writtenConf.indexOf("transitive=\"false\"")
>= 0);
+    }
+
+    /**
+     * Test that the transitive attribute is not written when the configuration IS transitive.
+     * 
+     * This is the default and writing it will only add noise and cause a deviation from
the known
+     * behavior (before fixing IVY-1207).
+     * 
+     * @see <a href="https://issues.apache.org/jira/browse/IVY-1207">IVY-1207</a>
+     * @throws Exception
+     */
+    public void testTransitiveAttributeNotWrittenForTransitiveConfs() throws Exception {
+        // Given a ModuleDescriptor with a transitive configuration
+        DefaultModuleDescriptor md = new DefaultModuleDescriptor(new ModuleRevisionId(new
ModuleId(
+                "myorg", "myname"), "1.0"), "integration", new Date());
+        Configuration conf = new Configuration("conf", Visibility.PUBLIC, "desc", null, true,
null);
+        md.addConfiguration(conf);
+
+        // When the ModuleDescriptor is written
+        XmlModuleDescriptorWriter.write(md, LICENSE, dest);
+
+        // Then the transitive attribute must NOT be written
+        String output = FileUtil.readEntirely(dest);
+        String writtenConf = output.substring(output.indexOf("<configurations>") +
16, output.indexOf("</configurations>")).trim();
+        assertFalse("Transitive attribute set: " + writtenConf, writtenConf.indexOf("transitive=")
>= 0);
+    }
+
     private String readEntirely(String resource) throws IOException {
         return FileUtil.readEntirely(new BufferedReader(new InputStreamReader(
                 XmlModuleDescriptorWriterTest.class.getResource(resource).openStream())));



Mime
View raw message