[GRADLE-3015] Incorrect artifact file resolved from cache for buildscript classpath Created: 04/Feb/14  Updated: 10/Feb/17  Resolved: 10/Feb/17

Status: Resolved
Project: Gradle
Affects Version/s: None
Fix Version/s: None

Type: Bug
Reporter: Gradle Forums Assignee: Unassigned
Resolution: Won't Fix Votes: 5

Issue Links:
Related
Related to GRADLE-3458 Incorrect artifact file parsed as POM... Resolved

 Description   

The crux of the issue:

[DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleVersionRepository] Found artifact 'org.apache.bcel:bcel:2.1:bcel.jar' in resolver cache: C:\Users\\.gradle\caches\modules-2\files-2.1\com.google.protobuf\protoc\2.5.0\267b2e8ac1b38481e25253da72b4302d10810029\protoc-2.5.0-win32.exe

The original forum issue:
Recently, we had quite some troubles with one of our multi-project builds.

While digging into the problem, it turned out that we do have wrong files on the buildscript classpath.

buildscript {
repositories {
    maven { url repositoryBaseURL + '/repo1' }
    maven { url repositoryBaseURL + '/anotherRepo' }
    mavenLocal()
}
dependencies {
    classpath "org.apache.bcel:bcel:2.1"
    classpath "c.c.t:myPlugin:2.6.2"
}
    println "classpath: " + buildscript.configurations.classpath.files
}
..

The script above leads to the following output:

~/.gradle/caches/artifacts-26/filestore/org.apache.bcel/bcel/2.1/jar/eab80d0721bf3057066e09d80e7fa8069fda9c87/bcel-2.1.jar
~/.gradle/caches/artifacts-26/filestore/c.c.a/c.c.a.anotherProject/0.0.0.20131129-085741.5124/jar/bc24ae0a3181c35ea96c7474f6b67e97dad1036/c.c.a.anotherProject-0.0.0.20131129-085741.5124.jar

"c.c.a.anotherProject-0.0.0.20131129-085741.5124.jar" is on the classpath (and has nothing to do with "myPlugin"), but we never specified this one. Additionally, "myPlugin" is missing completely on the classpath.

After cleaning the gradle cache, the build does not fail any longer and we do get the expected files on buildscript classpath. (Note: we are using gradle 1.8)



 Comments   
Comment by Gradle Forums [ 04/Feb/14 ]

... happened once again (using gradle 1.9 now). This time the other dependency specified in the buildscript section was missing on the actual buildscript classpath.

Comment by Gradle Forums [ 04/Feb/14 ]

Hard to say why this would happen. Perhaps "myPlugin" changed without having its version number bumped. One thing I'd try to get rid of is "mavenLocal". Including this means that every developer's search path will be different, leading to less consistent build results.

Comment by Gradle Forums [ 04/Feb/14 ]

We already got rid of "mavenLocal" right after this problem appeared for the very first time.
@your first thought: I'm pretty sure that we pumped the version of the plugin mentioned right before publishing it. Anyway, this time it happened without having a change at all in the buildscript section for a week.

Comment by Gradle Forums [ 04/Feb/14 ]

Strange. It's not something I've heard of before. If you find out more, let us know.

Comment by Gradle Forums [ 04/Feb/14 ]

.. happened again (bcel was replaced by protoc on buildscript classpath).
Sadly, I'm still not able to provide an example which shows up the actual problem. But maybe the debug log might give you some hint:

I'm wondering about this line which in fact indicates our problem:
[DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleVersionRepository] Found artifact 'org.apache.bcel:bcel:2.1:bcel.jar' in resolver cache: C:\Users\\.gradle\caches\modules-2\files-2.1\com.google.protobuf\protoc\2.5.0\267b2e8ac1b38481e25253da72b4302d10810029\protoc-2.5.0-win32.exe

[DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder] Visiting configuration org.apache.bcel:bcel:2.1(default).
[DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder] Visiting configuration c.c.t:myPlugin:2.6.2(default).
[DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder] Attaching :building:unspecified(classpath) to its parents.
[DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder] Attaching org.apache.bcel:bcel:2.1(default) to its parents.
[DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder] Attaching c.c.t:myPlugin:2.6.2(default) to its parents.
[DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.oldresult.TransientConfigurationResultsBuilder] Flushing resolved configuration data in Binary store in C:\Users\\AppData\Local\Temp\gradle282855522417523883.bin. Wrote root :building:unspecified:classpath.
[DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Opening cache artifact-at-repository.bin (C:\Users\\.gradle\caches\modules-2\metadata-2.1\artifact-at-repository.bin)
[DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleVersionRepository] Found artifact 'org.apache.bcel:bcel:2.1:bcel.jar' in resolver cache: C:\Users\\.gradle\caches\modules-2\files-2.1\com.google.protobuf\protoc\2.5.0\267b2e8ac1b38481e25253da72b4302d10810029\protoc-2.5.0-win32.exe
[DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleVersionRepository] Found artifact 'c.c.t:myPlugin:2.6.2:myPlugin.jar' in resolver cache: C:\Users\\.gradle\caches\modules-2\files-2.1\c.c.t\myPlugin\2.6.2\986b8fd00dac9fcf6c93543eea9f783bdc0a6f18\myPlugin-2.6.2.jar
[QUIET] [system.out] classpath: [C:\Users\\.gradle\caches\modules-2\files-2.1\com.google.protobuf\protoc\2.5.0\267b2e8ac1b38481e25253da72b4302d10810029\protoc-2.5.0-win32.exe, C:\Users\\.gradle\caches\modules-2\files-2.1\c.c.t\myPlugin\2.6.2\986b8fd00dac9fcf6c93543eea9f783bdc0a6f18\myPlugin-2.6.2.jar]
[DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire shared lock on no_buildscript class cache for build file 'C:\\building\build.gradle' (C:\Users\\.gradle\caches\1.9\scripts\build_7jvf0l4e7uv842s9f9rj8qvpuc\ProjectScript\no_buildscript).
[DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired.

Comment by Erhard Pointl [ 13/Feb/14 ]

Today this problem popped up once more, but for the very first time not within the buildscript section. But in an external dependency of a dependency configuration.

10:48:02.265 [DEBUG] [org.apache.http.headers] >> HEAD /artifactory/<repo>/c/c/a/testapps/dnw/c.c.a.testapps.dnw.dnw/0.0.1.17/c.c.a.testapps.dnw.dnw-0.0.1.17.zip HTTP/1.1
10:48:02.265 [DEBUG] [org.apache.http.headers] >> Accept-Encoding: gzip,deflate
10:48:02.266 [DEBUG] [org.apache.http.headers] >> Host: <artifactoryHost>
10:48:02.266 [DEBUG] [org.apache.http.headers] >> Connection: Keep-Alive
10:48:02.266 [DEBUG] [org.apache.http.headers] >> User-Agent: Gradle/1.9 (Windows 7;6.1;amd64) (Oracle Corporation;1.7.0_25;23.25-b01)
10:48:02.312 [DEBUG] [org.apache.http.impl.conn.DefaultClientConnection] Receiving response: HTTP/1.1 200 OK
10:48:02.312 [DEBUG] [org.apache.http.headers] << HTTP/1.1 200 OK
10:48:02.312 [DEBUG] [org.apache.http.headers] << Date: Thu, 13 Feb 2014 09:47:54 GMT
10:48:02.312 [DEBUG] [org.apache.http.headers] << Server: Artifactory/3.0.4
10:48:02.313 [DEBUG] [org.apache.http.headers] << Last-Modified: Wed, 12 Feb 2014 08:14:28 GMT
10:48:02.313 [DEBUG] [org.apache.http.headers] << ETag: f278d7e1d1e02fe99e3d1818f67934b77d57a78b
10:48:02.313 [DEBUG] [org.apache.http.headers] << X-Checksum-Sha1: f278d7e1d1e02fe99e3d1818f67934b77d57a78b
10:48:02.313 [DEBUG] [org.apache.http.headers] << X-Checksum-Md5: 7a36df31c1d020194893a0cf419d8c11
10:48:02.314 [DEBUG] [org.apache.http.headers] << Content-Disposition: attachment; filename=c.c.a.testapps.dnw.dnw-0.0.1.17.zip
10:48:02.314 [DEBUG] [org.apache.http.headers] << X-Artifactory-Filename: c.c.a.testapps.dnw.dnw-0.0.1.17.zip
10:48:02.314 [DEBUG] [org.apache.http.headers] << Content-Type: application/zip
10:48:02.314 [DEBUG] [org.apache.http.headers] << Content-Length: 16566195
10:48:02.315 [DEBUG] [org.apache.http.headers] << Keep-Alive: timeout=5, max=98
10:48:02.315 [DEBUG] [org.apache.http.headers] << Connection: Keep-Alive
10:48:02.315 [DEBUG] [org.apache.http.impl.client.SystemDefaultHttpClient] Connection can be kept alive for 5000 MILLISECONDS
10:48:02.315 [DEBUG] [org.apache.http.impl.conn.PoolingClientConnectionManager] Connection [id: 1][route: {}->http://<artifactoryHost>] can be kept alive for 5000 MILLISECONDS
10:48:02.316 [DEBUG] [org.apache.http.impl.conn.PoolingClientConnectionManager] Connection released: [id: 1][route: {}->http://<artifactoryHost>][total kept alive: 1; route allocated: 1 of 5; total allocated: 1 of 10]
10:48:02.316 [DEBUG] [org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceResolver] Ivy file found for module 'c.c.a.testapps.dnw#c.c.a.testapps.dnw.dnw;0.0.1.+' in repository 'maven4'.
10:48:02.317 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.dynamicversions.SingleFileBackedModuleResolutionCache] Caching resolved revision in dynamic revision cache: Will use 'c.c.a.testapps.dnw:c.c.a.testapps.dnw.dnw:0.0.1.17' for 'c.c.a.testapps.dnw:c.c.a.testapps.dnw.dnw:0.0.1.+'
10:48:02.317 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.modulecache.DefaultModuleMetaDataCache] Recording module descriptor in cache: c.c.a.testapps.dnw#c.c.a.testapps.dnw.dnw;0.0.1.17 [changing = false]
10:48:02.320 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleVersionRepository] Detected non-existence of module 'c.c.a.testapps.dnw#c.c.a.testapps.dnw.dnw;0.0.1.+' in resolver cache 'maven5'
10:48:02.320 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.UserResolverChain] Using module 'c.c.a.testapps.dnw:c.c.a.testapps.dnw.dnw:0.0.1.17' from repository 'maven2'
10:48:02.321 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder] Selecting new module version c.c.a.testapps.dnw:c.c.a.testapps.dnw.dnw:0.0.1.17
10:48:02.321 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder] Visiting configuration c.c.a.testapps.dnw:c.c.a.testapps.dnw.dnw:0.0.1.17(default).
10:48:02.321 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder] Attaching c.c.a:c.c.a.b.f:unspecified(dnw) to its parents.
10:48:02.321 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder] Attaching c.c.a.testapps.dnw:c.c.a.testapps.dnw.dnw:0.0.1.17(default) to its parents.
10:48:02.322 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.oldresult.TransientConfigurationResultsBuilder] Flushing resolved configuration data in Binary store in C:\Users\<USER_NAME>\AppData\Local\Temp\gradle6183270639864618304.bin. Wrote root c.c.a:c.c.a.b.f:unspecified:dnw.
10:48:02.323 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleVersionRepository] Found artifact 'c.c.a.testapps.dnw:c.c.a.testapps.dnw.dnw:0.0.1.17:c.c.a.testapps.dnw.dnw.zip' in resolver cache: C:\Users\<USER_NAME>\.gradle\caches\modules-2\files-2.1\org.apache.cassandra\cassandra-parent\1.2.11\22ad5bb47f2c389a2b36b4019914cdb6d507d85a\cassandra-parent-1.2.11.pom.

