|
|
|
@ -6,37 +6,65 @@ import org.jetbrains.kotlin.gradle.dsl.KotlinCommonCompilerOptions
|
|
|
|
|
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
|
|
|
|
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation
|
|
|
|
|
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
|
|
|
|
|
import org.jetbrains.kotlin.gradle.plugin.KotlinTarget
|
|
|
|
|
|
|
|
|
|
public fun KotlinMultiplatformExtension.configureAllCompilations(action: KotlinCompilation<*>.() -> Unit) {
|
|
|
|
|
public fun KotlinMultiplatformExtension.configureAllCompilationsOnAllTargets(action: KotlinCompilation<*>.() -> Unit) {
|
|
|
|
|
this.targets.configureEach { t ->
|
|
|
|
|
t.compilations.configureEach(action)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public fun KotlinMultiplatformExtension.configureAllCompilersOptions(action: KotlinCommonCompilerOptions.() -> Unit) {
|
|
|
|
|
@Deprecated(
|
|
|
|
|
message = "New name avoids confusions when function called on wrong scope",
|
|
|
|
|
replaceWith = ReplaceWith(
|
|
|
|
|
"this.configureAllCompilationsOnAllTargets",
|
|
|
|
|
"ru.landgrafhomyak.kotlin.kmp_gradle_build_helper.configureAllCompilationsOnAllTargets"
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
public fun KotlinMultiplatformExtension.configureAllCompilations(action: KotlinCompilation<*>.() -> Unit): Unit =
|
|
|
|
|
this.configureAllCompilationsOnAllTargets(action)
|
|
|
|
|
|
|
|
|
|
public fun KotlinMultiplatformExtension.configureAllCompilersOptionsOnAllTargets(action: KotlinCommonCompilerOptions.() -> Unit) {
|
|
|
|
|
this.targets.configureEach { t ->
|
|
|
|
|
t.compilations.configureEach { c ->
|
|
|
|
|
t.configureAllCompilersOptionsOnAllCompilations(action)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Deprecated(
|
|
|
|
|
message = "New name avoids confusions when function called on wrong scope",
|
|
|
|
|
replaceWith = ReplaceWith(
|
|
|
|
|
"this.configureAllCompilersOptionsOnAllTargets",
|
|
|
|
|
"ru.landgrafhomyak.kotlin.kmp_gradle_build_helper.configureAllCompilersOptionsOnAllTargets"
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
public fun KotlinMultiplatformExtension.configureAllCompilersOptions(action: KotlinCommonCompilerOptions.() -> Unit): Unit =
|
|
|
|
|
this.configureAllCompilersOptionsOnAllTargets(action)
|
|
|
|
|
|
|
|
|
|
public fun KotlinTarget.configureAllCompilersOptionsOnAllCompilations(action: KotlinCommonCompilerOptions.() -> Unit) {
|
|
|
|
|
this.compilations.configureEach { c ->
|
|
|
|
|
c.compileTaskProvider.configure { t ->
|
|
|
|
|
t.compilerOptions(action)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public fun KotlinMultiplatformExtension.noWarnExpectActual(): Unit =
|
|
|
|
|
this.configureAllCompilersOptions { this@configureAllCompilersOptions.freeCompilerArgs.add("-Xexpect-actual-classes") }
|
|
|
|
|
this.configureAllCompilersOptionsOnAllTargets { this@configureAllCompilersOptionsOnAllTargets.freeCompilerArgs.add("-Xexpect-actual-classes") }
|
|
|
|
|
|
|
|
|
|
public fun KotlinMultiplatformExtension.warningsAsErrors(): Unit =
|
|
|
|
|
this.configureAllCompilersOptions { this@configureAllCompilersOptions.allWarningsAsErrors.set(true) }
|
|
|
|
|
this.configureAllCompilersOptionsOnAllTargets { this@configureAllCompilersOptionsOnAllTargets.allWarningsAsErrors.set(true) }
|
|
|
|
|
|
|
|
|
|
public fun KotlinMultiplatformExtension.optIn(classQualname: String): Unit =
|
|
|
|
|
this.configureAllCompilersOptions { this@configureAllCompilersOptions.optIn.add(classQualname) }
|
|
|
|
|
this.configureAllCompilersOptionsOnAllTargets { this@configureAllCompilersOptionsOnAllTargets.optIn.add(classQualname) }
|
|
|
|
|
|
|
|
|
|
public fun KotlinMultiplatformExtension.optInContracts(): Unit =
|
|
|
|
|
this.optIn("kotlin.contracts.ExperimentalContracts")
|
|
|
|
|
|
|
|
|
|
public fun KotlinMultiplatformExtension.optInUnsignedArrayTypes(): Unit =
|
|
|
|
|
this.optIn("kotlin.ExperimentalUnsignedTypes")
|
|
|
|
|
|
|
|
|
|
public fun KotlinMultiplatformExtension.setCompatibilityWithKotlin(version: KotlinVersion): Unit =
|
|
|
|
|
this.configureAllCompilersOptions {
|
|
|
|
|
this@configureAllCompilersOptions.apiVersion.set(version)
|
|
|
|
|
this@configureAllCompilersOptions.languageVersion.set(version)
|
|
|
|
|
this.configureAllCompilersOptionsOnAllTargets {
|
|
|
|
|
this@configureAllCompilersOptionsOnAllTargets.apiVersion.set(version)
|
|
|
|
|
this@configureAllCompilersOptionsOnAllTargets.languageVersion.set(version)
|
|
|
|
|
}
|