Skip to content

[2.x] Fix #7951: Apply dependencyOverrides to delivered Ivy XML#8463

Merged
eed3si9n merged 4 commits intosbt:developfrom
MkDev11:fix/dependency-overrides-ivy-7951
Jan 11, 2026
Merged

[2.x] Fix #7951: Apply dependencyOverrides to delivered Ivy XML#8463
eed3si9n merged 4 commits intosbt:developfrom
MkDev11:fix/dependency-overrides-ivy-7951

Conversation

@MkDev11
Copy link
Copy Markdown
Contributor

@MkDev11 MkDev11 commented Jan 10, 2026

Fix dependencyOverrides not applied to Ivy XML

What's the problem?

When you use dependencyOverrides in your build and then run publishLocal, the generated Ivy XML file ignores your overrides. Instead of writing the actual version you specified, it writes rev="managed" - which is useless to anyone consuming your published artifact.

For example, if you have:

libraryDependencies += "org.slf4j" % "slf4j-api" % "1.7.36"
dependencyOverrides += "org.slf4j" % "slf4j-api" % "2.0.16"

The published ivy.xml would contain:

<dependency org="org.slf4j" name="slf4j-api" rev="managed" .../>

Instead of the expected:

<dependency org="org.slf4j" name="slf4j-api" rev="2.0.16" .../>

This breaks downstream consumers who rely on the Ivy XML for dependency resolution.

Why does this happen?

Ivy's internal deliver() method doesn't apply DependencyDescriptorMediators (which is how sbt implements dependencyOverrides) when generating the XML output. The overrides work fine during resolution, but they're lost when writing the file.

The fix

After Ivy generates the XML file, we now post-process it to apply the overrides. The fix:

  1. Reads the delivered Ivy XML
  2. Finds all <dependency> elements
  3. For each one that has a matching override, updates the rev attribute
  4. Writes the corrected XML back

It's a simple and targeted fix that doesn't change Ivy's internals - just patches up the output.

Testing

Added unit tests that verify:

  • Overridden dependencies get the correct version
  • All other attributes (conf, transitive, force, etc.) are preserved
  • Dependencies without overrides are left alone

Fixes #7951


Contribution by Gittensor, see my contribution statistics at https://gittensor.io/miners/details?githubId=94194147

Post-process the delivered Ivy XML file to apply dependency overrides.
This is necessary because Ivy's deliver() method doesn't automatically
apply DependencyDescriptorMediators when writing the XML.

The fix:
- Adds applyOverridesToDeliveredIvy() method in IvyActions
- Reads the delivered Ivy XML and transforms dependency elements
- Updates rev attributes for dependencies that have overrides
- Ensures consistency between Maven POM and Ivy XML publishing

Added unit tests to verify:
- Overrides are correctly applied to matching dependencies
- All other attributes are preserved
- Non-matching dependencies remain unchanged
@MkDev11 MkDev11 requested a review from eed3si9n January 10, 2026 23:51
Copy link
Copy Markdown
Member

@eed3si9n eed3si9n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@eed3si9n eed3si9n changed the title Fix #7951: Apply dependencyOverrides to delivered Ivy XML [2.x] Fix #7951: Apply dependencyOverrides to delivered Ivy XML Jan 10, 2026
@eed3si9n eed3si9n merged commit 4bee874 into sbt:develop Jan 11, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dependencyOverrides are not taken into account for ivy

2 participants