diff --git a/impl/src/jvmMain/kotlin/ru/landgrafhomyak/kotlin/kmp_gradle_build_helper/compilations.kt b/impl/src/jvmMain/kotlin/ru/landgrafhomyak/kotlin/kmp_gradle_build_helper/compilations.kt index ffd86db..5241a88 100644 --- a/impl/src/jvmMain/kotlin/ru/landgrafhomyak/kotlin/kmp_gradle_build_helper/compilations.kt +++ b/impl/src/jvmMain/kotlin/ru/landgrafhomyak/kotlin/kmp_gradle_build_helper/compilations.kt @@ -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 -> - c.compileTaskProvider.configure { t -> - t.compilerOptions(action) - } + 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) } \ No newline at end of file diff --git a/versions.properties b/versions.properties index 1f22af5..fde520f 100644 --- a/versions.properties +++ b/versions.properties @@ -1,3 +1,3 @@ -this=0.2 +this=0.3 kotlin=2.0.20 gradle=7.5.1 \ No newline at end of file