Skip to content

Commit c645f52

Browse files
authored
Restructure source-sets-conventions.gradle.kts
so it applies overridenLanugageVersion to all source sets using the new compilerOptions DSL. (#2891) Previously, only leaf source sets were affected because the language version was applied to the KotlinCompilationTask configuration.
1 parent fa797bc commit c645f52

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

buildSrc/src/main/kotlin/source-sets-conventions.gradle.kts

+16-11
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,24 @@ kotlin {
6464
sourceSets.all {
6565
kotlin.srcDirs("$name/src")
6666
resources.srcDirs("$name/resources")
67-
languageSettings {
68-
progressiveMode = true
67+
}
6968

70-
optIn("kotlin.ExperimentalMultiplatform")
71-
optIn("kotlin.ExperimentalSubclassOptIn")
72-
optIn("kotlinx.serialization.InternalSerializationApi")
73-
optIn("kotlinx.serialization.SealedSerializationApi")
69+
compilerOptions {
70+
// These configuration replaces 'languageSettings' config on line 67
71+
progressiveMode.set(true)
72+
optIn.addAll(
73+
listOf(
74+
"kotlin.ExperimentalMultiplatform",
75+
"kotlin.ExperimentalSubclassOptIn",
76+
"kotlinx.serialization.InternalSerializationApi",
77+
"kotlinx.serialization.SealedSerializationApi",
78+
)
79+
)
80+
if (overriddenLanguageVersion != null) {
81+
languageVersion = KotlinVersion.fromVersion(overriddenLanguageVersion!!)
82+
freeCompilerArgs.add("-Xsuppress-version-warnings")
7483
}
84+
freeCompilerArgs.add("-Xexpect-actual-classes")
7585
}
7686

7787
sourceSets {
@@ -126,10 +136,5 @@ tasks.withType(KotlinCompilationTask::class).configureEach {
126136
if (isMainTaskName) {
127137
allWarningsAsErrors = true
128138
}
129-
if (overriddenLanguageVersion != null) {
130-
languageVersion = KotlinVersion.fromVersion(overriddenLanguageVersion!!)
131-
freeCompilerArgs.add("-Xsuppress-version-warnings")
132-
}
133-
freeCompilerArgs.add("-Xexpect-actual-classes")
134139
}
135140
}

0 commit comments

Comments
 (0)