Snapshot dependencies with sources/test classifier are not updated


(ben.halton) #1

We publish source and test code jars for common libraries to Nexus.

So we end up with something like:

core-1.0-SNAPSHOT.jar core-1.0-SNAPSHOT-sources.jar core-1.0-SNAPSHOT-test.jar

Then I refer to the test jar from another project like so:

testCompile group: 'foo', name: 'core', version: '1.0-SNAPSHOT.jar', classifier: 'test'

This works the first time it is run but the updates do not get downloaded. So I have the usual:

configurations.all {
    resolutionStrategy {
        //don't cache snapshots
        cacheChangingModulesFor 0, 'seconds'
    }
}

This works for the main artifact but not for the test jar. What can I do to get the test jar to update like a normal SNAPSHOT?

Cheers, Ben


(Luke Daley) #2

Hi Ben,

What Gradle version? And what’s the repository definition that this dependency will be coming from?


(ben.halton) #3

Gradle version M8a

The repository is a Nexus Maven repo.

I meant to mention that if I run --refresh dependencies, then that brings down the latest test jar. So it is possible, but I’d prefer it to work like a standard changing dependency.


(Luke Daley) #4

I just noticed that the version in:

group: 'foo', name: 'core', version: '1.0-SNAPSHOT.jar', classifier: 'test'

Doesn’t look right. Is that a copy/paste error?


(ben.halton) #5

sorry yes that’s a typo

As I say - it works OK first time (i.e. nothing in local cache), and if I do --refresh dependencies.

I suspect it is using the default caching resolution strategy rather than the zero seconds one I have specified. I’ll try to see today if I get a new version down after 24hrs.


(ben.halton) #6

A bit more detail in case it is useful

we create the test code jar like so:

task testsJar(type: Jar, dependsOn: testClasses) {
    classifier = 'tests'
    from sourceSets.test.output.classesDir
}

and publish to nexus by adding it to the artifacts like so:

artifacts {
    archives sourcesJar
    archives testsJar
}

FWIW we also seem to have the same problem with the sources jar.


(Luke Daley) #7

Linked to GRADLE-2175.


#8

Can you try declaring your dependency like:

testCompile group: 'foo', name: 'core', version: '1.0-SNAPSHOT.jar',
             classifier: 'test', changing: true

I suspect that we’re not automatically flagging 1.0-SNAPSHOT-test.jar as ‘changing’.


(ben.halton) #9

Hi Daz yes I have tried this but it didn’t seem to help.

I’ll have another go when I get a chance and let you know.


(ben.halton) #10

OK I can confirm that using ‘changing: true’ does not solve the problem.

Thanks, Ben


(Davide Cavestro) #11

We had to publish sources inside the main jar and remove publishing of sources artifacts in order to avoid troublesome desynchronization on the IDE side… otherwise people would see old sources whilst using updated binaries.


(idanh) #12

This is still an issue. Anyone figured out how to fix this?

Thanks