IVY-1410: FIX: the 'ivy:deliver' task didn't replace dynamic revision from inherited dependencies.

This commit is contained in:
Maarten Coene 2025-08-31 23:39:45 +02:00
parent aa3c169322
commit 8fe5d37d6c
No known key found for this signature in database
GPG Key ID: 5BE0BA8CB80602AE
5 changed files with 84 additions and 1 deletions

View File

@ -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

View File

@ -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

View File

@ -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());

View File

@ -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>

View File

@ -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>