[Gradle] Fix tests for Gradle 8.2 compatibility

* Dependency scope configurations can't have attributes
* ConfigurationInternal.path is removed

^KT-60879
This commit is contained in:
Anton Lakotka
2023-11-10 12:55:34 +01:00
parent 2ab30d8880
commit 5d46e45da7
2 changed files with 15 additions and 11 deletions
@@ -85,16 +85,17 @@ private fun generateResolveAllConfigurationsTask(excludes: List<String>) =
.matching { !excludeConfigs.contains(it.name) } .matching { !excludeConfigs.contains(it.name) }
.each { configuration -> .each { configuration ->
try { try {
println "Resolving " + configuration.path def configurationPath = (project.path == ":") ? ":" + configuration.name : project.path + ":" + configuration.name
configuration.files.each { println '>> ' + configuration.path + ' --> ' + it.name } println "Resolving " + configurationPath
println "OK, resolved " + configuration.path + "\n" configuration.files.each { println '>> ' + configurationPath + ' --> ' + it.name }
println "OK, resolved " + configurationPath + "\n"
} catch (e) { } catch (e) {
def ex = e def ex = e
while (ex != null) { while (ex != null) {
println ex.message println ex.message
ex = ex.cause ex = ex.cause
} }
println '$UNRESOLVED_MARKER' + configuration.name + "\n" println '$UNRESOLVED_MARKER' + configurationPath + "\n"
} }
} }
} }
@@ -115,24 +116,25 @@ private fun generateResolveAllConfigurationsTaskKts(excludes: List<String>) =
.filter { it.isCanBeResolved } .filter { it.isCanBeResolved }
.filterNot { excludeConfigs.contains(it.name) } .filterNot { excludeConfigs.contains(it.name) }
.forEach { configuration -> .forEach { configuration ->
val path = (configuration as org.gradle.api.internal.artifacts.configurations.ConfigurationInternal).path val configurationPath =
if (project.path == ":") ":" + configuration.name
else project.path + ":" + configuration.name
try { try {
println("Resolving ${'$'}path") println("Resolving ${'$'}configurationPath")
configuration.files.forEach { println(">> ${'$'}path --> ${'$'}{it.name}") } configuration.files.forEach { println(">> ${'$'}configurationPath --> ${'$'}{it.name}") }
println("OK, resolved ${'$'}path\n") println("OK, resolved ${'$'}configurationPath\n")
} catch (e: Throwable) { } catch (e: Throwable) {
var ex = e as Throwable? var ex = e as Throwable?
while (ex != null) { while (ex != null) {
println(ex.message) println(ex.message)
ex = ex.cause ex = ex.cause
} }
println("$UNRESOLVED_MARKER ${'$'}{configuration.name}\n") println("$UNRESOLVED_MARKER ${'$'}configurationPath\n")
} }
} }
} }
} }
""".trimIndent() """.trimIndent()
private fun computeExcludeConfigurations(excludes: List<String>): String { private fun computeExcludeConfigurations(excludes: List<String>): String {
val deprecatedConfigurations = listOf("compile", "runtime", "compileOnly", "runtimeOnly") val deprecatedConfigurations = listOf("compile", "runtime", "compileOnly", "runtimeOnly")
return """ return """
@@ -34,5 +34,7 @@ publishing {
def complexLibAttribute = Attribute.of('org.jetbrains.qa.complexlib', String) def complexLibAttribute = Attribute.of('org.jetbrains.qa.complexlib', String)
configurations.all { configurations.all {
attributes { attribute(complexLibAttribute, 'jvmWithJava') } if (isCanBeResolved()) {
attributes { attribute(complexLibAttribute, 'jvmWithJava') }
}
} }