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

(Howard Lewis Ship) #1

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

(Peter Niederwieser) #2

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).

(Howard Lewis Ship) #3

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?

(Howard Lewis Ship) #4

Still having trouble in my real project, update shortly.

(Peter Niederwieser) #5

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.)

(Howard Lewis Ship) #6

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.

(Peter Niederwieser) #7

Personally, I always run ‘gradlew cleanIdea idea’.

(Howard Lewis Ship) #8

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