How to exclude one version from compile/runtime dependencies

My project has a dependency of Java-WebSocket - there are 2 versions on Maven: 1.3.0 and 1.3.4. Moving to 1.3.4 necessitated some changes to my code, so it doesn’t work with 1.3.0 any more. I’d like to add a dependency to build.gradle, specifying 1.3.4 and up, but excluding 1.3.0. So far I haven’t found a way to do this… or is this really necessary…? Thanks in advance.

This is basically the default behavior. If you declare your dependency on 1.3.4, anything lower in transitive dependencies will be resolved up to 1.3.4. If another dependency transitively depends on a version higher, you’ll get that. It is unnecessary to specifically exclude 1.3.0.

However, if at some point there was a version in the middle that you didn’t want (1.3.4 or higher, but not 1.3.5, for example), Component selection rules should help.

Thanks, James, that’s great! So I don’t have to use a notation like *version:
"[1.3,)" *, as that doesn’t seem to go down to the 3rd version level - e.g.
.4…?

Does declaring a dependency on 1.3.4 also work if they decide to go up to
e.g. 2.0.0?

Thanks in advance,

Paul

Yes, the default Gradle dependency resolution will treat your declared version as the floor. It will resolve to ‘1.3.4’ or anything higher found anywhere in the dependency graph.

In the case of dynamic version notation, it will use the highest specified by each notation, then select the highest of those versions anywhere in the graph. It will not calculate the highest intersection of the notations. If you require something more sophisticated, you either need to use a plugin that provides the desired behavior or model the rules yourself.

Thanks James,

Much simpler than I thought it would be!

Best regards

Paul