Add lambda configurable languageSettings function in KotlinSourceSet
Function with Groovy Closure is already exists, it provides DSL parity #KT-44834 Fixed
This commit is contained in:
+1
@@ -16,6 +16,7 @@ interface KotlinSourceSet : Named, HasKotlinDependencies {
|
||||
val resources: SourceDirectorySet
|
||||
|
||||
val languageSettings: LanguageSettingsBuilder
|
||||
fun languageSettings(configure: LanguageSettingsBuilder.() -> Unit): LanguageSettingsBuilder
|
||||
fun languageSettings(configureClosure: Closure<Any?>): LanguageSettingsBuilder
|
||||
|
||||
fun dependsOn(other: KotlinSourceSet)
|
||||
|
||||
+22
@@ -692,6 +692,28 @@ class NewMultiplatformIT : BaseGradleIT() {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testLanguageSettingsClosureForKotlinDsl() = with(transformNativeTestProjectWithPluginDsl("sample-lib-gradle-kotlin-dsl", gradleVersion, "new-mpp-lib-and-app")) {
|
||||
gradleBuildScript().appendText(
|
||||
"\n" + """
|
||||
kotlin.sourceSets.all {
|
||||
languageSettings {
|
||||
languageVersion = "1.3"
|
||||
apiVersion = "1.3"
|
||||
}
|
||||
}
|
||||
""".trimIndent()
|
||||
)
|
||||
|
||||
listOf("compileKotlinMetadata", "compileKotlinJvm6", "compileKotlinNodeJs").forEach {
|
||||
build(it) {
|
||||
assertSuccessful()
|
||||
assertTasksExecuted(":$it")
|
||||
assertContains("-language-version 1.3", "-api-version 1.3")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testLanguageSettingsApplied() = with(transformNativeTestProject("sample-lib", gradleVersion, "new-mpp-lib-and-app")) {
|
||||
gradleBuildScript().appendText(
|
||||
|
||||
+3
@@ -71,6 +71,9 @@ class DefaultKotlinSourceSet(
|
||||
ConfigureUtil.configure(configureClosure, this)
|
||||
}
|
||||
|
||||
override fun languageSettings(configure: LanguageSettingsBuilder.() -> Unit): LanguageSettingsBuilder =
|
||||
languageSettings.apply { configure(this) }
|
||||
|
||||
override fun getName(): String = displayName
|
||||
|
||||
override fun dependencies(configure: KotlinDependencyHandler.() -> Unit): Unit =
|
||||
|
||||
+1
@@ -253,6 +253,7 @@ class MockKotlinSourceSet(private val name: String) : KotlinSourceSet {
|
||||
override val resources: SourceDirectorySet get() = throw UnsupportedOperationException()
|
||||
override val languageSettings: LanguageSettingsBuilder get() = throw UnsupportedOperationException()
|
||||
override fun languageSettings(configureClosure: Closure<Any?>): LanguageSettingsBuilder = languageSettings
|
||||
override fun languageSettings(configure: LanguageSettingsBuilder.() -> Unit): LanguageSettingsBuilder = languageSettings
|
||||
override val apiMetadataConfigurationName: String get() = throw UnsupportedOperationException()
|
||||
override val implementationMetadataConfigurationName: String get() = throw UnsupportedOperationException()
|
||||
override val compileOnlyMetadataConfigurationName: String get() = throw UnsupportedOperationException()
|
||||
|
||||
Reference in New Issue
Block a user