What is the best way to ensure that an entire group contains the same version? For example, lets say I wanted to ensure that all Spring dependencies (including transitive) were the same version? The best I can come up with was something like this:
configurations.all {
resolutionStrategy {
['tx','jdbc', .... ].each { force "org.springframework:spring-$it:$springVersion" }
}
}
The approach above is not ideal since I have to continually update the resolutionStrategy with any Spring dependency brought in. Based on a little bit of experimentation and the documentation on ResolutionStrategy#force it does not appear restricting versions without specifying the exact artifact is supported. Does anyone have any tips on dealing with this?
There are a number of frameworks that release many artifacts within the same group and require the versions to be the same (i.e. Spring, slf4j, etc). If there is no concise way of specifying a version for an entire group, I think it would be really nice if something like this could be supported:
configurations.all {
resolutionStrategy {
force "org.springframework:*:$springVersion"
}
}
Another variant that would be nice is to support a wildcard in the group so that subgroups like org.springframework.security would also be impacted. For example, something like the following would ensure any artifact with a group starting with org.springframework would use the same version:
configurations.all {
resolutionStrategy {
force "org.springframework*:*:$springVersion"
}
}
Of course allowing force to accept a closure would also be nice. Something like the following would enforce springVersion for everything artifact that starts with the group org.springframework and return null (indicate use the default resolution for it) for other artifacts:
configurations.all {
resolutionStrategy {
force { return it.group.startsWith('org.springframework') ? springVersion : null; }
}
}
Any thoughts to how I can implement this? Any thoughts to the suggestions above?
Thanks, Rob Winch