[GRADLE-2175] Snapshot dependencies with sources/test classifier are not considered 'changing' Created: 15/Mar/12  Updated: 17/Sep/16  Resolved: 11/Dec/12

Status: Resolved
Project: Gradle
Affects Version/s: None
Fix Version/s: 1.4-rc-1

Type: Bug
Reporter: Gradle Forums Assignee: René Gröschke (Inactive)
Resolution: Fixed Votes: 4

Issue Links:
Duplicate
Duplicated by GRADLE-2218 eclipse plugin : Snapshot dependencie... Resolved

 Description   

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



 Comments   
Comment by Gradle Forums [ 15/Mar/12 ]

Hi Ben,

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

Comment by Gradle Forums [ 15/Mar/12 ]

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.

Comment by Gradle Forums [ 15/Mar/12 ]

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?

Comment by Gradle Forums [ 15/Mar/12 ]

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.

Comment by Gradle Forums [ 15/Mar/12 ]

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.

Comment by caiweiwei [ 13/Jun/12 ]

This issue still reappear in 1.0-rc3

Comment by Daz DeBoer [ 28/Jun/12 ]

I've confirmed this is an issue: it is caused by the fact that artifacts with classifiers are not available via ModuleDescriptor.getAllArtifacts(), and so we don't expire them from the cache when we expire the module from the cache. See ChangingModuleVersionRepository#expireArtifactsForChangingModule().

Comment by caiweiwei [ 29/Jun/12 ]

Will fix?

Comment by Adam Murdoch [ 03/Jul/12 ]

yes

Comment by caiweiwei [ 22/Jul/12 ]

When?
Or any method we can do about it?
Thank you.

Comment by Adam Murdoch [ 22/Jul/12 ]

I can't give you an accurate answer. It's queued up to be fixed 'soon', probably in the Gradle 1.2 or 1.3 timeframe. The fix won't make it into Gradle 1.1.

Comment by hexucheng [ 17/Sep/16 ]

Is this bug fixed? I am an android application developer and my android studio project use gradle 2.8, this bug is still exist. I upload libary project aar and source jar to nexus maven snapshot repository like this(execute gradle uploadArchives):

apply plugin: 'maven'

version = "x.x.x-SNAPSHOT"

uploadArchives {
repositories {
mavenDeployer {
repository(
url: "http://x.x.x.x:x/nexus/content/repositories/releases/")

{ authentication(userName: nexusUsername, password: nexusPassword) pom.groupId = "xxx.xxx.xxx" pom.artifactId = "xxx" }

snapshotRepository(
url: "http://x.x.x.x:x/nexus/content/repositories/snapshots/")

{ authentication(userName: nexusUsername, password: nexusPassword) pom.groupId = "xxx.xxx.xxx" pom.artifactId = "xxx" }

}
}
}

task sourcesJar(type: Jar)

{ from android.sourceSets.main.java.srcDirs classifier = 'sources' }

artifacts

{ archives sourcesJar }

and declared dependencies in other application project like this:

configurations.all

{ // check for updates every build resolutionStrategy.cacheChangingModulesFor 0, 'seconds' }

dependencies

{ compile group:'xxx.xxx.xxx', name:'xxx', version:'x.x.x-SNAPSHOT', changing:true }

but it will not check and update every build. If only upload libary project aar, it works fine.

Generated at Wed Jun 30 12:14:45 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.