Author: maartenc
Date: Mon May 5 20:56:51 2014
New Revision: 1592628
URL: http://svn.apache.org/r1592628
Log:
IMPROVEMENT: ivy:makepom will generate an exclusion when transitive=false on a
dependency (IVY-1470)
Added:
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-transitive.pom
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-transitive.xml
Modified:
ant/ivy/core/trunk/CHANGES.txt
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorWriter.java
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorWriterTest.java
Modified: ant/ivy/core/trunk/CHANGES.txt
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=1592628&r1=1592627&r2=1592628&view=diff
==============================================================================
--- ant/ivy/core/trunk/CHANGES.txt (original)
+++ ant/ivy/core/trunk/CHANGES.txt Mon May 5 20:56:51 2014
@@ -144,6 +144,7 @@ for detailed view of each issue, please
=====================================
- IMPROVEMENT: Add support for packed jar within an OSGi bundle
- IMPROVEMENT: ModuleRules.getRule is O(n) leading to resolution slowness
(IVY-1465) (Thanks to Zhong Wang aka Kewpie)
+- IMPROVEMENT: ivy:makepom will generate an exclusion when transitive=false on
a dependency (IVY-1470)
- FIX: impossible to get artifacts when data has not been loaded. (IVY-1399)
(Thanks to David Turner)
- FIX: regression introduced by IVY-1457, dependency management wasn't
properly handled introducing lots of resolution failures
Modified:
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorWriter.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorWriter.java?rev=1592628&r1=1592627&r2=1592628&view=diff
==============================================================================
---
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorWriter.java
(original)
+++
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorWriter.java
Mon May 5 20:56:51 2014
@@ -228,7 +228,7 @@ public final class PomModuleDescriptorWr
version = md.getModuleRevisionId().getRevision();
}
printDependency(out, indent, groupId, dep.getArtifact(),
version, dep.getType(),
- dep.getClassifier(), dep.getScope(), dep.isOptional(),
null);
+ dep.getClassifier(), dep.getScope(), dep.isOptional(),
true, null);
}
// now print the dependencies listed in the ModuleDescriptor
@@ -251,13 +251,15 @@ public final class PomModuleDescriptorWr
String scope =
mapping.getScope(dds[i].getModuleConfigurations());
boolean optional =
mapping.isOptional(dds[i].getModuleConfigurations());
printDependency(out, indent, mrid.getOrganisation(),
mrid.getName(),
- mrid.getRevision(), type, classifier, scope,
optional, excludes);
+ mrid.getRevision(), type, classifier, scope,
optional,
+ dds[i].isTransitive(), excludes);
}
} else {
String scope =
mapping.getScope(dds[i].getModuleConfigurations());
boolean optional =
mapping.isOptional(dds[i].getModuleConfigurations());
printDependency(out, indent, mrid.getOrganisation(),
mrid.getName(),
- mrid.getRevision(), null, null, scope, optional,
excludes);
+ mrid.getRevision(), null, null, scope, optional,
dds[i].isTransitive(),
+ excludes);
}
}
@@ -270,7 +272,7 @@ public final class PomModuleDescriptorWr
private static void printDependency(PrintWriter out, int indent, String
groupId,
String artifactId, String version, String type, String classifier,
String scope,
- boolean isOptional, ExcludeRule[] excludes) {
+ boolean isOptional, boolean isTransitive, ExcludeRule[] excludes) {
indent(out, indent * 2);
out.println("<dependency>");
indent(out, indent * 3);
@@ -295,7 +297,20 @@ public final class PomModuleDescriptorWr
indent(out, indent * 3);
out.println("<optional>true</optional>");
}
- if (excludes != null) {
+ if (!isTransitive) {
+ indent(out, indent * 3);
+ out.println("<exclusions>");
+ indent(out, indent * 4);
+ out.println("<exclusion>");
+ indent(out, indent * 5);
+ out.println("<groupId>*</groupId>");
+ indent(out, indent * 5);
+ out.println("<artifactId>*</artifactId>");
+ indent(out, indent * 4);
+ out.println("</exclusion>");
+ indent(out, indent * 3);
+ out.println("</exclusions>");
+ } else if (excludes != null) {
printExclusions(excludes, out, indent);
}
indent(out, indent * 2);
Modified:
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorWriterTest.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorWriterTest.java?rev=1592628&r1=1592627&r2=1592628&view=diff
==============================================================================
---
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorWriterTest.java
(original)
+++
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorWriterTest.java
Mon May 5 20:56:51 2014
@@ -27,6 +27,7 @@ import junit.framework.TestCase;
import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
import org.apache.ivy.core.settings.IvySettings;
+import org.apache.ivy.plugins.parser.ModuleDescriptorParserRegistry;
import org.apache.ivy.util.FileUtil;
public class PomModuleDescriptorWriterTest extends TestCase {
@@ -121,6 +122,20 @@ public class PomModuleDescriptorWriterTe
assertEquals(expected, wrote);
}
+ public void testTransitive() throws Exception {
+ ModuleDescriptor md =
ModuleDescriptorParserRegistry.getInstance().parseDescriptor(
+ new IvySettings(), getClass().getResource("test-transitive.xml"),
false);
+ PomModuleDescriptorWriter.write(md, _dest, getWriterOptions());
+ assertTrue(_dest.exists());
+
+ String wrote = FileUtil.readEntirely(new BufferedReader(new
FileReader(_dest)))
+ .replaceAll("\r\n", "\n").replace('\r', '\n');
+ System.out.println(wrote);
+ String expected =
readEntirely("test-transitive.pom").replaceAll("\r\n", "\n").replace(
+ '\r', '\n');
+ assertEquals(expected, wrote);
+ }
+
public void testPackaging() throws Exception {
ModuleDescriptor md =
PomModuleDescriptorParser.getInstance().parseDescriptor(
new IvySettings(), getClass().getResource("test-packaging.pom"),
false);
Added:
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-transitive.pom
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-transitive.pom?rev=1592628&view=auto
==============================================================================
---
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-transitive.pom
(added)
+++
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-transitive.pom
Mon May 5 20:56:51 2014
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>apache</groupId>
+ <artifactId>test-transitive</artifactId>
+ <packaging>jar</packaging>
+ <version>1.0</version>
+ <dependencies>
+ <dependency>
+ <groupId>apache</groupId>
+ <artifactId>ivy</artifactId>
+ <version>1.0</version>
+ <optional>true</optional>
+ <exclusions>
+ <exclusion>
+ <groupId>*</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ </dependencies>
+</project>
Added:
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-transitive.xml
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-transitive.xml?rev=1592628&view=auto
==============================================================================
---
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-transitive.xml
(added)
+++
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-transitive.xml
Mon May 5 20:56:51 2014
@@ -0,0 +1,24 @@
+<!--
+ 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">
+ <info organisation="apache" module="test-transitive" revision="1.0"/>
+ <dependencies>
+ <dependency org="apache" name="ivy" rev="1.0" transitive="false" />
+ </dependencies>
+</ivy-module>