You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by hi...@apache.org on 2014/10/28 22:37:11 UTC
[08/35] git commit: IMPROVEMENT: ivy:makepom will generate an
exclusion when transitive=false on a dependency (IVY-1470)
IMPROVEMENT: ivy:makepom will generate an exclusion when transitive=false on a dependency (IVY-1470)
git-svn-id: https://svn.apache.org/repos/asf/ant/ivy/core/trunk@1592628 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/ant-ivy/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant-ivy/commit/e484646c
Tree: http://git-wip-us.apache.org/repos/asf/ant-ivy/tree/e484646c
Diff: http://git-wip-us.apache.org/repos/asf/ant-ivy/diff/e484646c
Branch: refs/heads/2.4.x
Commit: e484646c60eaca1f89921db7058d8927302d7226
Parents: 8d85139
Author: Maarten Coene <ma...@apache.org>
Authored: Mon May 5 20:56:51 2014 +0000
Committer: Maarten Coene <ma...@apache.org>
Committed: Mon May 5 20:56:51 2014 +0000
----------------------------------------------------------------------
CHANGES.txt | 1 +
.../parser/m2/PomModuleDescriptorWriter.java | 25 +++++++++---
.../m2/PomModuleDescriptorWriterTest.java | 15 +++++++
.../ivy/plugins/parser/m2/test-transitive.pom | 42 ++++++++++++++++++++
.../ivy/plugins/parser/m2/test-transitive.xml | 24 +++++++++++
5 files changed, 102 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/e484646c/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 572a09a..b59693e 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -144,6 +144,7 @@ for detailed view of each issue, please consult http://issues.apache.org/jira/br
=====================================
- 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
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/e484646c/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorWriter.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorWriter.java b/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorWriter.java
index 5e62288..5cd254a 100644
--- a/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorWriter.java
+++ b/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorWriter.java
@@ -228,7 +228,7 @@ public final class PomModuleDescriptorWriter {
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 PomModuleDescriptorWriter {
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 PomModuleDescriptorWriter {
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 PomModuleDescriptorWriter {
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);
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/e484646c/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorWriterTest.java
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorWriterTest.java b/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorWriterTest.java
index bebd6a7..d37a869 100644
--- a/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorWriterTest.java
+++ b/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorWriterTest.java
@@ -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 PomModuleDescriptorWriterTest extends TestCase {
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);
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/e484646c/test/java/org/apache/ivy/plugins/parser/m2/test-transitive.pom
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/plugins/parser/m2/test-transitive.pom b/test/java/org/apache/ivy/plugins/parser/m2/test-transitive.pom
new file mode 100644
index 0000000..f723715
--- /dev/null
+++ b/test/java/org/apache/ivy/plugins/parser/m2/test-transitive.pom
@@ -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>
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/e484646c/test/java/org/apache/ivy/plugins/parser/m2/test-transitive.xml
----------------------------------------------------------------------
diff --git a/test/java/org/apache/ivy/plugins/parser/m2/test-transitive.xml b/test/java/org/apache/ivy/plugins/parser/m2/test-transitive.xml
new file mode 100644
index 0000000..d95cb6d
--- /dev/null
+++ b/test/java/org/apache/ivy/plugins/parser/m2/test-transitive.xml
@@ -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>