IVY-1410: FIX: the 'ivy:deliver' task didn't replace dynamic revision from inherited dependencies.
diff --git a/asciidoc/release-notes.adoc b/asciidoc/release-notes.adoc
index 4672030..6e2a57a 100644
--- a/asciidoc/release-notes.adoc
+++ b/asciidoc/release-notes.adoc
@@ -60,6 +60,7 @@
- FIX: when the `ivy:deliver` task is configured to replace dynamic revisions, it now replaces these revisions to the resolved revision before any conflict resolution was done, which was the original behavior before Ivy 2.3.0.
This way, the delivered ivy.xml can be used to have reproducible dependency resolution, especially when multiple configurations are used.
It also fixes issues where the dynamic revisions were replaced by versions from other configurations. (IVY-1485, IVY-1661)
+- FIX: the `ivy:deliver` task didn't replace dynamic revision from inherited dependencies. (IVY-1410) (Thanks to Eric Milles)
== Committers and Contributors
diff --git a/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorUpdater.java b/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorUpdater.java
index 83440c4..9af53fa 100644
--- a/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorUpdater.java
+++ b/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorUpdater.java
@@ -1101,11 +1101,23 @@
private void writeInheritedDependencies(ModuleDescriptor merged) {
if (!mergedDependencies) {
mergedDependencies = true;
- writeInheritedItems(merged, merged.getDependencies(), DependencyPrinter.INSTANCE,
+ writeInheritedItems(merged, getDependencies(merged), DependencyPrinter.INSTANCE,
"dependencies", false);
}
}
+ private DependencyDescriptor[] getDependencies(ModuleDescriptor merged) {
+ DependencyDescriptor[] dependencies = merged.getDependencies();
+ for (int i = 0; i < dependencies.length; i += 1) {
+ ModuleRevisionId mrid = dependencies[i].getDependencyRevisionId();
+ String rev = resolvedRevisions.get(mrid); // IVY-1410
+ if (rev != null && !rev.equals(mrid.getRevision())) {
+ dependencies[i] = dependencies[i].clone(ModuleRevisionId.newInstance(mrid, rev));
+ }
+ }
+ return dependencies;
+ }
+
/**
* <p>
* If publishing in merge mode, guarantee that any merged elements appearing before
diff --git a/test/java/org/apache/ivy/core/deliver/DeliverTest.java b/test/java/org/apache/ivy/core/deliver/DeliverTest.java
index cb194bc..aa303ef 100644
--- a/test/java/org/apache/ivy/core/deliver/DeliverTest.java
+++ b/test/java/org/apache/ivy/core/deliver/DeliverTest.java
@@ -92,6 +92,25 @@
assertTrue(deliverContent.contains("name=\"b\" rev=\"1.5\""));
}
+ /**
+ * Test case for <a href="https://issues.apache.org/jira/browse/IVY-1410">IVY-1410</a>.
+ */
+ @Test
+ public void testDeliver1410() throws Exception {
+ Project project = ivyDeliver.getProject();
+ project.setProperty("ivy.settings.file", "test/repositories/ivysettings-1.xml");
+ File ivyFile = new File(new URI(DeliverTest.class.getResource("ivy-1410.xml").toString()));
+
+ resolve(ivyFile);
+
+ ivyDeliver.setReplacedynamicrev(true);
+ ivyDeliver.doExecute();
+
+ String deliverContent = readFile(deliverDir.getAbsolutePath() + "/ivys/ivy-1.0.xml");
+ assertTrue(deliverContent.contains("org=\"org1\" name=\"mod1.1\" rev=\"1.1\""));
+ assertTrue(deliverContent.contains("org=\"org2\" name=\"mod2.1\" rev=\"0.7\""));
+ }
+
private void resolve(File ivyFile) {
IvyResolve ivyResolve = new IvyResolve();
ivyResolve.setProject(ivyDeliver.getProject());
diff --git a/test/java/org/apache/ivy/core/deliver/ivy-1410-parent.xml b/test/java/org/apache/ivy/core/deliver/ivy-1410-parent.xml
new file mode 100644
index 0000000..31f59d3
--- /dev/null
+++ b/test/java/org/apache/ivy/core/deliver/ivy-1410-parent.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
+
+ https://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="2.0">
+ <info organisation="org" module="xxx"/>
+ <dependencies>
+ <dependency org="org1" name="mod1.1" rev="1.+"/>
+ </dependencies>
+</ivy-module>
diff --git a/test/java/org/apache/ivy/core/deliver/ivy-1410.xml b/test/java/org/apache/ivy/core/deliver/ivy-1410.xml
new file mode 100644
index 0000000..459e18c
--- /dev/null
+++ b/test/java/org/apache/ivy/core/deliver/ivy-1410.xml
@@ -0,0 +1,27 @@
+<!--
+ 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
+
+ https://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="2.0">
+ <info organisation="org" module="yyy" revision="1.0">
+ <extends organisation="org" module="xxx" extendType="dependencies"
+ location="ivy-1410-parent.xml" revision="latest"/>
+ </info>
+ <dependencies>
+ <dependency org="org2" name="mod2.1" rev="0.+"/>
+ </dependencies>
+</ivy-module>
\ No newline at end of file