[GRADLE-1570] Allow shorthand to replace transitive dependency version with another version Created: 23/May/11  Updated: 01/May/13  Resolved: 01/May/13

Status: Resolved
Project: Gradle
Affects Version/s: 1.0-milestone-2
Fix Version/s: 1.5-rc-1

Type: Improvement
Reporter: Daniel Gredler Assignee: Unassigned
Resolution: Fixed Votes: 1


Not sure if this is worth the extra API surface area, but it's fairly common to need to exclude a transitive dependency and replace it with a different version of the same dependency. So for example if you depend on library foo, which depends on commons-logging 1.1, and you want to use commons-logging 1.1.1 instead, then it might be nice to be able to do the following:

dependencies {

{ replaceVersion "commons-logging:commons-logging:1.1.1" }


In terms of API, "replace" would be nice and terse, but maybe "replaceVersion" is more descriptive?

Obviously you can already do this via "exclude" and by then adding a separate dependency on e.g. commons-logging 1.1.1, but this makes the intent explicit – that what you're doing is replacing a transitive dependency's version. Without this explicit syntax, you have to manually add a comment to the build file documenting that the two actions are related in purpose.

Anyway, just an idea. Feel free to shoot it down or refine it or ask more questions.

Comment by Daniel Gredler [ 07/Feb/12 ]

Another use case you may want to consider: wanting to replace a transitive dependency with a completely different transitive dependency, e.g. replacing a transitive dependency on commons-logging with a transitive dependency on jcl-over-slf4j.

Comment by Adam Murdoch [ 01/May/13 ]

Dependency resolve rules now allow you to do this in a relatively shorthand way.

Generated at Wed Jun 30 11:58:54 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.