Artifact published to local maven repository is ignored in favor of out-of-date snapshot from remote repository

console output

First I build my artifact and deploy it to the local Maven repository.

Then I build my project dependent on it.

As you can see, there’s no note about the local Maven repository version, and what is downloaded does not match what I just pushed into my local Maven repository.

If I push my local changes to our projects repository, it will break the CI server until I get everything stable, that’s why I temporarily resort to using Maven local.

Here’s my build script:

build script

Moving ‘mavenLocal()’ before the remote repository declaration should solve the problem. Additionally, you may need to set ‘configurations.all { resolutionStrategy.cacheChangingModulesFor 0, “seconds” }’ (but I haven’t verified this).

Moving the mavenLocal() first didn’t change it … and I though Gradle consulted all repositories, not just the first match?

Hm. Looks like the resolutionStrategy change did get the job done. This is counter-intuitive for me. What’s the default for cache changing?

1 Like

Still having trouble in my real project, update shortly.

Gradle goes with the first match, and the default TTL is 24h. (Both statements also hold for Maven, but Maven treats the local repo differently from all other repos, and Gradle only does so in some areas.)

I may be having a related problem with the “idea” task; eventually I manually deleted my Idea files and re-rant it and finally have the correct dependency visible in my project.

Personally, I always run ‘gradlew cleanIdea idea’.

cleanIdea was insufficient for some reason, had to actually delete the files. Odd.