# SNAPSHOT dependency resolution problems

**URL:** <https://discuss.gradle.org/t/snapshot-dependency-resolution-problems/24936>\
**Category:** Help/Discuss\
**Created:** [November 28, 2017, 3:00pm UTC](https://discuss.gradle.org/t/snapshot-dependency-resolution-problems/24936 "2017-11-28T15:00:32Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![Steve\_Ebersole](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/steve_ebersole/32/9763_2.png) [@Steve\_Ebersole](https://discuss.gradle.org/u/Steve_Ebersole)\
**Post date:** [November 28, 2017, 3:00pm UTC](https://discuss.gradle.org/t/snapshot-dependency-resolution-problems/24936/1 "2017-11-28T15:00:32Z")

</div>

I’ve searched these forums as well as SO. On these forums I found nothing that exactly matches the problem I am seeing, even though it seems like the most basic of SNAPSHOT resolution problems. On SO I only found (seemingly) out-of-date solutions that do not fix the problem. So I apologize up front if I missed something - please free to point me to the information I missed

All that said I am having trouble getting SNAPSHOT dependencies to be resolved properly. The generalized problem is that Gradle has trouble recognizing newer SNAPSHOT versions.

I have a pretty basic dependency:

`
ext {
    hibernateVersion = '5.3.0-SNAPSHOT'
}
dependencies {
compile( “org.hibernate:hibernate-core:${hibernateVersion}” )
compile( “org.hibernate:hibernate-testing:${hibernateVersion}” ) {
transitive = false
}
}
`

When I publish new SNAPSHOTs of these Gradle will often ignore the newer ones. I’ve tried one consistent suggestion I found on SO:

`
configurations.all {
    // check for updates every build
    resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
ext {
hibernateVersion = ‘5.3.0-SNAPSHOT’
}
dependencies {
compile( “org.hibernate:hibernate-core:${hibernateVersion}” ) {
changing = true
}
compile( “org.hibernate:hibernate-testing:${hibernateVersion}” ) {
transitive = false
changing = true
}
}
`

However, even this does not work. So as an example, I perform a publish on hibernate-core:  
`
Upload https://repository.jboss.org/nexus/content/repositories/snapshots/org/hibernate/hibernate-core/5.3.0-SNAPSHOT/hibernate-core-5.3.0-20171128.145357-16.jar
`

But Gradle does not “see” this version, instead keeping the one it previously downloaded:  
`
Download http://repository.jboss.org/nexus/content/groups/public/org/hibernate/hibernate-core/5.3.0-SNAPSHOT/hibernate-core-5.3.0-20171128.034434-15.jar
`

As you can see the versions are not the same. And to clarify, this repo makes these uploaded artifacts available immediately so there is no “latency” problem.

Interestingly, after 24 hours it does now see the newer version. I say 24 hours because AFAIK that is the Gradle default handling for SNAPSHOT dependencies, although all I can really say definitively is that it is after some “significant” amount of time" has passed.

So its essentially like Gradle either does not see these dependency/configuration changes or accept/honor them.

How do I fix this? Thanks in advance

---

<div class="post-metadata">

**Author:** ![Steve\_Ebersole](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/steve_ebersole/32/9763_2.png) [@Steve\_Ebersole](https://discuss.gradle.org/u/Steve_Ebersole)\
**Post date:** [November 28, 2017, 3:03pm UTC](https://discuss.gradle.org/t/snapshot-dependency-resolution-problems/24936/2 "2017-11-28T15:03:35Z")

</div>

BTW, I fogot to mention - I have also tried deleting the local gradle cached version of the entire 5.3.0-SNAPSHOT directory to no avail… Grade simply downloads the older one again.

---

<div class="post-metadata">

**Author:** ![Steve\_Ebersole](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/steve_ebersole/32/9763_2.png) [@Steve\_Ebersole](https://discuss.gradle.org/u/Steve_Ebersole)\
**Post date:** [November 30, 2017, 1:17am UTC](https://discuss.gradle.org/t/snapshot-dependency-resolution-problems/24936/3 "2017-11-30T01:17:47Z")

</div>

So I guess I can assume SNAPSHOT dependencies really are not supported by Gradle, which is just a huge disappointment. And I consider Gradle not being able to disable the caching of these to be non-support. Very disappointing.

---

<div class="post-metadata">

**Author:** ![bmuschko](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/bmuschko/32/5458_2.png) [@bmuschko](https://discuss.gradle.org/u/bmuschko)\
**Post date:** [November 30, 2017, 2:40am UTC](https://discuss.gradle.org/t/snapshot-dependency-resolution-problems/24936/4 "2017-11-30T02:40:52Z")

</div>

Hi Steve,

I tried to reproduce your issue but couldn’t. Please find my sample project [here](https://github.com/bmuschko/cached-snapshot-ttl). For trying it out I downloaded and installed [Artifactory OSS 5.6.2](https://www.jfrog.com/open-source/).

1. In Artifactory set up a local Maven 2 repository. The “Maven Snapshot Version Behavior” is set to “Unique”, meaning it’s timestamp based.
2. Navigate to `producer` directory. Upload a new snapshot version with `../gradlew uploadArchives`.
3. Navigate to `consumer` directory. Use the latest snapshot version by executing `../gradlew run`. You should see the message rendered by the main method.
4. Change the message rendered in the main method. Repeat 2. and 3. You should see the changed message.

Some comments about your code:

- Dependencies with SNAPSHOT suffix in version are changing by default. You don’t need to add `changing = true`.
- Where exactly do you apply `resolutionStrategy.cacheChangingModulesFor`? Maybe the setting is not applied somehow.
- What repository product are you using? From the URL it seems like you are using Sonatype Nexus? If yes what settings are you using for your repository?

---

<div class="post-metadata">

**Author:** ![Steve\_Ebersole](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/steve_ebersole/32/9763_2.png) [@Steve\_Ebersole](https://discuss.gradle.org/u/Steve_Ebersole)\
**Post date:** [November 30, 2017, 2:53am UTC](https://discuss.gradle.org/t/snapshot-dependency-resolution-problems/24936/5 "2017-11-30T02:53:25Z")

</div>

Hey Benjamin, you can see the entire contents of the file here: [https://gist.github.com/sebersole/c396ca6ed62f5a93777710f34f0ccad5](https://gist.github.com/sebersole/c396ca6ed62f5a93777710f34f0ccad5)

As for the repo, it is the JBoss Snapshot repo and yes it uses Nexus (beyond my control unfortunately). I have no idea what settings are used. What settings should I ask about?

---

<div class="post-metadata">

**Author:** ![bmuschko](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/bmuschko/32/5458_2.png) [@bmuschko](https://discuss.gradle.org/u/bmuschko)\
**Post date:** [November 30, 2017, 3:37pm UTC](https://discuss.gradle.org/t/snapshot-dependency-resolution-problems/24936/6 "2017-11-30T15:37:16Z")

</div>

I just tried out my sample project with Nexus OSS 3.6.2-01 as well and it works fine. In the settings of the repository I have the following under “Maven 2”:

Version policy: Snapshot  
Layout policy: Strict

 ![nexus](https://global.discourse-cdn.com/gradle/original/2X/d/d993785bcf03cea6a168da70868f1205bf259214.png)

Maybe you can ask about the settings you have in place there.

Regarding your project: Can you try to trim down your build code to the basics to see if you can identify a specific issue. Please also remove the `changing=true` as it is not required. Apart from that nothing sticks out as an obvious issue. Could you please also provide the code that publishes the SNAPSHOT version?

---

<div class="post-metadata">

**Author:** ![Steve\_Ebersole](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/steve_ebersole/32/9763_2.png) [@Steve\_Ebersole](https://discuss.gradle.org/u/Steve_Ebersole)\
**Post date:** [November 30, 2017, 3:57pm UTC](https://discuss.gradle.org/t/snapshot-dependency-resolution-problems/24936/7 "2017-11-30T15:57:48Z")

</div>

Thanks for the help Benjamin, I appreciate it.

The code is Hibernate. Specifically this branch: [https://github.com/sebersole/hibernate-core/tree/5.3](https://github.com/sebersole/hibernate-core/tree/5.3). Check out that branch, cd into hibernate-core and run `../gradlew publish`.

Here is what I see in the Nexus UI (I do not have “admin” access, this is just what I can see in the “Repositories” tab):

`
Format: maven2
Policy: Snapshot
`

It does not show any value for “Layout Policy”, but is that really impactful here?

---

<div class="post-metadata">

**Author:** ![Steve\_Ebersole](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/steve_ebersole/32/9763_2.png) [@Steve\_Ebersole](https://discuss.gradle.org/u/Steve_Ebersole)\
**Post date:** [November 30, 2017, 4:00pm UTC](https://discuss.gradle.org/t/snapshot-dependency-resolution-problems/24936/8 "2017-11-30T16:00:38Z")

</div>

I will work on paring that build down. Can you at least confirm that I have the `resolutionStrategy.cacheChangingModulesFor` part correct?

I will remove `changing=true`, but considering that is the default, will that really have in impact?

---

<div class="post-metadata">

**Author:** ![bmuschko](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/bmuschko/32/5458_2.png) [@bmuschko](https://discuss.gradle.org/u/bmuschko)\
**Post date:** [November 30, 2017, 4:23pm UTC](https://discuss.gradle.org/t/snapshot-dependency-resolution-problems/24936/9 "2017-11-30T16:23:57Z")

</div>

> [@](#):
>
> I will work on paring that build down. Can you at least confirm that I have the resolutionStrategy.cacheChangingModulesFor part correct?

That looks correct to me.

> [@](#):
>
> I will remove changing=true, but considering that is the default, will that really have in impact?

That shouldn’t matter. It will just set the property to `true` which should have that value anyway. I just want to remove any unnecessary build code to be able to easier identify the root cause.

> [@](#):
>
> It does not show any value for “Layout Policy”, but is that really impactful here?

I am not a Nexus expert unfortunately but I guess it shouldn’t matter for our use case. Just wanted to make sure that at least the version policy is set correctly.

Two more things I’d like to see:

- Could you provide us with a build scan of a build that does not properly resolve the latest `SNAPSHOT` version?
- Could you run your build with `-d` to see if we can find additional information on what going on under the covers during dependency resolution?

Regarding your publishing code:

1. You are using the new Maven publishing plugin. My code used the “old” one. I am going to try out my sample project with the new plugin to see if there’s some issue.
2. What’s the reason for having this code? I believe you don’t need that.

```gradle
model {
    tasks.generatePomFileForMavenJavaPublication {
        destination = file( "$subProject.buildDir/generated-pom.xml" )
    }
}

```

---

<div class="post-metadata">

**Author:** ![Steve\_Ebersole](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/steve_ebersole/32/9763_2.png) [@Steve\_Ebersole](https://discuss.gradle.org/u/Steve_Ebersole)\
**Post date:** [November 30, 2017, 6:24pm UTC](https://discuss.gradle.org/t/snapshot-dependency-resolution-problems/24936/10 "2017-11-30T18:24:23Z")

</div>

> [@bmuschko](#):
>
> Regarding your publishing code:
> 
> 1. You are using the new Maven publishing plugin. My code used the “old” one. I am going to try out my sample project with the new plugin to see if there’s some issue.
> 2. What’s the reason for having this code? I believe you don’t need that.
> 
> ```gradle
> model {
> tasks.generatePomFileForMavenJavaPublication {
> destination = file( "$subProject.buildDir/generated-pom.xml" )
> }
> }
> 
> ```

IIUC you are asking why I need the `model {..}` block? If so, I don’t understand - I actually do not have that in my build. In fact I do not configure publishing at all, just let the defaults kick in

---

<div class="post-metadata">

**Author:** ![bmuschko](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/bmuschko/32/5458_2.png) [@bmuschko](https://discuss.gradle.org/u/bmuschko)\
**Post date:** [November 30, 2017, 7:06pm UTC](https://discuss.gradle.org/t/snapshot-dependency-resolution-problems/24936/11 "2017-11-30T19:06:56Z")

</div>

> [@Steve\_Ebersole](#):
>
> IIUC you are asking why I need the model {…} block? If so, I don’t understand - I actually do not have that in my build. In fact I do not configure publishing at all, just let the defaults kick in

I was referring to this: [https://github.com/sebersole/hibernate-core/blob/5.3/build.gradle#L456-L482](https://github.com/sebersole/hibernate-core/blob/5.3/build.gradle#L456-L482)

---

<div class="post-metadata">

**Author:** ![Steve\_Ebersole](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/steve_ebersole/32/9763_2.png) [@Steve\_Ebersole](https://discuss.gradle.org/u/Steve_Ebersole)\
**Post date:** [November 30, 2017, 7:13pm UTC](https://discuss.gradle.org/t/snapshot-dependency-resolution-problems/24936/12 "2017-11-30T19:13:07Z")

</div>

At the time, I think it was needed - back when the new publishing had just been kinda-sorta released. Maybe that’s changed… not sure.

---

<div class="post-metadata">

**Author:** ![bmuschko](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/bmuschko/32/5458_2.png) [@bmuschko](https://discuss.gradle.org/u/bmuschko)\
**Post date:** [November 30, 2017, 8:56pm UTC](https://discuss.gradle.org/t/snapshot-dependency-resolution-problems/24936/13 "2017-11-30T20:56:29Z")

</div>

I just tried out my sample project with the Maven Publish plugin. Works as well. I’d need to see your logs/build scan. I’d also be interested in your build options e.g. `configure-on-demand` etc. (that would be part of the build scan if you can provide it).

On your Nexus repository you might also want to check that the latest version is set in [`maven-metadata.xml`](http://snapshots.jboss.org/maven2/org/hibernate/hibernate-core/5.3.0-SNAPSHOT/maven-metadata.xml) after you published a new `SNAPSHOT` version.

BTW: Did this ever work for you?

---

<div class="post-metadata">

**Author:** ![Steve\_Ebersole](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/steve_ebersole/32/9763_2.png) [@Steve\_Ebersole](https://discuss.gradle.org/u/Steve_Ebersole)\
**Post date:** [December 1, 2017, 2:54am UTC](https://discuss.gradle.org/t/snapshot-dependency-resolution-problems/24936/14 "2017-12-01T02:54:27Z")

</div>

No, I have not gotten it to work ☹

How should I configure the bvuildScan?

---

<div class="post-metadata">

**Author:** ![bmuschko](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/bmuschko/32/5458_2.png) [@bmuschko](https://discuss.gradle.org/u/bmuschko)\
**Post date:** [December 1, 2017, 6:40pm UTC](https://discuss.gradle.org/t/snapshot-dependency-resolution-problems/24936/15 "2017-12-01T18:40:47Z")

</div>

You can find the info here: [https://scans.gradle.com/get-started](https://scans.gradle.com/get-started). Looks like you already apply the plugin here: [https://github.com/sebersole/hibernate-core/blob/5.3/build.gradle#L35](https://github.com/sebersole/hibernate-core/blob/5.3/build.gradle#L35) and configure it here: [https://github.com/sebersole/hibernate-core/blob/5.3/build.gradle#L492-L497](https://github.com/sebersole/hibernate-core/blob/5.3/build.gradle#L492-L497). You should get a link at the end of a build for the build scan that you can send us over.

---

<div class="post-metadata">

**Author:** ![Steve\_Ebersole](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/steve_ebersole/32/9763_2.png) [@Steve\_Ebersole](https://discuss.gradle.org/u/Steve_Ebersole)\
**Post date:** [December 1, 2017, 9:10pm UTC](https://discuss.gradle.org/t/snapshot-dependency-resolution-problems/24936/16 "2017-12-01T21:10:57Z")

</div>

I mean specifically for :

`
	recipe 'git-commit', baseUrl: 'https://github.com/hibernate/hibernate-orm/tree'
`

This is not part of the hibernate-orm tree, nor is it in any accessible repo

---

<div class="post-metadata">

**Author:** ![bmuschko](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/bmuschko/32/5458_2.png) [@bmuschko](https://discuss.gradle.org/u/bmuschko)\
**Post date:** [December 1, 2017, 9:49pm UTC](https://discuss.gradle.org/t/snapshot-dependency-resolution-problems/24936/17 "2017-12-01T21:49:11Z")

</div>

You can commented that out. It’s doesn’t really matter much for the analysis I think.

---

<div class="post-metadata">

**Author:** ![Steve\_Ebersole](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/steve_ebersole/32/9763_2.png) [@Steve\_Ebersole](https://discuss.gradle.org/u/Steve_Ebersole)\
**Post date:** [December 1, 2017, 10:24pm UTC](https://discuss.gradle.org/t/snapshot-dependency-resolution-problems/24936/18 "2017-12-01T22:24:48Z")

</div>

Of course. As soon as i add scanning it starts working - it now downloads each new SNAPSHOT immediately after I publish it… ¯\_(ツ)_/¯

---

<div class="post-metadata">

**Author:** ![bmuschko](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/bmuschko/32/5458_2.png) [@bmuschko](https://discuss.gradle.org/u/bmuschko)\
**Post date:** [December 1, 2017, 11:05pm UTC](https://discuss.gradle.org/t/snapshot-dependency-resolution-problems/24936/19 "2017-12-01T23:05:54Z")

</div>

There must be a reason for it. Maybe one of your plugins is messing with the cache settings for SNAPSHOT versions. Not sure. Let us know if you need further assistance.
