[Gradle] Add dsl marker to KotlinSourceSet
We also need users to distinguish KotlinSourceSet DSL from other levels of DSL, specifically extension one. ^KT-64722 In Progress
This commit is contained in:
committed by
Space Team
parent
e92017f64e
commit
eb663117c7
@@ -431,13 +431,15 @@ kotlin {
|
||||
kotlin.srcDir("${jsDir}/test")
|
||||
}
|
||||
|
||||
val commonMainSourceSet = commonMain.get()
|
||||
val nativeWasmMain by creating {
|
||||
dependsOn(commonMain.get())
|
||||
dependsOn(commonMainSourceSet)
|
||||
kotlin.srcDir("native-wasm/src")
|
||||
}
|
||||
|
||||
val commonTestSourceSet = commonTest.get()
|
||||
val nativeWasmTest by creating {
|
||||
dependsOn(commonTest.get())
|
||||
dependsOn(commonTestSourceSet)
|
||||
kotlin.srcDir("native-wasm/test")
|
||||
}
|
||||
|
||||
@@ -525,7 +527,7 @@ kotlin {
|
||||
|
||||
if (kotlinBuildProperties.isInIdeaSync) {
|
||||
val nativeKotlinTestCommon by creating {
|
||||
dependsOn(commonMain.get())
|
||||
dependsOn(commonMainSourceSet)
|
||||
val prepareKotlinTestCommonNativeSources by tasks.registering(Sync::class) {
|
||||
from("../kotlin.test/common/src/main/kotlin")
|
||||
from("../kotlin.test/annotations-common/src/main/kotlin")
|
||||
|
||||
+2
@@ -8,8 +8,10 @@ package org.jetbrains.kotlin.gradle.plugin
|
||||
import org.gradle.api.Action
|
||||
import org.gradle.api.Named
|
||||
import org.gradle.api.file.SourceDirectorySet
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinGradlePluginDsl
|
||||
import org.jetbrains.kotlin.tooling.core.HasMutableExtras
|
||||
|
||||
@KotlinGradlePluginDsl
|
||||
interface KotlinSourceSet : Named, HasProject, HasMutableExtras, HasKotlinDependencies {
|
||||
val kotlin: SourceDirectorySet
|
||||
|
||||
|
||||
+17
-6
@@ -58,15 +58,25 @@ class MppHighlightingTestDataWithGradleIT : BaseGradleIT() {
|
||||
// create Gradle Kotlin source sets for project roots:
|
||||
val scriptCustomization = buildString {
|
||||
appendLine()
|
||||
appendLine("kotlin {\n sourceSets {")
|
||||
appendLine("kotlin {")
|
||||
appendLine(
|
||||
"""
|
||||
| fun configureTargetsDefaultDependsOn(sourceSet: org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet) {
|
||||
| listOf(${cliCompiler.targets.joinToString { "$it()" }}).forEach {
|
||||
| it.compilations["main"].defaultSourceSet.dependsOn(sourceSet)
|
||||
| }
|
||||
| }
|
||||
|
|
||||
""".trimMargin()
|
||||
)
|
||||
appendLine(" sourceSets {")
|
||||
sourceRoots.forEach { sourceRoot ->
|
||||
if (sourceRoot.kotlinSourceSetName != "commonMain") {
|
||||
appendLine(
|
||||
""" create("${sourceRoot.kotlinSourceSetName}") {
|
||||
"""
|
||||
| create("${sourceRoot.kotlinSourceSetName}") {
|
||||
| dependsOn(getByName("commonMain"))
|
||||
| listOf(${cliCompiler.targets.joinToString { "$it()" }}).forEach {
|
||||
| it.compilations["main"].defaultSourceSet.dependsOn(this@create)
|
||||
| }
|
||||
| configureTargetsDefaultDependsOn(this@create)
|
||||
| }
|
||||
|
|
||||
""".trimMargin()
|
||||
@@ -85,7 +95,8 @@ class MppHighlightingTestDataWithGradleIT : BaseGradleIT() {
|
||||
}
|
||||
}
|
||||
}
|
||||
appendLine(" }\n}")
|
||||
appendLine(" }")
|
||||
appendLine("}")
|
||||
}
|
||||
|
||||
gradleBuildScript().appendText("\n" + scriptCustomization)
|
||||
|
||||
+2
-1
@@ -10,8 +10,9 @@ repositories {
|
||||
}
|
||||
|
||||
kotlin {
|
||||
val commonMainSourceSet = sourceSets.commonMain.get()
|
||||
val nativeMain by sourceSets.creating {
|
||||
dependsOn(sourceSets["commonMain"])
|
||||
dependsOn(commonMainSourceSet)
|
||||
}
|
||||
|
||||
targets.withType(KotlinNativeTarget::class.java).all {
|
||||
|
||||
+2
-1
@@ -10,8 +10,9 @@ repositories {
|
||||
}
|
||||
|
||||
kotlin {
|
||||
val commonMain by sourceSets.getting
|
||||
val nativeMain by sourceSets.creating {
|
||||
dependsOn(sourceSets["commonMain"])
|
||||
dependsOn(commonMain)
|
||||
}
|
||||
|
||||
targets.withType(KotlinNativeTarget::class.java).all {
|
||||
|
||||
+2
-1
@@ -10,8 +10,9 @@ repositories {
|
||||
}
|
||||
|
||||
kotlin {
|
||||
val commonMainSourceSet = sourceSets.commonMain.get()
|
||||
val nativeMain by sourceSets.creating {
|
||||
dependsOn(sourceSets["commonMain"])
|
||||
dependsOn(commonMainSourceSet)
|
||||
}
|
||||
|
||||
targets.withType(KotlinNativeTarget::class.java).all {
|
||||
|
||||
+2
-6
@@ -55,13 +55,9 @@ class KotlinMultiplatformSourceSetConventionsTest {
|
||||
fun `test - invoke - allows creating new source set in closure`() {
|
||||
val project = buildProjectWithMPP()
|
||||
project.multiplatformExtension.apply {
|
||||
val fooSourceSet = sourceSets.create("foo")
|
||||
sourceSets.jvmMain {
|
||||
/*
|
||||
When done wrong, expect:
|
||||
org.gradle.api.internal.AbstractMutationGuard$IllegalMutationException:
|
||||
NamedDomainObjectContainer#create(String) on KotlinSourceSet container cannot be executed in the current context
|
||||
*/
|
||||
dependsOn(sourceSets.create("foo"))
|
||||
dependsOn(fooSourceSet)
|
||||
}
|
||||
|
||||
assertEquals(setOf("foo"), sourceSets.jvmMain.get().dependsOn.map { it.name }.toSet())
|
||||
|
||||
Reference in New Issue
Block a user