mirror of
https://github.com/tadfisher/gradle2nix.git
synced 2026-01-11 15:30:38 -05:00
Ignore Gradle cache when hashing metadata artifacts
This commit is contained in:
@@ -11,7 +11,7 @@ io.github.classgraph:classgraph:4.8.37=testRuntimeClasspath
|
||||
io.strikt:strikt-core:0.28.0=testCompileClasspath,testRuntimeClasspath
|
||||
net.swiftzer.semver:semver:1.1.1=runtimeClasspath,testRuntimeClasspath
|
||||
org.apiguardian:apiguardian-api:1.1.0=testRuntimeClasspath
|
||||
org.gradle:gradle-tooling-api:6.8-milestone-2=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.gradle:gradle-tooling-api:6.8-milestone-3=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.jetbrains.kotlin:kotlin-reflect:1.4.10=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.jetbrains.kotlin:kotlin-stdlib-common:1.4.10=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.10=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
|
||||
@@ -2554,46 +2554,46 @@
|
||||
"id": {
|
||||
"group": "org.gradle",
|
||||
"name": "gradle-tooling-api",
|
||||
"version": "6.8-milestone-2",
|
||||
"version": "6.8-milestone-3",
|
||||
"type": "jar",
|
||||
"extension": "jar"
|
||||
},
|
||||
"name": "gradle-tooling-api-6.8-milestone-2.jar",
|
||||
"path": "org/gradle/gradle-tooling-api/6.8-milestone-2",
|
||||
"name": "gradle-tooling-api-6.8-milestone-3.jar",
|
||||
"path": "org/gradle/gradle-tooling-api/6.8-milestone-3",
|
||||
"urls": [
|
||||
"https://repo.gradle.org/gradle/libs-releases/org/gradle/gradle-tooling-api/6.8-milestone-2/gradle-tooling-api-6.8-milestone-2.jar"
|
||||
"https://repo.gradle.org/gradle/libs-releases/org/gradle/gradle-tooling-api/6.8-milestone-3/gradle-tooling-api-6.8-milestone-3.jar"
|
||||
],
|
||||
"sha256": "3aec6cf21e2859bb9ad3c121446f2124633b8ecad6d757c6e03d82483019787d"
|
||||
"sha256": "30794f0bfaa1f8f02e623817f7a0464cb66100d3f4f387de0bd3b56c4fc8a2a0"
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"group": "org.gradle",
|
||||
"name": "gradle-tooling-api",
|
||||
"version": "6.8-milestone-2",
|
||||
"version": "6.8-milestone-3",
|
||||
"type": "module",
|
||||
"extension": "module"
|
||||
},
|
||||
"name": "gradle-tooling-api-6.8-milestone-2.module",
|
||||
"path": "org/gradle/gradle-tooling-api/6.8-milestone-2",
|
||||
"name": "gradle-tooling-api-6.8-milestone-3.module",
|
||||
"path": "org/gradle/gradle-tooling-api/6.8-milestone-3",
|
||||
"urls": [
|
||||
"https://repo.gradle.org/gradle/libs-releases/org/gradle/gradle-tooling-api/6.8-milestone-2/gradle-tooling-api-6.8-milestone-2.module"
|
||||
"https://repo.gradle.org/gradle/libs-releases/org/gradle/gradle-tooling-api/6.8-milestone-3/gradle-tooling-api-6.8-milestone-3.module"
|
||||
],
|
||||
"sha256": "13f2309ed1d7572a9f270444b966e41e37ea447c725239f131312f6e7556eecd"
|
||||
"sha256": "66ef5b94e7edd271a263aeb05ceebe8acc768f8bbbfb29aff20905b5422d7963"
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"group": "org.gradle",
|
||||
"name": "gradle-tooling-api",
|
||||
"version": "6.8-milestone-2",
|
||||
"version": "6.8-milestone-3",
|
||||
"type": "pom",
|
||||
"extension": "pom"
|
||||
},
|
||||
"name": "gradle-tooling-api-6.8-milestone-2.pom",
|
||||
"path": "org/gradle/gradle-tooling-api/6.8-milestone-2",
|
||||
"name": "gradle-tooling-api-6.8-milestone-3.pom",
|
||||
"path": "org/gradle/gradle-tooling-api/6.8-milestone-3",
|
||||
"urls": [
|
||||
"https://repo.gradle.org/gradle/libs-releases/org/gradle/gradle-tooling-api/6.8-milestone-2/gradle-tooling-api-6.8-milestone-2.pom"
|
||||
"https://repo.gradle.org/gradle/libs-releases/org/gradle/gradle-tooling-api/6.8-milestone-3/gradle-tooling-api-6.8-milestone-3.pom"
|
||||
],
|
||||
"sha256": "13d0746b71f0dfe7380d913f0a4344ca16731d9d5c1cb5e338e8d9cae52c908e"
|
||||
"sha256": "f1c439e4229548ced7d464cb7b3984a7af91ed16be340d1b959d4fd2c1e82504"
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
@@ -3729,7 +3729,7 @@
|
||||
"https://jcenter.bintray.com/javax/servlet/javax.servlet-api/3.1.0/javax.servlet-api-3.1.0.pom",
|
||||
"https://repo.gradle.org/gradle/libs-releases/javax/servlet/javax.servlet-api/3.1.0/javax.servlet-api-3.1.0.pom"
|
||||
],
|
||||
"sha256": "b31109e22ea3f2df1ad7955432e718a35def50ae6c19698034afa8a0cf9e9069"
|
||||
"sha256": "6fad2ae0a3a00c145ba5774d67196678291cc200bd09bd0626ef11ff20b4dc1a"
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
|
||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-milestone-2-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-milestone-3-all.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
@@ -30,7 +30,7 @@ org.eclipse.jetty:jetty-servlet:9.4.31.v20200723=compatTestCompileClasspath,comp
|
||||
org.eclipse.jetty:jetty-util:9.4.31.v20200723=compatTestCompileClasspath,compatTestImplementationDependenciesMetadata,compatTestRuntimeClasspath
|
||||
org.eclipse.jetty:jetty-webapp:9.4.31.v20200723=compatTestCompileClasspath,compatTestImplementationDependenciesMetadata,compatTestRuntimeClasspath
|
||||
org.eclipse.jetty:jetty-xml:9.4.31.v20200723=compatTestCompileClasspath,compatTestImplementationDependenciesMetadata,compatTestRuntimeClasspath
|
||||
org.gradle:gradle-tooling-api:6.8-milestone-2=compileClasspath,compileOnly,compileOnlyDependenciesMetadata
|
||||
org.gradle:gradle-tooling-api:6.8-milestone-3=compileClasspath,compileOnly,compileOnlyDependenciesMetadata
|
||||
org.jetbrains.intellij.deps:trove4j:1.0.20181211=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
|
||||
org.jetbrains.kotlin:kotlin-compiler-embeddable:1.4.10=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
|
||||
org.jetbrains.kotlin:kotlin-daemon-embeddable:1.4.10=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
|
||||
|
||||
@@ -38,7 +38,9 @@ internal class ConfigurationResolverFactory(
|
||||
) {
|
||||
private val ivySettings = IvySettings().apply {
|
||||
defaultInit()
|
||||
defaultRepositoryCacheManager = null
|
||||
// This doesn't appear to be used, but it's better to define it explicitly than to introduce
|
||||
// impurities into artifact resolution.
|
||||
setDefaultRepositoryCacheBasedir(project.buildDir.resolve("tmp/gradle2nix/_cache").absolutePath)
|
||||
setDictatorResolver(ChainResolver().also { chain ->
|
||||
chain.settings = this@apply
|
||||
for (resolver in resolvers) chain.add(resolver)
|
||||
@@ -98,7 +100,7 @@ internal class ConfigurationResolver(
|
||||
classifier = resolvedArtifact.classifier
|
||||
)
|
||||
|
||||
val sha256 = resolvedArtifact.file.sha256()
|
||||
val sha256 = resolvedArtifact.computeHash()
|
||||
val artifacts = resolvers.mapNotNull { it.resolve(artifactId, sha256) }.merge()
|
||||
if (artifacts.isEmpty()) failed.add(artifactId)
|
||||
return artifacts + componentId.run { resolveMetadata(group, module, version) }
|
||||
@@ -135,8 +137,8 @@ internal class ConfigurationResolver(
|
||||
version = componentId.version,
|
||||
type = "pom"
|
||||
)
|
||||
val sha256 = resolvedPom.file.sha256()
|
||||
val artifacts = resolvers.mapNotNull { it.resolve(artifactId, sha256) }.merge()
|
||||
// Intentionally not computing hash from the cached result; see ResolvedArtifact.computeHash() below.
|
||||
val artifacts = resolvers.mapNotNull { it.resolve(artifactId) }.merge()
|
||||
if (artifacts.isEmpty()) failed.add(artifactId)
|
||||
artifacts
|
||||
}
|
||||
@@ -164,8 +166,8 @@ internal class ConfigurationResolver(
|
||||
type = "ivy",
|
||||
extension = "xml"
|
||||
)
|
||||
val sha256 = resolvedDesc.file.sha256()
|
||||
val artifacts = resolvers.mapNotNull { it.resolve(artifactId, sha256) }.merge()
|
||||
// Intentionally not computing hash from the cached result; see ResolvedArtifact.computeHash() below.
|
||||
val artifacts = resolvers.mapNotNull { it.resolve(artifactId) }.merge()
|
||||
if (artifacts.isEmpty()) failed.add(artifactId)
|
||||
artifacts
|
||||
}
|
||||
@@ -283,4 +285,19 @@ private fun List<DefaultArtifact>.merge(): List<DefaultArtifact> {
|
||||
return groupingBy { it.id }
|
||||
.reduce { _, dest, next -> dest.copy(urls = dest.urls + next.urls) }
|
||||
.values.toList()
|
||||
}
|
||||
|
||||
private fun ResolvedArtifact.computeHash(): String? {
|
||||
// Hack: Some POM files are served with CRLF line endings, e.g. javax.servlet:javax.servlet-api:3.1.0.
|
||||
// Gradle stores these normalized with LF line endings, which will not match the eventual hash
|
||||
// of the fixed-output derivation which produces the POM artifact.
|
||||
//
|
||||
// A similar issue can exist for Apache Ivy; see https://issues.apache.org/jira/browse/IVY-1156.
|
||||
//
|
||||
// Ignore these artifacts, and defer hash calculation to RepositoryResolver.
|
||||
if (type == "pom" || type == "ivy") {
|
||||
return null
|
||||
}
|
||||
|
||||
return file.sha256()
|
||||
}
|
||||
Reference in New Issue
Block a user