[Gradle][KMP] Remove top level and target level compilerOptions APIs
as those experimental APIs have shown to negatively affect usages of stable APIs (because of resolve confusion), whilst also failing to address popular use cases. KT-61636 KT-61355 KT-61368
This commit is contained in:
committed by
Space Team
parent
eef57f216c
commit
1dad890652
@@ -1117,7 +1117,6 @@ public abstract interface class org/jetbrains/kotlin/gradle/plugin/KotlinTarget
|
||||
public abstract fun getApiElementsConfigurationName ()Ljava/lang/String;
|
||||
public abstract fun getArtifactsTaskName ()Ljava/lang/String;
|
||||
public abstract fun getCompilations ()Lorg/gradle/api/NamedDomainObjectContainer;
|
||||
public abstract fun getCompilerOptions ()Lorg/jetbrains/kotlin/gradle/dsl/KotlinCommonCompilerOptions;
|
||||
public abstract fun getComponents ()Ljava/util/Set;
|
||||
public abstract fun getDisambiguationClassifier ()Ljava/lang/String;
|
||||
public abstract fun getName ()Ljava/lang/String;
|
||||
|
||||
-3
@@ -64,9 +64,6 @@ interface KotlinTarget : Named, HasAttributes, HasProject, HasMutableExtras {
|
||||
val preset: KotlinTargetPreset<out KotlinTarget>?
|
||||
|
||||
override fun getName(): String = targetName
|
||||
|
||||
@ExperimentalKotlinGradlePluginApi
|
||||
val compilerOptions: KotlinCommonCompilerOptions
|
||||
}
|
||||
|
||||
interface KotlinTargetWithTests<E : KotlinExecution.ExecutionSource, T : KotlinTargetTestRun<E>> : KotlinTarget {
|
||||
|
||||
+6
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.gradle
|
||||
import org.gradle.api.logging.LogLevel
|
||||
import org.gradle.util.GradleVersion
|
||||
import org.jetbrains.kotlin.gradle.testbase.*
|
||||
import org.junit.jupiter.api.Disabled
|
||||
import org.junit.jupiter.api.DisplayName
|
||||
import kotlin.io.path.appendText
|
||||
|
||||
@@ -298,6 +299,7 @@ class CompilerOptionsProjectIT : KGPBaseTest() {
|
||||
}
|
||||
}
|
||||
|
||||
@Disabled("DSL was demoted to 'internal'; Design is planned for 2.0")
|
||||
@DisplayName("Android target compiler options override project level compiler options")
|
||||
@AndroidGradlePluginTests
|
||||
@GradleAndroidTest
|
||||
@@ -445,6 +447,7 @@ class CompilerOptionsProjectIT : KGPBaseTest() {
|
||||
@GradleTestVersions(minVersion = TestVersions.Gradle.G_7_0)
|
||||
@AndroidTestVersions(minVersion = TestVersions.AGP.AGP_70)
|
||||
@AndroidGradlePluginTests
|
||||
@Disabled("DSL was demoted to 'internal'; Design is planned for 2.0")
|
||||
fun mppAndroidModuleName(
|
||||
gradleVersion: GradleVersion,
|
||||
agpVersion: String,
|
||||
@@ -478,6 +481,7 @@ class CompilerOptionsProjectIT : KGPBaseTest() {
|
||||
}
|
||||
}
|
||||
|
||||
@Disabled("DSL was demoted to 'internal'; Design is planned for 2.0")
|
||||
@GradleTest
|
||||
@DisplayName("Multiplatform compiler option DSL hierarchy")
|
||||
@JvmGradlePluginTests
|
||||
@@ -555,6 +559,8 @@ class CompilerOptionsProjectIT : KGPBaseTest() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Disabled("DSL was demoted to 'internal'; Design is planned for 2.0")
|
||||
@DisplayName("KT-61303: Multiplatform/Android module name is changed")
|
||||
@AndroidGradlePluginTests
|
||||
@GradleAndroidTest
|
||||
|
||||
+4
-2
@@ -5,8 +5,10 @@ apply plugin: 'kotlin-multiplatform'
|
||||
apply plugin: 'maven-publish'
|
||||
|
||||
kotlin {
|
||||
compilerOptions {
|
||||
optIn.add("kotlinx.cinterop.ExperimentalForeignApi")
|
||||
sourceSets.all {
|
||||
languageSettings {
|
||||
optIn("kotlinx.cinterop.ExperimentalForeignApi")
|
||||
}
|
||||
}
|
||||
|
||||
js() {
|
||||
|
||||
+6
-1
@@ -4,7 +4,12 @@ plugins {
|
||||
}
|
||||
|
||||
kotlin {
|
||||
compilerOptions.freeCompilerArgs.add("-Xexpect-actual-classes")
|
||||
targets.all {
|
||||
compilations.all {
|
||||
compilerOptions.options.freeCompilerArgs.add("-Xexpect-actual-classes")
|
||||
}
|
||||
}
|
||||
|
||||
jvm {
|
||||
withJava()
|
||||
}
|
||||
|
||||
+4
-2
@@ -8,8 +8,10 @@ repositories {
|
||||
}
|
||||
|
||||
kotlin {
|
||||
compilerOptions {
|
||||
optIn.add("kotlinx.cinterop.ExperimentalForeignApi")
|
||||
sourceSets.all {
|
||||
languageSettings {
|
||||
optIn("kotlinx.cinterop.ExperimentalForeignApi")
|
||||
}
|
||||
}
|
||||
|
||||
linuxArm64("shortPlatform") {
|
||||
|
||||
-14
@@ -26,18 +26,4 @@ class PrototypeAndroidTarget(
|
||||
@Suppress("unchecked_cast")
|
||||
override val compilations: NamedDomainObjectContainer<PrototypeAndroidCompilation>
|
||||
get() = super.compilations as NamedDomainObjectContainer<PrototypeAndroidCompilation>
|
||||
|
||||
@ExperimentalKotlinGradlePluginApi
|
||||
override val compilerOptions: KotlinJvmCompilerOptions
|
||||
get() = super.compilerOptions as KotlinJvmCompilerOptions
|
||||
|
||||
@ExperimentalKotlinGradlePluginApi
|
||||
fun compilerOptions(configure: KotlinJvmCompilerOptions.() -> Unit) {
|
||||
configure(compilerOptions)
|
||||
}
|
||||
|
||||
@ExperimentalKotlinGradlePluginApi
|
||||
fun compilerOptions(configure: Action<KotlinJvmCompilerOptions>) {
|
||||
configure.execute(compilerOptions)
|
||||
}
|
||||
}
|
||||
@@ -34,8 +34,6 @@ public abstract class org/jetbrains/kotlin/gradle/dsl/KotlinMultiplatformExtensi
|
||||
public fun applyHierarchyTemplate (Lkotlin/jvm/functions/Function1;)V
|
||||
public fun applyHierarchyTemplate (Lorg/jetbrains/kotlin/gradle/plugin/KotlinHierarchyTemplate;)V
|
||||
public fun applyHierarchyTemplate (Lorg/jetbrains/kotlin/gradle/plugin/KotlinHierarchyTemplate;Lkotlin/jvm/functions/Function1;)V
|
||||
public final fun compilerOptions (Lkotlin/jvm/functions/Function1;)V
|
||||
public final fun compilerOptions (Lorg/gradle/api/Action;)V
|
||||
public fun dependencies (Lorg/gradle/api/NamedDomainObjectProvider;Lkotlin/jvm/functions/Function1;)V
|
||||
public fun getAndroidMain (Lorg/gradle/api/NamedDomainObjectContainer;)Lorg/gradle/api/NamedDomainObjectProvider;
|
||||
public fun getAndroidNativeMain (Lorg/gradle/api/NamedDomainObjectContainer;)Lorg/gradle/api/NamedDomainObjectProvider;
|
||||
@@ -45,7 +43,6 @@ public abstract class org/jetbrains/kotlin/gradle/dsl/KotlinMultiplatformExtensi
|
||||
public fun getBOTH ()Lorg/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerType;
|
||||
public fun getCommonMain (Lorg/gradle/api/NamedDomainObjectContainer;)Lorg/gradle/api/NamedDomainObjectProvider;
|
||||
public fun getCommonTest (Lorg/gradle/api/NamedDomainObjectContainer;)Lorg/gradle/api/NamedDomainObjectProvider;
|
||||
public final fun getCompilerOptions ()Lorg/jetbrains/kotlin/gradle/dsl/KotlinCommonCompilerOptions;
|
||||
public fun getCompilerTypeFromProperties ()Lorg/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerType;
|
||||
public fun getDefaultJsCompilerType ()Lorg/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerType;
|
||||
public fun getIR ()Lorg/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerType;
|
||||
@@ -737,7 +734,6 @@ public class org/jetbrains/kotlin/gradle/plugin/mpp/external/DecoratedExternalKo
|
||||
public fun getArtifactsTaskName ()Ljava/lang/String;
|
||||
public fun getAttributes ()Lorg/gradle/api/attributes/AttributeContainer;
|
||||
public fun getCompilations ()Lorg/gradle/api/NamedDomainObjectContainer;
|
||||
public fun getCompilerOptions ()Lorg/jetbrains/kotlin/gradle/dsl/KotlinCommonCompilerOptions;
|
||||
public fun getComponents ()Ljava/util/Set;
|
||||
public fun getDisambiguationClassifier ()Ljava/lang/String;
|
||||
public synthetic fun getExtras ()Lorg/jetbrains/kotlin/tooling/core/Extras;
|
||||
|
||||
+3
-3
@@ -244,7 +244,7 @@ abstract class KotlinMultiplatformExtension
|
||||
}
|
||||
|
||||
@ExperimentalKotlinGradlePluginApi
|
||||
val compilerOptions: KotlinCommonCompilerOptions = project.objects
|
||||
internal val compilerOptions: KotlinCommonCompilerOptions = project.objects
|
||||
.newInstance<KotlinCommonCompilerOptionsDefault>()
|
||||
.configureExperimentalTryK2(project)
|
||||
.also {
|
||||
@@ -252,12 +252,12 @@ abstract class KotlinMultiplatformExtension
|
||||
}
|
||||
|
||||
@ExperimentalKotlinGradlePluginApi
|
||||
fun compilerOptions(configure: KotlinCommonCompilerOptions.() -> Unit) {
|
||||
internal fun compilerOptions(configure: KotlinCommonCompilerOptions.() -> Unit) {
|
||||
configure(compilerOptions)
|
||||
}
|
||||
|
||||
@ExperimentalKotlinGradlePluginApi
|
||||
fun compilerOptions(configure: Action<KotlinCommonCompilerOptions>) {
|
||||
internal fun compilerOptions(configure: Action<KotlinCommonCompilerOptions>) {
|
||||
configure.execute(compilerOptions)
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -12,6 +12,8 @@ import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinPluginLifecycle
|
||||
import org.jetbrains.kotlin.gradle.plugin.await
|
||||
import org.jetbrains.kotlin.gradle.plugin.launch
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.compilerOptions
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.internal
|
||||
import org.jetbrains.kotlin.gradle.plugin.sources.DefaultLanguageSettingsBuilder
|
||||
import org.jetbrains.kotlin.gradle.utils.newInstance
|
||||
|
||||
@@ -21,7 +23,7 @@ internal fun KotlinMultiplatformExtension.syncCommonOptions(
|
||||
targets.configureEach { target ->
|
||||
KotlinCommonCompilerOptionsHelper.syncOptionsAsConvention(
|
||||
extensionCompilerOptions,
|
||||
target.compilerOptions
|
||||
target.internal.compilerOptions
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
+3
@@ -13,6 +13,7 @@ import org.gradle.api.publish.maven.MavenPublication
|
||||
import org.jetbrains.kotlin.gradle.DeprecatedTargetPresetApi
|
||||
import org.jetbrains.kotlin.gradle.InternalKotlinGradlePluginApi
|
||||
import org.jetbrains.kotlin.gradle.PRESETS_API_IS_DEPRECATED_MESSAGE
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonCompilerOptions
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||
import org.jetbrains.kotlin.gradle.dsl.kotlinExtension
|
||||
import org.jetbrains.kotlin.gradle.plugin.*
|
||||
@@ -36,6 +37,8 @@ abstract class AbstractKotlinTarget(
|
||||
|
||||
override fun getAttributes(): AttributeContainer = attributeContainer
|
||||
|
||||
internal abstract val compilerOptions: KotlinCommonCompilerOptions
|
||||
|
||||
@Deprecated("Scheduled for removal with Kotlin 2.2")
|
||||
override var useDisambiguationClassifierAsSourceSetNamePrefix: Boolean = true
|
||||
internal set
|
||||
|
||||
+10
@@ -7,10 +7,13 @@ package org.jetbrains.kotlin.gradle.plugin.mpp
|
||||
|
||||
import org.gradle.api.publish.maven.MavenPublication
|
||||
import org.jetbrains.kotlin.gradle.InternalKotlinGradlePluginApi
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonCompilerOptions
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinPluginLifecycle
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinTarget
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinTargetComponent
|
||||
import org.jetbrains.kotlin.gradle.plugin.await
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.external.DecoratedExternalKotlinTarget
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.external.ExternalKotlinTargetImpl
|
||||
import org.jetbrains.kotlin.gradle.utils.futureExtension
|
||||
import org.jetbrains.kotlin.tooling.core.HasMutableExtras
|
||||
|
||||
@@ -28,6 +31,13 @@ internal val KotlinTarget.internal: InternalKotlinTarget
|
||||
"KotlinTarget($name) ${this::class} does not implement ${InternalKotlinTarget::class}"
|
||||
)
|
||||
|
||||
internal val InternalKotlinTarget.compilerOptions: KotlinCommonCompilerOptions
|
||||
get() = when (this) {
|
||||
is AbstractKotlinTarget -> compilerOptions
|
||||
is ExternalKotlinTargetImpl -> compilerOptions
|
||||
is DecoratedExternalKotlinTarget -> delegate.compilerOptions
|
||||
else -> throw IllegalStateException("Unexpected 'KotlinTarget' type: ${this.javaClass}")
|
||||
}
|
||||
|
||||
internal val InternalKotlinTarget.isSourcesPublishableFuture by futureExtension("isSourcesPublishableFuture") {
|
||||
KotlinPluginLifecycle.Stage.AfterFinaliseDsl.await()
|
||||
|
||||
+2
-2
@@ -36,11 +36,11 @@ open class KotlinCommonCompilation @Inject internal constructor(compilation: Kot
|
||||
|
||||
internal var forceCompilationToKotlinMetadata: Boolean = false
|
||||
|
||||
fun compilerOptions(configure: KotlinCommonCompilerOptions.() -> Unit) {
|
||||
internal fun compilerOptions(configure: KotlinCommonCompilerOptions.() -> Unit) {
|
||||
compilerOptions.configure(configure)
|
||||
}
|
||||
|
||||
fun compilerOptions(configure: Action<KotlinCommonCompilerOptions>) {
|
||||
internal fun compilerOptions(configure: Action<KotlinCommonCompilerOptions>) {
|
||||
configure.execute(compilerOptions.options)
|
||||
}
|
||||
}
|
||||
|
||||
+5
-4
@@ -19,7 +19,7 @@ import org.jetbrains.kotlin.gradle.utils.newInstance
|
||||
import javax.inject.Inject
|
||||
|
||||
abstract class KotlinMetadataTarget @Inject constructor(
|
||||
project: Project
|
||||
project: Project,
|
||||
) : KotlinOnlyTarget<KotlinCompilation<*>>(project, KotlinPlatformType.common) {
|
||||
|
||||
override val artifactsTaskName: String
|
||||
@@ -38,17 +38,18 @@ abstract class KotlinMetadataTarget @Inject constructor(
|
||||
emptySet()
|
||||
}
|
||||
|
||||
@Suppress("RedundantVisibilityModifier")
|
||||
@ExperimentalKotlinGradlePluginApi
|
||||
override val compilerOptions: KotlinCommonCompilerOptions = project.objects
|
||||
internal override val compilerOptions: KotlinCommonCompilerOptions = project.objects
|
||||
.newInstance<KotlinCommonCompilerOptionsDefault>()
|
||||
|
||||
@ExperimentalKotlinGradlePluginApi
|
||||
fun compilerOptions(configure: KotlinCommonCompilerOptions.() -> Unit) {
|
||||
internal fun compilerOptions(configure: KotlinCommonCompilerOptions.() -> Unit) {
|
||||
configure(compilerOptions)
|
||||
}
|
||||
|
||||
@ExperimentalKotlinGradlePluginApi
|
||||
fun compilerOptions(configure: Action<KotlinCommonCompilerOptions>) {
|
||||
internal fun compilerOptions(configure: Action<KotlinCommonCompilerOptions>) {
|
||||
configure.execute(compilerOptions)
|
||||
}
|
||||
}
|
||||
|
||||
+3
-5
@@ -8,9 +8,7 @@ package org.jetbrains.kotlin.gradle.plugin.mpp.compilationImpl
|
||||
import org.jetbrains.kotlin.gradle.dsl.*
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompilerOptionsHelper
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinNativeCompilerOptionsHelper
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.DecoratedKotlinCompilation
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinMetadataTarget
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinWithJavaTarget
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.*
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.compilationImpl.factory.KotlinCompilationImplFactory
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.moduleNameForCompilation
|
||||
|
||||
@@ -92,13 +90,13 @@ internal object KotlinCompilationCompilerOptionsFromTargetConfigurator : KotlinC
|
||||
commonCompilerOptions: KotlinCommonCompilerOptions
|
||||
) {
|
||||
KotlinCommonCompilerOptionsHelper.syncOptionsAsConvention(
|
||||
target.compilerOptions,
|
||||
target.internal.compilerOptions,
|
||||
commonCompilerOptions
|
||||
)
|
||||
}
|
||||
|
||||
private inline fun <reified T : KotlinCommonCompilerOptions> DecoratedKotlinCompilation<*>.requireTargetCompilerOptionsType(): T {
|
||||
val targetCompilerOptions = compilation.target.compilerOptions
|
||||
val targetCompilerOptions = compilation.target.internal.compilerOptions
|
||||
require(targetCompilerOptions is T) {
|
||||
"${compilation.compilationName} target ${compilation.target.name}:${compilation.target::class.qualifiedName} has incorrect 'compilerOptions' type " +
|
||||
"${targetCompilerOptions::class.qualifiedName}"
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ internal class ExternalKotlinTargetImpl internal constructor(
|
||||
override val targetName: String,
|
||||
override val platformType: KotlinPlatformType,
|
||||
override val publishable: Boolean,
|
||||
override val compilerOptions: KotlinCommonCompilerOptions,
|
||||
val compilerOptions: KotlinCommonCompilerOptions,
|
||||
val apiElementsConfiguration: Configuration,
|
||||
val runtimeElementsConfiguration: Configuration,
|
||||
val sourcesElementsConfiguration: Configuration,
|
||||
|
||||
+4
-3
@@ -332,20 +332,21 @@ abstract class KotlinAndroidTarget @Inject constructor(
|
||||
attribute: Attribute<*>,
|
||||
): Boolean = attribute.name != "com.android.build.api.attributes.AgpVersionAttr"
|
||||
|
||||
@Suppress("RedundantVisibilityModifier")
|
||||
@ExperimentalKotlinGradlePluginApi
|
||||
override val compilerOptions: KotlinJvmCompilerOptions = project.objects
|
||||
internal override val compilerOptions: KotlinJvmCompilerOptions = project.objects
|
||||
.newInstance<KotlinJvmCompilerOptionsDefault>()
|
||||
.apply {
|
||||
DefaultKotlinJavaToolchain.wireJvmTargetToToolchain(this, project)
|
||||
}
|
||||
|
||||
@ExperimentalKotlinGradlePluginApi
|
||||
fun compilerOptions(configure: KotlinJvmCompilerOptions.() -> Unit) {
|
||||
internal fun compilerOptions(configure: KotlinJvmCompilerOptions.() -> Unit) {
|
||||
configure(compilerOptions)
|
||||
}
|
||||
|
||||
@ExperimentalKotlinGradlePluginApi
|
||||
fun compilerOptions(configure: Action<KotlinJvmCompilerOptions>) {
|
||||
internal fun compilerOptions(configure: Action<KotlinJvmCompilerOptions>) {
|
||||
configure.execute(compilerOptions)
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -31,11 +31,11 @@ open class KotlinJsCompilation @Inject internal constructor(
|
||||
final override val compilerOptions: HasCompilerOptions<KotlinJsCompilerOptions>
|
||||
get() = compilation.compilerOptions as HasCompilerOptions<KotlinJsCompilerOptions>
|
||||
|
||||
fun compilerOptions(configure: KotlinJsCompilerOptions.() -> Unit) {
|
||||
internal fun compilerOptions(configure: KotlinJsCompilerOptions.() -> Unit) {
|
||||
compilerOptions.configure(configure)
|
||||
}
|
||||
|
||||
fun compilerOptions(configure: Action<KotlinJsCompilerOptions>) {
|
||||
internal fun compilerOptions(configure: Action<KotlinJsCompilerOptions>) {
|
||||
configure.execute(compilerOptions.options)
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -13,8 +13,9 @@ import org.jetbrains.kotlin.gradle.dsl.kotlinExtension
|
||||
import org.jetbrains.kotlin.gradle.internal.customizeKotlinDependencies
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation.Companion.MAIN_COMPILATION_NAME
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation.Companion.TEST_COMPILATION_NAME
|
||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJsSingleTargetPreset
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.compilerOptions
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.internal
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.setupGeneralKotlinExtensionParameters
|
||||
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrSingleTargetPreset
|
||||
import org.jetbrains.kotlin.gradle.utils.*
|
||||
@@ -94,7 +95,7 @@ open class KotlinJsPlugin: Plugin<Project> {
|
||||
kotlinExtension.sourceSets.maybeCreate(TEST_COMPILATION_NAME)
|
||||
|
||||
kotlinExtension.registerTargetObserver { target ->
|
||||
target?.compilerOptions?.configureExperimentalTryK2(project)
|
||||
target?.internal?.compilerOptions?.configureExperimentalTryK2(project)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-13
@@ -66,19 +66,6 @@ interface KotlinJsTargetDsl : KotlinTarget, KotlinTargetWithNodeJsDsl {
|
||||
|
||||
// Need to compatibility when users use KotlinJsCompilation specific in build script
|
||||
override val compilations: NamedDomainObjectContainer<out KotlinJsCompilation>
|
||||
|
||||
@ExperimentalKotlinGradlePluginApi
|
||||
override val compilerOptions: KotlinJsCompilerOptions
|
||||
|
||||
@ExperimentalKotlinGradlePluginApi
|
||||
fun compilerOptions(configure: KotlinJsCompilerOptions.() -> Unit) {
|
||||
configure(compilerOptions)
|
||||
}
|
||||
|
||||
@ExperimentalKotlinGradlePluginApi
|
||||
fun compilerOptions(configure: Action<KotlinJsCompilerOptions>) {
|
||||
configure.execute(compilerOptions)
|
||||
}
|
||||
}
|
||||
|
||||
interface KotlinTargetWithNodeJsDsl {
|
||||
|
||||
+2
-1
@@ -477,8 +477,9 @@ constructor(
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("RedundantVisibilityModifier")
|
||||
@ExperimentalKotlinGradlePluginApi
|
||||
override val compilerOptions: KotlinJsCompilerOptions = project.objects
|
||||
internal override val compilerOptions: KotlinJsCompilerOptions = project.objects
|
||||
.newInstance<KotlinJsCompilerOptionsDefault>()
|
||||
.apply {
|
||||
configureJsDefaultOptions(platformType)
|
||||
|
||||
+2
-2
@@ -35,11 +35,11 @@ open class KotlinJvmCompilation @Inject internal constructor(
|
||||
override val compilerOptions: HasCompilerOptions<KotlinJvmCompilerOptions> =
|
||||
compilation.compilerOptions.castCompilerOptionsType()
|
||||
|
||||
fun compilerOptions(configure: KotlinJvmCompilerOptions.() -> Unit) {
|
||||
internal fun compilerOptions(configure: KotlinJvmCompilerOptions.() -> Unit) {
|
||||
compilerOptions.configure(configure)
|
||||
}
|
||||
|
||||
fun compilerOptions(configure: Action<KotlinJvmCompilerOptions>) {
|
||||
internal fun compilerOptions(configure: Action<KotlinJvmCompilerOptions>) {
|
||||
configure.execute(compilerOptions.options)
|
||||
}
|
||||
|
||||
|
||||
+4
-3
@@ -335,8 +335,9 @@ abstract class KotlinJvmTarget @Inject constructor(
|
||||
private fun areRuntimeOrCompileConfigurationsAvailable(): Boolean =
|
||||
GradleVersion.version(project.gradle.gradleVersion) <= GradleVersion.version("6.8.3")
|
||||
|
||||
@Suppress("RedundantVisibilityModifier")
|
||||
@ExperimentalKotlinGradlePluginApi
|
||||
override val compilerOptions: KotlinJvmCompilerOptions = project.objects
|
||||
internal override val compilerOptions: KotlinJvmCompilerOptions = project.objects
|
||||
.newInstance<KotlinJvmCompilerOptionsDefault>()
|
||||
.apply {
|
||||
DefaultKotlinJavaToolchain.wireJvmTargetToToolchain(
|
||||
@@ -346,12 +347,12 @@ abstract class KotlinJvmTarget @Inject constructor(
|
||||
}
|
||||
|
||||
@ExperimentalKotlinGradlePluginApi
|
||||
fun compilerOptions(configure: KotlinJvmCompilerOptions.() -> Unit) {
|
||||
internal fun compilerOptions(configure: KotlinJvmCompilerOptions.() -> Unit) {
|
||||
configure(compilerOptions)
|
||||
}
|
||||
|
||||
@ExperimentalKotlinGradlePluginApi
|
||||
fun compilerOptions(configure: Action<KotlinJvmCompilerOptions>) {
|
||||
internal fun compilerOptions(configure: Action<KotlinJvmCompilerOptions>) {
|
||||
configure.execute(compilerOptions)
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -29,11 +29,11 @@ open class KotlinWithJavaCompilation<KotlinOptionsType : KotlinCommonOptions, CO
|
||||
override val compilerOptions: HasCompilerOptions<CO> =
|
||||
compilation.compilerOptions as HasCompilerOptions<CO>
|
||||
|
||||
fun compilerOptions(configure: CO.() -> Unit) {
|
||||
internal fun compilerOptions(configure: CO.() -> Unit) {
|
||||
compilerOptions.configure(configure)
|
||||
}
|
||||
|
||||
fun compilerOptions(configure: Action<CO>) {
|
||||
internal fun compilerOptions(configure: Action<CO>) {
|
||||
configure.execute(compilerOptions.options)
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -44,11 +44,11 @@ abstract class AbstractKotlinNativeCompilation internal constructor(
|
||||
override val compilerOptions: HasCompilerOptions<KotlinNativeCompilerOptions>
|
||||
get() = compilation.compilerOptions as HasCompilerOptions<KotlinNativeCompilerOptions>
|
||||
|
||||
fun compilerOptions(configure: KotlinNativeCompilerOptions.() -> Unit) {
|
||||
internal fun compilerOptions(configure: KotlinNativeCompilerOptions.() -> Unit) {
|
||||
compilerOptions.configure(configure)
|
||||
}
|
||||
|
||||
fun compilerOptions(configure: Action<KotlinNativeCompilerOptions>) {
|
||||
internal fun compilerOptions(configure: Action<KotlinNativeCompilerOptions>) {
|
||||
configure.execute(compilerOptions.options)
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -136,7 +136,7 @@ abstract class KotlinNativeTarget @Inject constructor(
|
||||
get() = konanTarget.enabledOnCurrentHost
|
||||
|
||||
@ExperimentalKotlinGradlePluginApi
|
||||
override val compilerOptions: KotlinNativeCompilerOptions = project.objects
|
||||
internal override val compilerOptions: KotlinNativeCompilerOptions = project.objects
|
||||
.newInstance<KotlinNativeCompilerOptionsDefault>()
|
||||
.apply {
|
||||
moduleName.convention(
|
||||
@@ -147,12 +147,12 @@ abstract class KotlinNativeTarget @Inject constructor(
|
||||
}
|
||||
|
||||
@ExperimentalKotlinGradlePluginApi
|
||||
fun compilerOptions(configure: KotlinNativeCompilerOptions.() -> Unit) {
|
||||
internal fun compilerOptions(configure: KotlinNativeCompilerOptions.() -> Unit) {
|
||||
configure(compilerOptions)
|
||||
}
|
||||
|
||||
@ExperimentalKotlinGradlePluginApi
|
||||
fun compilerOptions(configure: Action<KotlinNativeCompilerOptions>) {
|
||||
internal fun compilerOptions(configure: Action<KotlinNativeCompilerOptions>) {
|
||||
configure.execute(compilerOptions)
|
||||
}
|
||||
|
||||
|
||||
-429
@@ -1,429 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.gradle.unitTests
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.jetbrains.kotlin.gradle.dsl.*
|
||||
import org.jetbrains.kotlin.gradle.dsl.multiplatformExtension
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinMetadataTarget
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.external.createCompilation
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.external.createExternalKotlinTarget
|
||||
import org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile as KotlinJvmCompileTask
|
||||
import org.jetbrains.kotlin.gradle.tasks.withType
|
||||
import org.jetbrains.kotlin.gradle.util.*
|
||||
import org.jetbrains.kotlin.gradle.utils.named
|
||||
import org.jetbrains.kotlin.test.util.JUnit4Assertions.assertTrue
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
class ProjectCompilerOptionsTests {
|
||||
|
||||
@Test
|
||||
fun nativeTargetCompilerOptionsDSL() {
|
||||
val project = buildProjectWithMPP {
|
||||
with(multiplatformExtension) {
|
||||
linuxX64 {
|
||||
compilerOptions {
|
||||
progressiveMode.set(true)
|
||||
}
|
||||
}
|
||||
|
||||
iosX64 {
|
||||
compilerOptions {
|
||||
suppressWarnings.set(true)
|
||||
}
|
||||
}
|
||||
|
||||
applyDefaultHierarchyTemplate()
|
||||
}
|
||||
}
|
||||
|
||||
project.evaluate()
|
||||
|
||||
assertEquals(true, project.kotlinNativeTask("compileKotlinLinuxX64").compilerOptions.progressiveMode.get())
|
||||
assertEquals(false, project.kotlinNativeTask("compileKotlinLinuxX64").compilerOptions.suppressWarnings.get())
|
||||
assertEquals(true, project.kotlinNativeTask("compileTestKotlinLinuxX64").compilerOptions.progressiveMode.get())
|
||||
assertEquals(false, project.kotlinNativeTask("compileTestKotlinLinuxX64").compilerOptions.suppressWarnings.get())
|
||||
assertEquals(true, project.kotlinNativeTask("compileKotlinIosX64").compilerOptions.suppressWarnings.get())
|
||||
assertEquals(false, project.kotlinNativeTask("compileKotlinIosX64").compilerOptions.progressiveMode.get())
|
||||
assertEquals(true, project.kotlinNativeTask("compileTestKotlinIosX64").compilerOptions.suppressWarnings.get())
|
||||
assertEquals(false, project.kotlinNativeTask("compileTestKotlinIosX64").compilerOptions.progressiveMode.get())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun nativeTaskOverridesTargetOptions() {
|
||||
val project = buildProjectWithMPP {
|
||||
tasks.withType<KotlinCompilationTask<*>>().configureEach {
|
||||
if (it.name == "compileKotlinLinuxX64") {
|
||||
it.compilerOptions.progressiveMode.set(false)
|
||||
}
|
||||
}
|
||||
|
||||
with(multiplatformExtension) {
|
||||
linuxX64 {
|
||||
compilerOptions {
|
||||
progressiveMode.set(true)
|
||||
}
|
||||
}
|
||||
|
||||
applyDefaultHierarchyTemplate()
|
||||
}
|
||||
}
|
||||
|
||||
project.evaluate()
|
||||
|
||||
assertEquals(false, project.kotlinNativeTask("compileKotlinLinuxX64").compilerOptions.progressiveMode.get())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun jsTargetCompilerOptionsDsl() {
|
||||
val project = buildProjectWithMPP {
|
||||
with(multiplatformExtension) {
|
||||
js {
|
||||
compilerOptions {
|
||||
suppressWarnings.set(true)
|
||||
}
|
||||
}
|
||||
|
||||
applyDefaultHierarchyTemplate()
|
||||
}
|
||||
}
|
||||
|
||||
project.evaluate()
|
||||
|
||||
assertEquals(true, project.kotlinJsTask("compileKotlinJs").compilerOptions.suppressWarnings.get())
|
||||
assertEquals(true, project.kotlinJsTask("compileTestKotlinJs").compilerOptions.suppressWarnings.get())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun jsTaskOptionsOverridesTargetOptions() {
|
||||
val project = buildProjectWithMPP {
|
||||
tasks.withType<KotlinCompilationTask<*>>().configureEach {
|
||||
if (it.name == "compileKotlinJs") {
|
||||
it.compilerOptions.suppressWarnings.set(false)
|
||||
}
|
||||
}
|
||||
|
||||
with(multiplatformExtension) {
|
||||
js {
|
||||
compilerOptions {
|
||||
suppressWarnings.set(true)
|
||||
}
|
||||
}
|
||||
|
||||
applyDefaultHierarchyTemplate()
|
||||
}
|
||||
}
|
||||
|
||||
project.evaluate()
|
||||
|
||||
assertEquals(false, project.kotlinJsTask("compileKotlinJs").compilerOptions.suppressWarnings.get())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun metadataTargetDsl() {
|
||||
val project = buildProjectWithMPP {
|
||||
with(multiplatformExtension) {
|
||||
linuxX64()
|
||||
iosX64()
|
||||
iosArm64()
|
||||
|
||||
targets.named("metadata", KotlinMetadataTarget::class.java) {
|
||||
it.compilerOptions {
|
||||
progressiveMode.set(true)
|
||||
}
|
||||
}
|
||||
|
||||
applyDefaultHierarchyTemplate()
|
||||
}
|
||||
}
|
||||
|
||||
project.evaluate()
|
||||
|
||||
assertEquals(true, project.kotlinCommonTask("compileKotlinMetadata").compilerOptions.progressiveMode.get())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun metadataTaskOptionsOverrideTargetOptions() {
|
||||
val project = buildProjectWithMPP {
|
||||
tasks.withType<KotlinCompilationTask<*>>().configureEach {
|
||||
if (it.name == "compileKotlinMetadata") {
|
||||
it.compilerOptions.progressiveMode.set(false)
|
||||
}
|
||||
}
|
||||
|
||||
with(multiplatformExtension) {
|
||||
linuxX64()
|
||||
iosX64()
|
||||
iosArm64()
|
||||
|
||||
targets.named("metadata", KotlinMetadataTarget::class.java) {
|
||||
it.compilerOptions {
|
||||
progressiveMode.set(true)
|
||||
}
|
||||
}
|
||||
|
||||
applyDefaultHierarchyTemplate()
|
||||
}
|
||||
}
|
||||
|
||||
project.evaluate()
|
||||
|
||||
assertEquals(false, project.kotlinCommonTask("compileKotlinMetadata").compilerOptions.progressiveMode.get())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun externalTargetDsl() {
|
||||
val project = buildProjectWithMPP()
|
||||
project.runLifecycleAwareTest {
|
||||
with(multiplatformExtension) {
|
||||
val target = createExternalKotlinTarget<FakeTarget> { defaults() }
|
||||
target.createCompilation<FakeCompilation> { defaults(this@with) }
|
||||
target.createCompilation<FakeCompilation> { defaults(this@with, "test") }
|
||||
|
||||
target.compilerOptions {
|
||||
javaParameters.set(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
assertEquals(true, project.kotlinJvmTask("compileKotlinFake").compilerOptions.javaParameters.get())
|
||||
assertEquals(true, project.kotlinJvmTask("compileTestKotlinFake").compilerOptions.javaParameters.get())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun externalTaskOptionsOverridesTargetOptions() {
|
||||
val project = buildProjectWithMPP()
|
||||
project.runLifecycleAwareTest {
|
||||
tasks.withType<KotlinJvmCompileTask>().configureEach {
|
||||
if (it.name == "compileKotlinFake") {
|
||||
it.compilerOptions.javaParameters.set(false)
|
||||
}
|
||||
}
|
||||
|
||||
with(multiplatformExtension) {
|
||||
val target = createExternalKotlinTarget<FakeTarget> { defaults() }
|
||||
target.createCompilation<FakeCompilation> { defaults(this@with) }
|
||||
target.createCompilation<FakeCompilation> { defaults(this@with, "test") }
|
||||
|
||||
target.compilerOptions {
|
||||
javaParameters.set(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
assertEquals(false, project.kotlinJvmTask("compileKotlinFake").compilerOptions.javaParameters.get())
|
||||
assertEquals(true, project.kotlinJvmTask("compileTestKotlinFake").compilerOptions.javaParameters.get())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun topLevelOptions() {
|
||||
val project = buildProjectWithMPP()
|
||||
project.runLifecycleAwareTest {
|
||||
with(multiplatformExtension) {
|
||||
compilerOptions {
|
||||
progressiveMode.set(true)
|
||||
}
|
||||
|
||||
jvm()
|
||||
js()
|
||||
iosArm64()
|
||||
linuxX64()
|
||||
}
|
||||
}
|
||||
|
||||
assertEquals(true, project.kotlinCommonTask("compileKotlinMetadata").compilerOptions.progressiveMode.get())
|
||||
assertEquals(true, project.kotlinCommonTask("compileNativeMainKotlinMetadata").compilerOptions.progressiveMode.get())
|
||||
assertEquals(true, project.kotlinCommonTask("compileCommonMainKotlinMetadata").compilerOptions.progressiveMode.get())
|
||||
assertEquals(true, project.kotlinJvmTask("compileKotlinJvm").compilerOptions.progressiveMode.get())
|
||||
assertEquals(true, project.kotlinJvmTask("compileTestKotlinJvm").compilerOptions.progressiveMode.get())
|
||||
assertEquals(true, project.kotlinJsTask("compileKotlinJs").compilerOptions.progressiveMode.get())
|
||||
assertEquals(true, project.kotlinJsTask("compileTestKotlinJs").compilerOptions.progressiveMode.get())
|
||||
assertEquals(true, project.kotlinNativeTask("compileKotlinLinuxX64").compilerOptions.progressiveMode.get())
|
||||
assertEquals(true, project.kotlinNativeTask("compileTestKotlinLinuxX64").compilerOptions.progressiveMode.get())
|
||||
assertEquals(true, project.kotlinNativeTask("compileKotlinIosArm64").compilerOptions.progressiveMode.get())
|
||||
assertEquals(true, project.kotlinNativeTask("compileTestKotlinIosArm64").compilerOptions.progressiveMode.get())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testTargetDslOverridesTopLevelDsl() {
|
||||
val project = buildProjectWithMPP()
|
||||
project.runLifecycleAwareTest {
|
||||
with(multiplatformExtension) {
|
||||
jvm {
|
||||
compilerOptions {
|
||||
languageVersion.set(KotlinVersion.KOTLIN_1_8)
|
||||
}
|
||||
}
|
||||
|
||||
compilerOptions {
|
||||
languageVersion.set(KotlinVersion.KOTLIN_2_0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
assertEquals(KotlinVersion.KOTLIN_1_8, project.kotlinJvmTask("compileKotlinJvm").compilerOptions.languageVersion.orNull)
|
||||
assertEquals(KotlinVersion.KOTLIN_1_8, project.kotlinJvmTask("compileTestKotlinJvm").compilerOptions.languageVersion.orNull)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testTaskDslOverrideTopLevelDsl() {
|
||||
val project = buildProjectWithMPP()
|
||||
project.runLifecycleAwareTest {
|
||||
tasks.withType<KotlinJvmCompileTask>().configureEach {
|
||||
if (it.name == "compileKotlinJvm") {
|
||||
it.compilerOptions.languageVersion.set(KotlinVersion.KOTLIN_1_8)
|
||||
}
|
||||
}
|
||||
|
||||
with(multiplatformExtension) {
|
||||
jvm()
|
||||
|
||||
compilerOptions {
|
||||
languageVersion.set(KotlinVersion.KOTLIN_2_0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
assertEquals(KotlinVersion.KOTLIN_1_8, project.kotlinJvmTask("compileKotlinJvm").compilerOptions.languageVersion.orNull)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testTopLevelDslAlsoConfiguresSharedSourceSets() {
|
||||
val project = buildProjectWithMPP()
|
||||
project.runLifecycleAwareTest {
|
||||
with(multiplatformExtension) {
|
||||
jvm()
|
||||
js()
|
||||
|
||||
compilerOptions {
|
||||
languageVersion.set(KotlinVersion.KOTLIN_2_0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
assertEquals("2.0", project.multiplatformExtension.sourceSets.getByName("commonTest").languageSettings.languageVersion)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testJvmModuleNameInMppIsConfigured() {
|
||||
val project = buildProjectWithMPP()
|
||||
project.runLifecycleAwareTest {
|
||||
with(multiplatformExtension) {
|
||||
jvm {
|
||||
compilerOptions.moduleName.set("my-custom-module-name")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
assertEquals("my-custom-module-name", project.kotlinJvmTask("compileKotlinJvm").compilerOptions.moduleName.orNull)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testJsOptionsIsConfigured() {
|
||||
val project = buildProjectWithMPP()
|
||||
project.runLifecycleAwareTest {
|
||||
with(multiplatformExtension) {
|
||||
js {
|
||||
compilerOptions {
|
||||
moduleName.set("js-module-name")
|
||||
freeCompilerArgs.add("-Xstrict-implicit-export-types")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val kotlinJsCompileTask = project.kotlinJsTask("compileKotlinJs")
|
||||
assertEquals("js-module-name", kotlinJsCompileTask.compilerOptions.moduleName.orNull)
|
||||
assertTrue(
|
||||
kotlinJsCompileTask
|
||||
.compilerOptions
|
||||
.freeCompilerArgs.get()
|
||||
.contains("-Xstrict-implicit-export-types")
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testJsBrowserConfigDoesNotOverrideFreeCompilerArgsFromTarget() {
|
||||
val project = buildProjectWithMPP()
|
||||
project.runLifecycleAwareTest {
|
||||
with(multiplatformExtension) {
|
||||
js {
|
||||
binaries.executable()
|
||||
browser()
|
||||
compilerOptions {
|
||||
freeCompilerArgs.addAll("-Xstrict-implicit-export-types", "-Xexplicit-api=warning")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val kotlinJsCompileTask = project.kotlinJsTask("compileKotlinJs")
|
||||
assertTrue(
|
||||
(kotlinJsCompileTask as Kotlin2JsCompile)
|
||||
.enhancedFreeCompilerArgs.get()
|
||||
.containsAll(listOf("-Xstrict-implicit-export-types", "-Xexplicit-api=warning"))
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testJsLinkTaskAreAlsoConfiguredWithOptionsFromDSL() {
|
||||
val project = buildProjectWithMPP()
|
||||
project.runLifecycleAwareTest {
|
||||
with(multiplatformExtension) {
|
||||
js {
|
||||
nodejs()
|
||||
binaries.library()
|
||||
compilerOptions {
|
||||
moduleName.set("my-custom-module")
|
||||
languageVersion.set(KotlinVersion.KOTLIN_1_8)
|
||||
apiVersion.set(KotlinVersion.KOTLIN_1_8)
|
||||
moduleKind.set(JsModuleKind.MODULE_PLAIN)
|
||||
freeCompilerArgs.addAll("-Xstrict-implicit-export-types", "-Xexplicit-api=warning")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val jsTasks = listOf(
|
||||
project.kotlinJsTask("compileKotlinJs"),
|
||||
project.kotlinJsTask("compileDevelopmentLibraryKotlinJs"),
|
||||
project.kotlinJsTask("compileProductionLibraryKotlinJs")
|
||||
)
|
||||
jsTasks.forEach { jsTask ->
|
||||
if (jsTask.name == "compileKotlinJs") {
|
||||
// JS IR has different module name from 'compileKotlinJs'
|
||||
assertEquals("my-custom-module", jsTask.compilerOptions.moduleName.orNull)
|
||||
}
|
||||
assertEquals(KotlinVersion.KOTLIN_1_8, jsTask.compilerOptions.languageVersion.orNull)
|
||||
assertEquals(KotlinVersion.KOTLIN_1_8, jsTask.compilerOptions.apiVersion.orNull)
|
||||
assertEquals(JsModuleKind.MODULE_PLAIN, jsTask.compilerOptions.moduleKind.orNull)
|
||||
assertTrue(
|
||||
jsTask.compilerOptions.freeCompilerArgs.get().containsAll(
|
||||
listOf("-Xstrict-implicit-export-types", "-Xexplicit-api=warning")
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun Project.kotlinNativeTask(name: String): KotlinCompilationTask<KotlinNativeCompilerOptions> = tasks
|
||||
.named<KotlinCompilationTask<KotlinNativeCompilerOptions>>(name)
|
||||
.get()
|
||||
|
||||
private fun Project.kotlinJsTask(name: String): KotlinCompilationTask<KotlinJsCompilerOptions> = tasks
|
||||
.named<KotlinCompilationTask<KotlinJsCompilerOptions>>(name)
|
||||
.get()
|
||||
|
||||
private fun Project.kotlinJvmTask(name: String): KotlinCompilationTask<KotlinJvmCompilerOptions> = tasks
|
||||
.named<KotlinCompilationTask<KotlinJvmCompilerOptions>>(name)
|
||||
.get()
|
||||
|
||||
private fun Project.kotlinCommonTask(name: String): KotlinCompilationTask<KotlinCommonCompilerOptions> = tasks
|
||||
.named<KotlinCompilationTask<KotlinCommonCompilerOptions>>(name)
|
||||
.get()
|
||||
}
|
||||
-7
@@ -25,13 +25,6 @@ class FakeTarget(delegate: Delegate) : DecoratedExternalKotlinTarget(delegate) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
override val compilations: NamedDomainObjectContainer<FakeCompilation>
|
||||
get() = super.compilations as NamedDomainObjectContainer<FakeCompilation>
|
||||
|
||||
override val compilerOptions: KotlinJvmCompilerOptions
|
||||
get() = super.compilerOptions as KotlinJvmCompilerOptions
|
||||
|
||||
fun compilerOptions(configure: KotlinJvmCompilerOptions.() -> Unit) {
|
||||
configure(compilerOptions)
|
||||
}
|
||||
}
|
||||
|
||||
fun ExternalKotlinTargetDescriptorBuilder<FakeTarget>.defaults() {
|
||||
|
||||
Reference in New Issue
Block a user