Comment by Brian McDonald [ 13/Mar/15 ]

I think we are seeing the same issue using 2.2.1 and it may be linked to using --refresh-dependencies

Here's a simple java project with one dependency

compile - Compile classpath for source set 'main'.
--- org.slf4j:slf4j-api:1.7.7

but the classpath is

/home/cruisecontrol/.gradle/caches/modules-2/files-2.1/org.apache/apache/7/6ebc3957064d9ca9d75431eb37ff40b380e64103/apache-7.pom

If I delete the cache and rerun it the classpath correctly point to the slf4j-api-1.7.7.jar in the cache. We're still trying to track down the trigger, but knowing more about how the cache goes from the dependency to the file would help. Is there a metadata map being used (so it's possible to go from one group:module:version to a totally different file? If so, how can that be incorrectly updated or corrupted?

Comment by Benjamin Muschko [ 15/Nov/16 ]

As announced on the Gradle blog we are planning to completely migrate issues from JIRA to GitHub.

We intend to prioritize issues that are actionable and impactful while working more closely with the community. Many of our JIRA issues are inactionable or irrelevant. We would like to request your help to ensure we can appropriately prioritize JIRA issues you’ve contributed to.

Please confirm that you still advocate for your JIRA issue before December 10th, 2016 by:

  • Checking that your issues contain requisite context, impact, behaviors, and examples as described in our published guidelines.
  • Leave a comment on the JIRA issue or open a new GitHub issue confirming that the above is complete.

We look forward to collaborating with you more closely on GitHub. Thank you for your contribution to Gradle!

Comment by Benjamin Muschko [ 10/Feb/17 ]

Thanks again for reporting this issue. We haven't heard back from you after our inquiry from November 15th. We are closing this issue now. Please create an issue on GitHub if you still feel passionate about getting it resolved.

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