I’m working with gradle and although I’ve been using exclude with success to remove transitive dependencies I don’t want, I can’t seem to work out how to solve the following.
I would suggest excluding at the configuration level. That way, the exclusion will apply regardless of which of your dependencies transitively pulled in the unwanted artifact.
Note that in your specific example, gradle would already reject the older version by default. This is described further in “50.2.3. Resolve version conflicts” of the same chapter in the user guide.