FIX: the 'ivy:install' task didn't take the 'from' resolver into account when resolving Maven parent modules or source/javadoc artifacts.

This commit is contained in:
Maarten Coene 2026-05-20 09:09:40 +02:00
parent 8d21b6d0c4
commit a4c22ca869
No known key found for this signature in database
GPG Key ID: 5BE0BA8CB80602AE
5 changed files with 47 additions and 4 deletions

View File

@ -87,7 +87,7 @@ Export-Package: org.apache.ivy;version="2.0.0",
org.apache.ivy.plugins.namespace;version="2.0.0",
org.apache.ivy.plugins.pack;version="2.6.0",
org.apache.ivy.plugins.parser;version="2.0.0",
org.apache.ivy.plugins.parser.m2;version="2.0.0",
org.apache.ivy.plugins.parser.m2;version="2.6.0",
org.apache.ivy.plugins.parser.xml;version="2.0.0",
org.apache.ivy.plugins.report;version="2.0.0",
org.apache.ivy.plugins.repository;version="2.0.0",

View File

@ -61,6 +61,7 @@ Note, if you have resolved dependencies with version of Ivy prior to 2.6.0, you
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)
- FIX: the `ivy:install` task didn't take the `from` resolver into account when resolving Maven parent modules or source/javadoc artifacts.
== Committers and Contributors
@ -103,6 +104,7 @@ Here is the list of people who have contributed source code and documentation up
* Mirko Bulovic
* Ed Burcher
* Jamie Burns
* Colin Chambers
* Wei Chen
* Chris Chilvers
* Kristian Cibulskis

View File

@ -378,7 +378,14 @@ public final class PomModuleDescriptorParser implements ModuleDescriptorParser {
ModuleDescriptor md = mdBuilder.getModuleDescriptor();
ModuleRevisionId mrid = md.getModuleRevisionId();
DependencyResolver resolver = ivySettings.getResolver(mrid);
// get the resolver configured on the engine and if none is configured then
// get the one configured in ivy settings
ResolveEngine engine = IvyContext.getContext().getIvy().getResolveEngine();
DependencyResolver resolver = engine.getDictatorResolver();
if (resolver == null) {
resolver = ivySettings.getResolver(mrid);
}
if (resolver == null) {
Message.debug(
@ -442,15 +449,21 @@ public final class PomModuleDescriptorParser implements ModuleDescriptorParser {
}
try {
DependencyDescriptor dd = new DefaultDependencyDescriptor(parentModRevID, true);
ResolveEngine engine = IvyContext.getContext().getIvy().getResolveEngine();
ResolveData data = IvyContext.getContext().getResolveData();
if (data == null) {
ResolveEngine engine = IvyContext.getContext().getIvy().getResolveEngine();
ResolveOptions options = new ResolveOptions();
options.setDownload(false);
data = new ResolveData(engine, options);
}
DependencyResolver resolver = ivySettings.getResolver(parentModRevID);
// get the resolver configured on the engine and if none is configured then
// get the one configured in ivy settings
DependencyResolver resolver = engine.getDictatorResolver();
if (resolver == null) {
resolver = ivySettings.getResolver(parentModRevID);
}
if (resolver == null) {
// TODO: Throw exception here?
return null;

View File

@ -83,6 +83,32 @@ public class InstallTest {
assertTrue(new File("build/test/install/org.apache/test/test-1.0.pom").exists());
}
@Test
public void testMavenParent() throws Exception {
Ivy ivy = Ivy.newInstance();
ivy.configure(new File("test/repositories/ivysettings.xml"));
@SuppressWarnings("unused")
ResolveReport rr = ivy.install(ModuleRevisionId.newInstance("org.apache", "test-parent", "1.0"),
ivy.getSettings().getDefaultResolver().getName(), "install", new InstallOptions());
assertTrue(new File("build/test/install/org.apache/test-parent/ivy-1.0.xml").exists());
assertTrue(new File("build/test/install/org.apache/test-parent/test-parent-1.0.jar").exists());
}
@Test
public void testMavenParentWithoutDefaultResolver() throws Exception {
Ivy ivy = Ivy.newInstance();
ivy.configure(new File("test/repositories/ivysettings-nodefaultresolver.xml"));
@SuppressWarnings("unused")
ResolveReport rr = ivy.install(ModuleRevisionId.newInstance("org.apache", "test-parent", "1.0"),
"test", "install", new InstallOptions());
assertTrue(new File("build/test/install/org.apache/test-parent/ivy-1.0.xml").exists());
assertTrue(new File("build/test/install/org.apache/test-parent/test-parent-1.0.jar").exists());
}
@Test
public void testNoValidate() throws Exception {
Ivy ivy = Ivy.newInstance();

View File

@ -34,6 +34,8 @@
<artifact pattern="${ivy.settings.dir}/2/[module]/[artifact].[ext]"/>
</filesystem>
</dual>
<ibiblio name="m2" m2compatible="true" useMavenMetadata="true"
root="${ivy.settings.dir.url}/m2" />
</chain>
<filesystem name="install">
<ivy pattern="${ivy.basedir}/build/test/install/[organisation]/[module]/[artifact]-[revision].[ext]"/>