This is an automated email from the ASF dual-hosted git repository.

maartenc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ant-ivy.git


The following commit(s) were added to refs/heads/master by this push:
     new 8fe5d37d IVY-1410: FIX: the 'ivy:deliver' task didn't replace dynamic 
revision from inherited dependencies.
8fe5d37d is described below

commit 8fe5d37d6cd2644ca288244564bbd14565b6bad9
Author: Maarten Coene <[email protected]>
AuthorDate: Sun Aug 31 23:39:45 2025 +0200

    IVY-1410: FIX: the 'ivy:deliver' task didn't replace dynamic revision from 
inherited dependencies.
---
 asciidoc/release-notes.adoc                        |  1 +
 .../parser/xml/XmlModuleDescriptorUpdater.java     | 14 ++++++++++-
 .../org/apache/ivy/core/deliver/DeliverTest.java   | 19 +++++++++++++++
 .../apache/ivy/core/deliver/ivy-1410-parent.xml    | 24 +++++++++++++++++++
 test/java/org/apache/ivy/core/deliver/ivy-1410.xml | 27 ++++++++++++++++++++++
 5 files changed, 84 insertions(+), 1 deletion(-)

diff --git a/asciidoc/release-notes.adoc b/asciidoc/release-notes.adoc
index 46720303..6e2a57a0 100644
--- a/asciidoc/release-notes.adoc
+++ b/asciidoc/release-notes.adoc
@@ -60,6 +60,7 @@ Note, if you have resolved dependencies with version of Ivy 
prior to 2.6.0, you
 - 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 83440c4a..9af53fa3 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 @@ public final class XmlModuleDescriptorUpdater {
         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 cb194bc7..aa303ef7 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 @@ public class DeliverTest {
         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 00000000..31f59d37
--- /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 00000000..459e18c4
--- /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

Reply via email to