Redefine version priority during dependency resolution


I have a usecase where I want to override Gradles default behaviour when selecting the latest version of a dependency library. In my case I want libraries with a version number like “latest-SNAPSHOT” to always be prioritiezed when resolving version conflicts.

Eg. mylib:latest-SNAPSHOT > mylib:8.2.4 > mylib:8.1.0

The default behaviour by gradle automatically selects mylib:8.2.4 in favor for latest-SNAPSHOT and that is my problem.

I know you can force a library to use a specific version with resolutionStrategy.force but the problem is that I want to write a general config script where I dont know what specific libs will be resolved at compile time.

Does anyone know is this is possible?