Author: maartenc
Date: Sun Jul 18 21:33:39 2010
New Revision: 965297
URL: http://svn.apache.org/viewvc?rev=965297&view=rev
Log:
Merged changes for IVY-1005 and IVY-1207 from trunk into 2.2.x branch.
Added:
ant/ivy/core/branches/2.2.x/test/java/org/apache/ivy/plugins/parser/m2/test-write-compile-dependencies.xml
- copied unchanged from r964690,
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-write-compile-dependencies.xml
Modified:
ant/ivy/core/branches/2.2.x/ (props changed)
ant/ivy/core/branches/2.2.x/CHANGES.txt
ant/ivy/core/branches/2.2.x/doc/use/makepom.html
ant/ivy/core/branches/2.2.x/src/java/org/apache/ivy/ant/IvyMakePom.java
ant/ivy/core/branches/2.2.x/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorWriter.java
ant/ivy/core/branches/2.2.x/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorWriter.java
ant/ivy/core/branches/2.2.x/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorWriterTest.java
ant/ivy/core/branches/2.2.x/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorWriterTest.java
Propchange: ant/ivy/core/branches/2.2.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Jul 18 21:33:39 2010
@@ -1,4 +1,4 @@
/ant/ivy/core/branches/2.0.0:727187-727188,727520-732505
/ant/ivy/core/branches/2.0.0-rc2:707459-708717
/ant/ivy/core/branches/2.0.x:696803-698317
-/ant/ivy/core/trunk:695737,696014-696031,696442,958415-958693,961017-961020
+/ant/ivy/core/trunk:695737,696014-696031,696442,958415-958693,961017-961020,962767-965284
Modified: ant/ivy/core/branches/2.2.x/CHANGES.txt
URL:
http://svn.apache.org/viewvc/ant/ivy/core/branches/2.2.x/CHANGES.txt?rev=965297&r1=965296&r2=965297&view=diff
==============================================================================
--- ant/ivy/core/branches/2.2.x/CHANGES.txt (original)
+++ ant/ivy/core/branches/2.2.x/CHANGES.txt Sun Jul 18 21:33:39 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
@@ -79,6 +80,7 @@ for detailed view of each issue, please
Mathias Muller
Randy Nott
Peter Oxenham
+ Jesper Pedersen
Emmanuel Pellereau
Roshan Punnoose
Jean-Baptiste Quenot
@@ -108,6 +110,9 @@ for detailed view of each issue, please
2.2.0
=====================================
+- 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/branches/2.2.x/doc/use/makepom.html
URL:
http://svn.apache.org/viewvc/ant/ivy/core/branches/2.2.x/doc/use/makepom.html?rev=965297&r1=965296&r2=965297&view=diff
==============================================================================
--- ant/ivy/core/branches/2.2.x/doc/use/makepom.html (original)
+++ ant/ivy/core/branches/2.2.x/doc/use/makepom.html Sun Jul 18 21:33:39 2010
@@ -42,6 +42,7 @@ An example of use is to publish an Ivy m
<td>Yes</td></tr>
<tr><td>pomfile</td><td>the destination pom file to write</td>
<td>Yes</td></tr>
+ <tr><td>conf</td><td>a comma separated list of the configurations to
include in the generated pom. Wildcards are supported here. <span
class="since">(since 2.2)</span></td><td>No, defaults to all
configurations.</td></tr>
<tr><td>settingsRef</td><td>A reference to the ivy settings that must be used
by this task</td><td>No, 'ivy.instance' is taken by default.</td></tr>
</tbody>
</table>
Modified:
ant/ivy/core/branches/2.2.x/src/java/org/apache/ivy/ant/IvyMakePom.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/branches/2.2.x/src/java/org/apache/ivy/ant/IvyMakePom.java?rev=965297&r1=965296&r2=965297&view=diff
==============================================================================
--- ant/ivy/core/branches/2.2.x/src/java/org/apache/ivy/ant/IvyMakePom.java
(original)
+++ ant/ivy/core/branches/2.2.x/src/java/org/apache/ivy/ant/IvyMakePom.java Sun
Jul 18 21:33:39 2010
@@ -59,6 +59,8 @@ public class IvyMakePom extends IvyTask
private File headerFile = null;
+ private String conf;
+
private File ivyFile = null;
private Collection mappings = new ArrayList();
@@ -87,6 +89,14 @@ public class IvyMakePom extends IvyTask
this.headerFile = headerFile;
}
+ public String getConf() {
+ return conf;
+ }
+
+ public void setConf(String conf) {
+ this.conf = conf;
+ }
+
public Mapping createMapping() {
Mapping mapping = new Mapping();
this.mappings.add(mapping);
@@ -103,7 +113,7 @@ public class IvyMakePom extends IvyTask
}
ModuleDescriptor md =
XmlModuleDescriptorParser.getInstance().parseDescriptor(
getSettings(), ivyFile.toURI().toURL(), false);
- PomModuleDescriptorWriter.write(md,
+ PomModuleDescriptorWriter.write(md, splitConfs(conf),
headerFile == null ? null :
FileUtil.readEntirely(getHeaderFile()),
mappings.isEmpty()
? PomModuleDescriptorWriter.DEFAULT_MAPPING
Modified:
ant/ivy/core/branches/2.2.x/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorWriter.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/branches/2.2.x/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorWriter.java?rev=965297&r1=965296&r2=965297&view=diff
==============================================================================
---
ant/ivy/core/branches/2.2.x/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorWriter.java
(original)
+++
ant/ivy/core/branches/2.2.x/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorWriter.java
Sun Jul 18 21:33:39 2010
@@ -22,14 +22,20 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.apache.ivy.Ivy;
import org.apache.ivy.core.module.descriptor.Artifact;
import org.apache.ivy.core.module.descriptor.DependencyDescriptor;
import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
import org.apache.ivy.core.module.id.ModuleRevisionId;
+import org.apache.ivy.util.ConfigurationUtils;
import org.apache.ivy.util.StringUtils;
public final class PomModuleDescriptorWriter {
@@ -42,12 +48,7 @@ public final class PomModuleDescriptorWr
private PomModuleDescriptorWriter() {
}
- public static void write(ModuleDescriptor md,
- ConfigurationScopeMapping mapping, File output) throws IOException
{
- write(md, null, mapping, output);
- }
-
- public static void write(ModuleDescriptor md,
+ public static void write(ModuleDescriptor md, String[] confs,
String licenseHeader, ConfigurationScopeMapping mapping, File
output)
throws IOException {
if (output.getParentFile() != null) {
@@ -74,7 +75,7 @@ public final class PomModuleDescriptorWr
+ "http://maven.apache.org/maven-v4_0_0.xsd\">\n");
out.println(" <modelVersion>4.0.0</modelVersion>");
printModuleId(md, out);
- printDependencies(md, mapping, out);
+ printDependencies(md, confs, mapping, out);
out.println("</project>");
} finally {
out.close();
@@ -121,8 +122,8 @@ public final class PomModuleDescriptorWr
}
private static void printDependencies(
- ModuleDescriptor md, ConfigurationScopeMapping mapping,
PrintWriter out) {
- DependencyDescriptor[] dds = md.getDependencies();
+ ModuleDescriptor md, String[] confs, ConfigurationScopeMapping
mapping, PrintWriter out) {
+ DependencyDescriptor[] dds = getDependencies(md, confs);
if (dds.length > 0) {
out.println(" <dependencies>");
for (int i = 0; i < dds.length; i++) {
@@ -144,6 +145,21 @@ public final class PomModuleDescriptorWr
}
}
+ private static DependencyDescriptor[] getDependencies(ModuleDescriptor md,
String[] confs) {
+ confs = ConfigurationUtils.replaceWildcards(confs, md);
+
+ List result = new ArrayList();
+ DependencyDescriptor[] dds = md.getDependencies();
+ for (int i = 0; i < dds.length; i++) {
+ String[] depConfs = dds[i].getDependencyConfigurations(confs);
+ if ((depConfs != null) && (depConfs.length > 0)) {
+ result.add(dds[i]);
+ }
+ }
+
+ return (DependencyDescriptor[]) result.toArray(new
DependencyDescriptor[result.size()]);
+ }
+
public static final ConfigurationScopeMapping DEFAULT_MAPPING
= new ConfigurationScopeMapping(new HashMap() {
{
Modified:
ant/ivy/core/branches/2.2.x/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorWriter.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/branches/2.2.x/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorWriter.java?rev=965297&r1=965296&r2=965297&view=diff
==============================================================================
---
ant/ivy/core/branches/2.2.x/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorWriter.java
(original)
+++
ant/ivy/core/branches/2.2.x/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorWriter.java
Sun Jul 18 21:33:39 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/branches/2.2.x/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorWriterTest.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/branches/2.2.x/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorWriterTest.java?rev=965297&r1=965296&r2=965297&view=diff
==============================================================================
---
ant/ivy/core/branches/2.2.x/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorWriterTest.java
(original)
+++
ant/ivy/core/branches/2.2.x/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorWriterTest.java
Sun Jul 18 21:33:39 2010
@@ -44,7 +44,7 @@ public class PomModuleDescriptorWriterTe
public void testSimple() throws Exception {
ModuleDescriptor md =
PomModuleDescriptorParser.getInstance().parseDescriptor(
new IvySettings(), getClass().getResource("test-simple.pom"),
false);
- PomModuleDescriptorWriter.write(md, LICENSE,
PomModuleDescriptorWriter.DEFAULT_MAPPING, _dest);
+ PomModuleDescriptorWriter.write(md, null, LICENSE,
PomModuleDescriptorWriter.DEFAULT_MAPPING, _dest);
assertTrue(_dest.exists());
String wrote = FileUtil.readEntirely(new BufferedReader(new
FileReader(_dest))).replaceAll(
@@ -57,7 +57,7 @@ public class PomModuleDescriptorWriterTe
public void testSimpleDependencies() throws Exception {
ModuleDescriptor md =
PomModuleDescriptorParser.getInstance().parseDescriptor(
new IvySettings(),
getClass().getResource("test-dependencies.pom"), false);
- PomModuleDescriptorWriter.write(md, LICENSE,
PomModuleDescriptorWriter.DEFAULT_MAPPING, _dest);
+ PomModuleDescriptorWriter.write(md, null, LICENSE,
PomModuleDescriptorWriter.DEFAULT_MAPPING, _dest);
assertTrue(_dest.exists());
String wrote = FileUtil.readEntirely(new BufferedReader(new
FileReader(_dest))).replaceAll(
@@ -70,7 +70,7 @@ public class PomModuleDescriptorWriterTe
public void testDependenciesWithScope() throws Exception {
ModuleDescriptor md =
PomModuleDescriptorParser.getInstance().parseDescriptor(
new IvySettings(),
getClass().getResource("test-dependencies-with-scope.pom"), false);
- PomModuleDescriptorWriter.write(md, LICENSE,
PomModuleDescriptorWriter.DEFAULT_MAPPING, _dest);
+ PomModuleDescriptorWriter.write(md, null, LICENSE,
PomModuleDescriptorWriter.DEFAULT_MAPPING, _dest);
assertTrue(_dest.exists());
String wrote = FileUtil.readEntirely(new BufferedReader(new
FileReader(_dest))).replaceAll(
@@ -83,7 +83,7 @@ public class PomModuleDescriptorWriterTe
public void testOptional() throws Exception {
ModuleDescriptor md =
PomModuleDescriptorParser.getInstance().parseDescriptor(
new IvySettings(), getClass().getResource("test-optional.pom"),
false);
- PomModuleDescriptorWriter.write(md, LICENSE,
PomModuleDescriptorWriter.DEFAULT_MAPPING, _dest);
+ PomModuleDescriptorWriter.write(md, null, LICENSE,
PomModuleDescriptorWriter.DEFAULT_MAPPING, _dest);
assertTrue(_dest.exists());
String wrote = FileUtil.readEntirely(new BufferedReader(new
FileReader(_dest))).replaceAll(
@@ -96,7 +96,7 @@ public class PomModuleDescriptorWriterTe
public void testPackaging() throws Exception {
ModuleDescriptor md =
PomModuleDescriptorParser.getInstance().parseDescriptor(
new IvySettings(), getClass().getResource("test-packaging.pom"),
false);
- PomModuleDescriptorWriter.write(md, LICENSE,
PomModuleDescriptorWriter.DEFAULT_MAPPING, _dest);
+ PomModuleDescriptorWriter.write(md, null, LICENSE,
PomModuleDescriptorWriter.DEFAULT_MAPPING, _dest);
assertTrue(_dest.exists());
String wrote = FileUtil.readEntirely(new BufferedReader(new
FileReader(_dest))).replaceAll(
@@ -106,6 +106,58 @@ public class PomModuleDescriptorWriterTe
assertEquals(expected, wrote);
}
+ public void testWriteCompileConfigurationOnly() throws Exception {
+ ModuleDescriptor md =
PomModuleDescriptorParser.getInstance().parseDescriptor(
+ new IvySettings(),
getClass().getResource("test-dependencies-with-scope.pom"), false);
+ PomModuleDescriptorWriter.write(md, new String[] {"compile"}, LICENSE,
PomModuleDescriptorWriter.DEFAULT_MAPPING, _dest);
+ assertTrue(_dest.exists());
+
+ String wrote = FileUtil.readEntirely(new BufferedReader(new
FileReader(_dest))).replaceAll(
+ "\r\n", "\n").replace('\r', '\n');
+ String expected = readEntirely("test-write-compile-dependencies.xml")
+ .replaceAll("\r\n", "\n").replace('\r', '\n');
+ assertEquals(expected, wrote);
+ }
+
+ public void testWriteRuntimeConfigurationOnly() throws Exception {
+ ModuleDescriptor md =
PomModuleDescriptorParser.getInstance().parseDescriptor(
+ new IvySettings(),
getClass().getResource("test-dependencies-with-scope.pom"), false);
+ PomModuleDescriptorWriter.write(md, new String[] {"runtime"}, LICENSE,
PomModuleDescriptorWriter.DEFAULT_MAPPING, _dest);
+ assertTrue(_dest.exists());
+
+ String wrote = FileUtil.readEntirely(new BufferedReader(new
FileReader(_dest))).replaceAll(
+ "\r\n", "\n").replace('\r', '\n');
+ String expected =
readEntirely("test-write-dependencies-with-scope.xml")
+ .replaceAll("\r\n", "\n").replace('\r', '\n');
+ assertEquals(expected, wrote);
+ }
+
+ public void testWriteAllConfiguration() throws Exception {
+ ModuleDescriptor md =
PomModuleDescriptorParser.getInstance().parseDescriptor(
+ new IvySettings(),
getClass().getResource("test-dependencies-with-scope.pom"), false);
+ PomModuleDescriptorWriter.write(md, new String[] {"*"}, LICENSE,
PomModuleDescriptorWriter.DEFAULT_MAPPING, _dest);
+ assertTrue(_dest.exists());
+
+ String wrote = FileUtil.readEntirely(new BufferedReader(new
FileReader(_dest))).replaceAll(
+ "\r\n", "\n").replace('\r', '\n');
+ String expected =
readEntirely("test-write-dependencies-with-scope.xml")
+ .replaceAll("\r\n", "\n").replace('\r', '\n');
+ assertEquals(expected, wrote);
+ }
+
+ public void testWriteAllExceptRuntimeConfiguration() throws Exception {
+ ModuleDescriptor md =
PomModuleDescriptorParser.getInstance().parseDescriptor(
+ new IvySettings(),
getClass().getResource("test-dependencies-with-scope.pom"), false);
+ PomModuleDescriptorWriter.write(md, new String[] {"*", "!runtime"},
LICENSE, PomModuleDescriptorWriter.DEFAULT_MAPPING, _dest);
+ assertTrue(_dest.exists());
+
+ String wrote = FileUtil.readEntirely(new BufferedReader(new
FileReader(_dest))).replaceAll(
+ "\r\n", "\n").replace('\r', '\n');
+ String expected = readEntirely("test-write-compile-dependencies.xml")
+ .replaceAll("\r\n", "\n").replace('\r', '\n');
+ assertEquals(expected, wrote);
+ }
+
private String readEntirely(String resource) throws IOException {
return FileUtil.readEntirely(new BufferedReader(new InputStreamReader(
PomModuleDescriptorWriterTest.class.getResource(resource).openStream())));
Modified:
ant/ivy/core/branches/2.2.x/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorWriterTest.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/branches/2.2.x/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorWriterTest.java?rev=965297&r1=965296&r2=965297&view=diff
==============================================================================
---
ant/ivy/core/branches/2.2.x/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorWriterTest.java
(original)
+++
ant/ivy/core/branches/2.2.x/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorWriterTest.java
Sun Jul 18 21:33:39 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())));