[Gradle] Prevent early resolve of compiler classpath
#KT-45834 Fixed
This commit is contained in:
+6
-1
@@ -248,7 +248,8 @@ abstract class BaseGradleIT {
|
||||
val configurationCacheProblems: ConfigurationCacheProblems = ConfigurationCacheProblems.FAIL,
|
||||
val warningMode: WarningMode = WarningMode.Fail,
|
||||
val useFir: Boolean = false,
|
||||
val customEnvironmentVariables: Map<String, String> = mapOf()
|
||||
val customEnvironmentVariables: Map<String, String> = mapOf(),
|
||||
val dryRun: Boolean = false,
|
||||
)
|
||||
|
||||
enum class ConfigurationCacheProblems {
|
||||
@@ -939,6 +940,10 @@ Finished executing task ':$taskName'|
|
||||
add("-Pkotlin.useFir=true")
|
||||
}
|
||||
|
||||
if (options.dryRun) {
|
||||
add("--dry-run")
|
||||
}
|
||||
|
||||
add("-Dorg.gradle.unsafe.configuration-cache=${options.configurationCache}")
|
||||
add("-Dorg.gradle.unsafe.configuration-cache-problems=${options.configurationCacheProblems.name.toLowerCase()}")
|
||||
|
||||
|
||||
+41
@@ -1240,4 +1240,45 @@ class KotlinGradleIT : BaseGradleIT() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testEarlyConfigurationsResolutionKotlin() = testEarlyConfigurationsResolution("kotlinProject", kts = false)
|
||||
|
||||
@Test
|
||||
fun testEarlyConfigurationsResolutionKotlinJs() = testEarlyConfigurationsResolution("kotlin-js-browser-project", kts = true)
|
||||
|
||||
private fun testEarlyConfigurationsResolution(projectName: String, kts: Boolean) = with(Project(projectName = projectName)) {
|
||||
setupWorkingDir()
|
||||
gradleBuildScript().modify(::transformBuildScriptWithPluginsDsl)
|
||||
//language=Gradle
|
||||
gradleBuildScript().appendText(
|
||||
"""${'\n'}
|
||||
// KT-45834 start
|
||||
${if (kts) "var" else "def"} ready = false
|
||||
gradle.taskGraph.whenReady {
|
||||
println("Task Graph Ready")
|
||||
ready = true
|
||||
}
|
||||
|
||||
allprojects {
|
||||
configurations.forEach { configuration ->
|
||||
configuration.incoming.beforeResolve {
|
||||
println("Resolving ${'$'}configuration")
|
||||
if (!ready) {
|
||||
throw ${if (kts) "" else "new"} GradleException("${'$'}configuration is being resolved at configuration time")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// KT-45834 end
|
||||
""".trimIndent()
|
||||
)
|
||||
|
||||
build(
|
||||
"assemble",
|
||||
options = defaultBuildOptions().copy(dryRun = true)
|
||||
) {
|
||||
assertSuccessful()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -79,7 +79,7 @@ class UpToDateIT : BaseGradleIT() {
|
||||
|
||||
override fun initProject(project: Project) = with(project) {
|
||||
buildGradle.appendText(
|
||||
"\nafterEvaluate { println 'compiler_cp=' + compileKotlin.getComputedCompilerClasspath\$kotlin_gradle_plugin() }"
|
||||
"\nafterEvaluate { println 'compiler_cp=' + compileKotlin.getComputedCompilerClasspath\$kotlin_gradle_plugin().toList() }"
|
||||
)
|
||||
build("clean") { originalCompilerCp = "compiler_cp=\\[(.*)]".toRegex().find(output)!!.groupValues[1].split(", ") }
|
||||
buildGradle.appendText("""${'\n'}
|
||||
|
||||
Reference in New Issue
Block a user