From 2e6a5238234e1dcd1c94c0096532fea6c763f443 Mon Sep 17 00:00:00 2001 From: Alex Semin Date: Mon, 27 Nov 2023 14:45:46 +0100 Subject: [PATCH 1/2] Avoid capturing project in configure action --- .../precompiled/DefaultPrecompiledScriptPluginsSupport.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/platforms/core-configuration/kotlin-dsl-provider-plugins/src/main/kotlin/org/gradle/kotlin/dsl/provider/plugins/precompiled/DefaultPrecompiledScriptPluginsSupport.kt b/platforms/core-configuration/kotlin-dsl-provider-plugins/src/main/kotlin/org/gradle/kotlin/dsl/provider/plugins/precompiled/DefaultPrecompiledScriptPluginsSupport.kt index 748c67b55425..341d5c20597a 100644 --- a/platforms/core-configuration/kotlin-dsl-provider-plugins/src/main/kotlin/org/gradle/kotlin/dsl/provider/plugins/precompiled/DefaultPrecompiledScriptPluginsSupport.kt +++ b/platforms/core-configuration/kotlin-dsl-provider-plugins/src/main/kotlin/org/gradle/kotlin/dsl/provider/plugins/precompiled/DefaultPrecompiledScriptPluginsSupport.kt @@ -266,6 +266,7 @@ fun Project.enableScriptCompilationOf( dependsOn(generatePrecompiledScriptPluginAccessors) metadataDir.set(accessorsMetadata) classPathFiles.from(compileClasspath) + val objects = objects onConfigure { resolverEnvironment -> configureKotlinCompilerArguments(objects, resolverEnvironment) } From 88c2174e08626c0b0ac194f7005af970f77c442a Mon Sep 17 00:00:00 2001 From: Alex Semin Date: Mon, 27 Nov 2023 10:28:50 +0100 Subject: [PATCH 2/2] Make fixture Isolated Projects compatible --- .../KotlinDslTestProjectInitiation.groovy | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/subprojects/internal-integ-testing/src/main/groovy/org/gradle/integtests/fixtures/build/KotlinDslTestProjectInitiation.groovy b/subprojects/internal-integ-testing/src/main/groovy/org/gradle/integtests/fixtures/build/KotlinDslTestProjectInitiation.groovy index f388a775a64b..4fb0e6ad722b 100644 --- a/subprojects/internal-integ-testing/src/main/groovy/org/gradle/integtests/fixtures/build/KotlinDslTestProjectInitiation.groovy +++ b/subprojects/internal-integ-testing/src/main/groovy/org/gradle/integtests/fixtures/build/KotlinDslTestProjectInitiation.groovy @@ -209,33 +209,34 @@ trait KotlinDslTestProjectInitiation { withDefaultSettingsIn("buildSrc").append(""" include(":a", ":b", ":c") """) - withFile("buildSrc/$defaultBuildKotlinFileName", """ + + withBuildScriptIn("buildSrc", """ plugins { java `kotlin-dsl` apply false } - val kotlinDslProjects = listOf(project.project(":a"), project.project(":b")) - - kotlinDslProjects.forEach { - it.apply(plugin = "org.gradle.kotlin.kotlin-dsl") - } - dependencies { - kotlinDslProjects.forEach { - "runtimeOnly"(project(it.path)) - } + "runtimeOnly"(project(":a")) + "runtimeOnly"(project(":b")) } """) - withFile("buildSrc/a/$defaultBuildKotlinFileName", """ + // Duplication in build scripts to avoid Isolated Projects violations without introducing shared build logic + withBuildScriptIn("buildSrc/a", """ + plugins { + id("org.gradle.kotlin.kotlin-dsl") + } $repositoriesBlock """) - withFile("buildSrc/b/$defaultBuildKotlinFileName", """ + withBuildScriptIn("buildSrc/b", """ + plugins { + id("org.gradle.kotlin.kotlin-dsl") + } $repositoriesBlock dependencies { implementation(project(":c")) } """) - withFile("buildSrc/c/$defaultBuildKotlinFileName", """ + withBuildScriptIn("buildSrc/c", """ plugins { java } $repositoriesBlock """)