Explicit repository assignment for dependencies


I would like to work-around the issue that Gradle uses the first matching SNAPSHOT it can find, instead of checking other repositories as well for a snapshot that is same version but later build date. See Gradle does not check SNAPSHOT timestamps across repos
My current quick fix is to add a property like ‘gradle start -Plocal’ that will put mavenLocal() before maven remote, and thus give precedence to local snapshots. However, this is coarse-grained because it gives ALL local SNAPSHOT builds precedence over remote, even if they are weeks older.

One way to fix this would be to allow a user to override certain dependencies explicitly via command-line arguments. I would like to allow a user to tell what artifact he wants to use from his local Maven cache, instead of letting gradle fetch it from a remote Maven repository.
eg ‘gradle start -Plocal=my-own-artifact’

I would then say in the dependencies that that artifact needs to use mavenLocal() explicitly, while other use maven remote as usual. Apparantly this was asked before at http://stackoverflow.com/questions/17597516/gradle-specify-appropriate-repo-for-dependency
Is there any feature like this possible now, or coming?


1 Like

IMO this issue makes the SNAPSHOT concept of maven unusable within Gradle.
A open issue for us since 2012 and there seems no workaround available.

did you or anybody else got around this issue?

Glad to hear I’m not alone with this issue, as I was thinking the issue must be me then.
Have been cursing on this for years, and it will never stop. It is very hard to keep explaining this to co-developers that stick with Maven. They face dependency issues quite a lot and all I can provide are CLI switches that make sure the correct repo is used. But when using an editor like intelliJ, one needs to get really creative with flags in the gralde settings that people forget etc. It hurts a lot.