IVY-1664: added support for the override child element

This commit is contained in:
Maarten Coene 2025-08-31 14:41:54 +02:00
parent 934bf19233
commit aa3c169322
No known key found for this signature in database
GPG Key ID: 5BE0BA8CB80602AE
6 changed files with 24 additions and 4 deletions

View File

@ -46,7 +46,7 @@ Import-Package: com.jcraft.jsch;resolution:=optional,
org.xml.sax.ext,
org.xml.sax.helpers
Export-Package: org.apache.ivy;version="2.0.0",
org.apache.ivy.ant;version="2.0.0",
org.apache.ivy.ant;version="2.6.0",
org.apache.ivy.core;version="2.0.0",
org.apache.ivy.core.cache;version="2.0.0",
org.apache.ivy.core.check;version="2.0.0",

View File

@ -54,6 +54,7 @@ Note, if you have resolved dependencies with version of Ivy prior to 2.6.0, you
- NEW: added a new `nearest` conflict manager, which handles conflicts in the same way that Maven does. (IVY-813) (Thanks to Eric Milles)
- IMPROVEMENT: use Apache Commons Compress for pack200 handling to avoid issues on Java 14 and later. If pack200 is needed, make sure to add Apache Commons Compress to your classpath. (IVY-1652)
- IMPROVEMENT: `ivy:retrieve` and the 'post resolve tasks' now support the `override` child element. (IVY-1664)
- FIX: improved Maven dependencyManagement matching for dependencies with a non-default type or classifier (IVY-1654) (Thanks to Mark Kittisopikul)
- FIX: the `ivy:retrieve` task failed when the retrieve pattern contained some text in parentheses before the first token, for instance: `/jobs/lib (JDK 17)/[artifact].[ext]` (IVY-1660)
- 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.

View File

@ -83,7 +83,8 @@ There is one important difference with the ivy.xml's link:../ivyfile/dependencie
|Element|Description|Cardinality
|link:../ivyfile/dependency{outfilesuffix}[dependency]|declares a dependency to resolve|0..n
|link:../ivyfile/exclude{outfilesuffix}[exclude]|excludes artifacts, modules or whole organizations from the set of dependencies to resolve|0..n
|link:../ivyfile/override{outfilesuffix}[override]|specify an override mediation rule, overriding the revision and/or branch requested for a transitive dependency (*__since 2.0__*)|0..n
|link:../ivyfile/override{outfilesuffix}[override]|specify an override mediation rule, overriding the revision and/or branch requested for a transitive dependency (*__since 2.6__*)|0..n
|link:../ivyfile/conflict{outfilesuffix}[conflict]|specify a a conflict manager for one or several dependencies|0..n
|=======
== Examples

View File

@ -148,7 +148,8 @@ There is one important difference with the ivy.xml's link:../ivyfile/dependencie
|Element|Description|Cardinality
|link:../ivyfile/dependency{outfilesuffix}[dependency]|declares a dependency to resolve|0..n
|link:../ivyfile/exclude{outfilesuffix}[exclude]|excludes artifacts, modules or whole organizations from the set of dependencies to resolve|0..n
|link:../ivyfile/override{outfilesuffix}[override]|specify an override mediation rule, overriding the revision and/or branch requested for a transitive dependency (*__since 2.0__*)|0..n
|link:../ivyfile/override{outfilesuffix}[override]|specify an override mediation rule, overriding the revision and/or branch requested for a transitive dependency (*__since 2.6__*)|0..n
|link:../ivyfile/conflict{outfilesuffix}[conflict]|specify a a conflict manager for one or several dependencies|0..n
|=======
== Examples

View File

@ -105,6 +105,10 @@ public abstract class IvyPostResolveTask extends IvyTask {
return resolve.createExclude();
}
public IvyOverride createOverride() {
return resolve.createOverride();
}
public IvyConflict createConflict() {
return resolve.createConflict();
}

View File

@ -96,6 +96,8 @@ public class IvyResolve extends IvyTask {
private List<IvyExclude> excludes = new ArrayList<>();
private List<IvyOverride> overrides = new ArrayList<>();
private List<IvyConflict> conflicts = new ArrayList<>();
public boolean isUseOrigin() {
@ -225,6 +227,12 @@ public class IvyResolve extends IvyTask {
return ex;
}
public IvyOverride createOverride() {
IvyOverride o = new IvyOverride();
overrides.add(o);
return o;
}
public IvyConflict createConflict() {
IvyConflict c = new IvyConflict();
conflicts.add(c);
@ -246,7 +254,8 @@ public class IvyResolve extends IvyTask {
type = getProperty(type, settings, "ivy.resolve.default.type.filter");
String[] confs = splitToArray(conf);
boolean childs = !dependencies.isEmpty() || !excludes.isEmpty() || !conflicts.isEmpty();
boolean childs = !dependencies.isEmpty() || !excludes.isEmpty() || !overrides.isEmpty()
|| !conflicts.isEmpty();
ResolveReport report;
if (childs) {
@ -282,6 +291,10 @@ public class IvyResolve extends IvyTask {
md.addExcludeRule(rule);
}
for (IvyOverride override : overrides) {
override.addOverride(md, settings);
}
for (IvyConflict conflict : conflicts) {
conflict.addConflict(md, settings);
}