[Gradle] Add compiler options DSL for Kotlin targets
Restore compiler options DSL for all Kotlin targets. 'KotlinTarget' interface does not provide any common way to configuring options - this is the responsibility of related plugin extensions. From the hierarchical standpoint of view target DSL overrides options configured in the extension. ^KT-57292 In Progress
This commit is contained in:
committed by
Space Team
parent
e527781772
commit
facc9cdb58
@@ -1159,8 +1159,6 @@ public final class org/jetbrains/kotlin/gradle/plugin/KotlinSourceSetTree$Compan
|
|||||||
public abstract interface class org/jetbrains/kotlin/gradle/plugin/KotlinTarget : org/gradle/api/Named, org/gradle/api/attributes/HasAttributes, org/jetbrains/kotlin/gradle/plugin/HasProject, org/jetbrains/kotlin/tooling/core/HasMutableExtras {
|
public abstract interface class org/jetbrains/kotlin/gradle/plugin/KotlinTarget : org/gradle/api/Named, org/gradle/api/attributes/HasAttributes, org/jetbrains/kotlin/gradle/plugin/HasProject, org/jetbrains/kotlin/tooling/core/HasMutableExtras {
|
||||||
public abstract fun attributes (Lkotlin/jvm/functions/Function1;)V
|
public abstract fun attributes (Lkotlin/jvm/functions/Function1;)V
|
||||||
public abstract fun attributes (Lorg/gradle/api/Action;)V
|
public abstract fun attributes (Lorg/gradle/api/Action;)V
|
||||||
public abstract fun compilerOptions (Lkotlin/jvm/functions/Function1;)V
|
|
||||||
public abstract fun compilerOptions (Lorg/gradle/api/Action;)V
|
|
||||||
public abstract fun getApiElementsConfigurationName ()Ljava/lang/String;
|
public abstract fun getApiElementsConfigurationName ()Ljava/lang/String;
|
||||||
public abstract fun getArtifactsTaskName ()Ljava/lang/String;
|
public abstract fun getArtifactsTaskName ()Ljava/lang/String;
|
||||||
public abstract fun getCompilations ()Lorg/gradle/api/NamedDomainObjectContainer;
|
public abstract fun getCompilations ()Lorg/gradle/api/NamedDomainObjectContainer;
|
||||||
@@ -1184,8 +1182,6 @@ public abstract interface class org/jetbrains/kotlin/gradle/plugin/KotlinTarget
|
|||||||
public final class org/jetbrains/kotlin/gradle/plugin/KotlinTarget$DefaultImpls {
|
public final class org/jetbrains/kotlin/gradle/plugin/KotlinTarget$DefaultImpls {
|
||||||
public static fun attributes (Lorg/jetbrains/kotlin/gradle/plugin/KotlinTarget;Lkotlin/jvm/functions/Function1;)V
|
public static fun attributes (Lorg/jetbrains/kotlin/gradle/plugin/KotlinTarget;Lkotlin/jvm/functions/Function1;)V
|
||||||
public static fun attributes (Lorg/jetbrains/kotlin/gradle/plugin/KotlinTarget;Lorg/gradle/api/Action;)V
|
public static fun attributes (Lorg/jetbrains/kotlin/gradle/plugin/KotlinTarget;Lorg/gradle/api/Action;)V
|
||||||
public static fun compilerOptions (Lorg/jetbrains/kotlin/gradle/plugin/KotlinTarget;Lkotlin/jvm/functions/Function1;)V
|
|
||||||
public static fun compilerOptions (Lorg/jetbrains/kotlin/gradle/plugin/KotlinTarget;Lorg/gradle/api/Action;)V
|
|
||||||
public static fun getDisambiguationClassifier (Lorg/jetbrains/kotlin/gradle/plugin/KotlinTarget;)Ljava/lang/String;
|
public static fun getDisambiguationClassifier (Lorg/jetbrains/kotlin/gradle/plugin/KotlinTarget;)Ljava/lang/String;
|
||||||
public static fun getName (Lorg/jetbrains/kotlin/gradle/plugin/KotlinTarget;)Ljava/lang/String;
|
public static fun getName (Lorg/jetbrains/kotlin/gradle/plugin/KotlinTarget;)Ljava/lang/String;
|
||||||
public static fun mavenPublication (Lorg/jetbrains/kotlin/gradle/plugin/KotlinTarget;Lkotlin/jvm/functions/Function1;)V
|
public static fun mavenPublication (Lorg/jetbrains/kotlin/gradle/plugin/KotlinTarget;Lkotlin/jvm/functions/Function1;)V
|
||||||
@@ -1244,8 +1240,6 @@ public final class org/jetbrains/kotlin/gradle/plugin/KotlinTargetWithTests$Comp
|
|||||||
public final class org/jetbrains/kotlin/gradle/plugin/KotlinTargetWithTests$DefaultImpls {
|
public final class org/jetbrains/kotlin/gradle/plugin/KotlinTargetWithTests$DefaultImpls {
|
||||||
public static fun attributes (Lorg/jetbrains/kotlin/gradle/plugin/KotlinTargetWithTests;Lkotlin/jvm/functions/Function1;)V
|
public static fun attributes (Lorg/jetbrains/kotlin/gradle/plugin/KotlinTargetWithTests;Lkotlin/jvm/functions/Function1;)V
|
||||||
public static fun attributes (Lorg/jetbrains/kotlin/gradle/plugin/KotlinTargetWithTests;Lorg/gradle/api/Action;)V
|
public static fun attributes (Lorg/jetbrains/kotlin/gradle/plugin/KotlinTargetWithTests;Lorg/gradle/api/Action;)V
|
||||||
public static fun compilerOptions (Lorg/jetbrains/kotlin/gradle/plugin/KotlinTargetWithTests;Lkotlin/jvm/functions/Function1;)V
|
|
||||||
public static fun compilerOptions (Lorg/jetbrains/kotlin/gradle/plugin/KotlinTargetWithTests;Lorg/gradle/api/Action;)V
|
|
||||||
public static fun getDisambiguationClassifier (Lorg/jetbrains/kotlin/gradle/plugin/KotlinTargetWithTests;)Ljava/lang/String;
|
public static fun getDisambiguationClassifier (Lorg/jetbrains/kotlin/gradle/plugin/KotlinTargetWithTests;)Ljava/lang/String;
|
||||||
public static fun getName (Lorg/jetbrains/kotlin/gradle/plugin/KotlinTargetWithTests;)Ljava/lang/String;
|
public static fun getName (Lorg/jetbrains/kotlin/gradle/plugin/KotlinTargetWithTests;)Ljava/lang/String;
|
||||||
public static fun mavenPublication (Lorg/jetbrains/kotlin/gradle/plugin/KotlinTargetWithTests;Lkotlin/jvm/functions/Function1;)V
|
public static fun mavenPublication (Lorg/jetbrains/kotlin/gradle/plugin/KotlinTargetWithTests;Lkotlin/jvm/functions/Function1;)V
|
||||||
|
|||||||
-18
@@ -3,8 +3,6 @@
|
|||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@file:Suppress("TYPEALIAS_EXPANSION_DEPRECATION")
|
|
||||||
|
|
||||||
package org.jetbrains.kotlin.gradle.plugin
|
package org.jetbrains.kotlin.gradle.plugin
|
||||||
|
|
||||||
import org.gradle.api.Action
|
import org.gradle.api.Action
|
||||||
@@ -17,7 +15,6 @@ import org.gradle.api.publish.maven.MavenPublication
|
|||||||
import org.jetbrains.kotlin.gradle.PRESETS_API_IS_DEPRECATED_MESSAGE
|
import org.jetbrains.kotlin.gradle.PRESETS_API_IS_DEPRECATED_MESSAGE
|
||||||
import org.jetbrains.kotlin.gradle.DeprecatedTargetPresetApi
|
import org.jetbrains.kotlin.gradle.DeprecatedTargetPresetApi
|
||||||
import org.jetbrains.kotlin.gradle.InternalKotlinGradlePluginApi
|
import org.jetbrains.kotlin.gradle.InternalKotlinGradlePluginApi
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonCompilerOptions
|
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonOptionsDeprecated
|
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonOptionsDeprecated
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinGradlePluginDsl
|
import org.jetbrains.kotlin.gradle.dsl.KotlinGradlePluginDsl
|
||||||
import org.jetbrains.kotlin.tooling.core.HasMutableExtras
|
import org.jetbrains.kotlin.tooling.core.HasMutableExtras
|
||||||
@@ -66,21 +63,6 @@ interface KotlinTarget : Named, HasAttributes, HasProject, HasMutableExtras {
|
|||||||
|
|
||||||
override fun getName(): String = targetName
|
override fun getName(): String = targetName
|
||||||
|
|
||||||
@Deprecated(
|
|
||||||
"Kotlin target level compiler options DSL is not available in this release!",
|
|
||||||
level = DeprecationLevel.ERROR
|
|
||||||
)
|
|
||||||
fun compilerOptions(configure: KotlinCommonCompilerOptions.() -> Unit) {
|
|
||||||
throw UnsupportedOperationException("Kotlin target level compiler options DSL is not available in this release!")
|
|
||||||
}
|
|
||||||
@Deprecated(
|
|
||||||
"Kotlin target level compiler options DSL is not available in this release!",
|
|
||||||
level = DeprecationLevel.ERROR
|
|
||||||
)
|
|
||||||
fun compilerOptions(configure: Action<KotlinCommonCompilerOptions>) {
|
|
||||||
throw UnsupportedOperationException("Kotlin target level compiler options DSL is not available in this release!")
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated(
|
@Deprecated(
|
||||||
"Accessing 'sourceSets' container on the Kotlin target level DSL is deprecated. " +
|
"Accessing 'sourceSets' container on the Kotlin target level DSL is deprecated. " +
|
||||||
"Consider configuring 'sourceSets' on the Kotlin extension level.",
|
"Consider configuring 'sourceSets' on the Kotlin extension level.",
|
||||||
|
|||||||
+1
-7
@@ -8,7 +8,6 @@ package org.jetbrains.kotlin.gradle
|
|||||||
import org.gradle.api.logging.LogLevel
|
import org.gradle.api.logging.LogLevel
|
||||||
import org.gradle.util.GradleVersion
|
import org.gradle.util.GradleVersion
|
||||||
import org.jetbrains.kotlin.gradle.testbase.*
|
import org.jetbrains.kotlin.gradle.testbase.*
|
||||||
import org.junit.jupiter.api.Disabled
|
|
||||||
import org.junit.jupiter.api.DisplayName
|
import org.junit.jupiter.api.DisplayName
|
||||||
import kotlin.io.path.appendText
|
import kotlin.io.path.appendText
|
||||||
|
|
||||||
@@ -45,7 +44,6 @@ class CompilerOptionsProjectIT : KGPBaseTest() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Disabled("DSL was demoted to 'internal'; Design is planned for 2.0")
|
|
||||||
@GradleTest
|
@GradleTest
|
||||||
@DisplayName("Jvm project target compiler options DSL override project level options")
|
@DisplayName("Jvm project target compiler options DSL override project level options")
|
||||||
@JvmGradlePluginTests
|
@JvmGradlePluginTests
|
||||||
@@ -241,7 +239,6 @@ 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")
|
@DisplayName("Android target compiler options override project level compiler options")
|
||||||
@AndroidGradlePluginTests
|
@AndroidGradlePluginTests
|
||||||
@GradleAndroidTest
|
@GradleAndroidTest
|
||||||
@@ -388,7 +385,6 @@ class CompilerOptionsProjectIT : KGPBaseTest() {
|
|||||||
@DisplayName("KT-57959: should be possible to configure module name in MPP/android")
|
@DisplayName("KT-57959: should be possible to configure module name in MPP/android")
|
||||||
@GradleAndroidTest
|
@GradleAndroidTest
|
||||||
@AndroidGradlePluginTests
|
@AndroidGradlePluginTests
|
||||||
@Disabled("DSL was demoted to 'internal'; Design is planned for 2.0")
|
|
||||||
fun mppAndroidModuleName(
|
fun mppAndroidModuleName(
|
||||||
gradleVersion: GradleVersion,
|
gradleVersion: GradleVersion,
|
||||||
agpVersion: String,
|
agpVersion: String,
|
||||||
@@ -426,7 +422,6 @@ class CompilerOptionsProjectIT : KGPBaseTest() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Disabled("DSL was demoted to 'internal'; Design is planned for 2.0")
|
|
||||||
@GradleTest
|
@GradleTest
|
||||||
@DisplayName("Multiplatform compiler option DSL hierarchy")
|
@DisplayName("Multiplatform compiler option DSL hierarchy")
|
||||||
@JvmGradlePluginTests
|
@JvmGradlePluginTests
|
||||||
@@ -503,7 +498,7 @@ class CompilerOptionsProjectIT : KGPBaseTest() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
build(":compileKotlinLinuxX64") {
|
build(":compileKotlinLinuxX64") {
|
||||||
extractNativeTasksCommandLineArgumentsFromOutput(":compileKotlinLinuxX64", logLevel = LogLevel.DEBUG) {
|
extractNativeTasksCommandLineArgumentsFromOutput(":compileKotlinLinuxX64") {
|
||||||
assertCommandLineArgumentsContain("-language-version", "1.7")
|
assertCommandLineArgumentsContain("-language-version", "1.7")
|
||||||
assertCommandLineArgumentsContain("-api-version", "1.7")
|
assertCommandLineArgumentsContain("-api-version", "1.7")
|
||||||
assertCommandLineArgumentsContain("-progressive")
|
assertCommandLineArgumentsContain("-progressive")
|
||||||
@@ -513,7 +508,6 @@ class CompilerOptionsProjectIT : KGPBaseTest() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Disabled("DSL was demoted to 'internal'; Design is planned for 2.0")
|
|
||||||
@DisplayName("KT-61303: Multiplatform/Android module name is changed")
|
@DisplayName("KT-61303: Multiplatform/Android module name is changed")
|
||||||
@AndroidGradlePluginTests
|
@AndroidGradlePluginTests
|
||||||
@GradleAndroidTest
|
@GradleAndroidTest
|
||||||
|
|||||||
+8
-2
@@ -5,10 +5,10 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.gradle.android
|
package org.jetbrains.kotlin.gradle.android
|
||||||
|
|
||||||
import org.gradle.api.Action
|
|
||||||
import org.gradle.api.NamedDomainObjectContainer
|
import org.gradle.api.NamedDomainObjectContainer
|
||||||
import org.gradle.kotlin.dsl.getByType
|
import org.gradle.kotlin.dsl.getByType
|
||||||
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
|
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
|
||||||
|
import org.jetbrains.kotlin.gradle.dsl.HasConfigurableCompilerOptions
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompilerOptions
|
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompilerOptions
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.external.DecoratedExternalKotlinTarget
|
import org.jetbrains.kotlin.gradle.plugin.mpp.external.DecoratedExternalKotlinTarget
|
||||||
@@ -17,13 +17,19 @@ data class PrototypeAndroidDsl(
|
|||||||
var compileSdk: Int
|
var compileSdk: Int
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@OptIn(ExperimentalKotlinGradlePluginApi::class)
|
||||||
class PrototypeAndroidTarget(
|
class PrototypeAndroidTarget(
|
||||||
delegate: Delegate,
|
delegate: Delegate,
|
||||||
val androidDsl: PrototypeAndroidDsl
|
val androidDsl: PrototypeAndroidDsl
|
||||||
) : DecoratedExternalKotlinTarget(delegate) {
|
) : DecoratedExternalKotlinTarget(delegate),
|
||||||
|
HasConfigurableCompilerOptions<KotlinJvmCompilerOptions> {
|
||||||
internal val kotlin = super.project.extensions.getByType<KotlinMultiplatformExtension>()
|
internal val kotlin = super.project.extensions.getByType<KotlinMultiplatformExtension>()
|
||||||
|
|
||||||
@Suppress("unchecked_cast")
|
@Suppress("unchecked_cast")
|
||||||
override val compilations: NamedDomainObjectContainer<PrototypeAndroidCompilation>
|
override val compilations: NamedDomainObjectContainer<PrototypeAndroidCompilation>
|
||||||
get() = super.compilations as NamedDomainObjectContainer<PrototypeAndroidCompilation>
|
get() = super.compilations as NamedDomainObjectContainer<PrototypeAndroidCompilation>
|
||||||
|
|
||||||
|
@ExperimentalKotlinGradlePluginApi
|
||||||
|
override val compilerOptions: KotlinJvmCompilerOptions
|
||||||
|
get() = super.compilerOptions as KotlinJvmCompilerOptions
|
||||||
}
|
}
|
||||||
@@ -743,18 +743,17 @@ public abstract class org/jetbrains/kotlin/gradle/plugin/mpp/external/DecoratedE
|
|||||||
public fun <init> (Lorg/jetbrains/kotlin/gradle/plugin/mpp/external/DecoratedExternalKotlinCompilation$Delegate;)V
|
public fun <init> (Lorg/jetbrains/kotlin/gradle/plugin/mpp/external/DecoratedExternalKotlinCompilation$Delegate;)V
|
||||||
}
|
}
|
||||||
|
|
||||||
public class org/jetbrains/kotlin/gradle/plugin/mpp/external/DecoratedExternalKotlinTarget : org/jetbrains/kotlin/gradle/plugin/mpp/InternalKotlinTarget {
|
public abstract class org/jetbrains/kotlin/gradle/plugin/mpp/external/DecoratedExternalKotlinTarget : org/jetbrains/kotlin/gradle/plugin/mpp/InternalKotlinTarget {
|
||||||
public fun <init> (Lorg/jetbrains/kotlin/gradle/plugin/mpp/external/DecoratedExternalKotlinTarget$Delegate;)V
|
public fun <init> (Lorg/jetbrains/kotlin/gradle/plugin/mpp/external/DecoratedExternalKotlinTarget$Delegate;)V
|
||||||
public fun attributes (Lkotlin/jvm/functions/Function1;)V
|
public fun attributes (Lkotlin/jvm/functions/Function1;)V
|
||||||
public fun attributes (Lorg/gradle/api/Action;)V
|
public fun attributes (Lorg/gradle/api/Action;)V
|
||||||
public fun compilerOptions (Lkotlin/jvm/functions/Function1;)V
|
|
||||||
public fun compilerOptions (Lorg/gradle/api/Action;)V
|
|
||||||
public final fun getApiElementsConfiguration ()Lorg/gradle/api/artifacts/Configuration;
|
public final fun getApiElementsConfiguration ()Lorg/gradle/api/artifacts/Configuration;
|
||||||
public fun getApiElementsConfigurationName ()Ljava/lang/String;
|
public fun getApiElementsConfigurationName ()Ljava/lang/String;
|
||||||
public final fun getApiElementsPublishedConfiguration ()Lorg/gradle/api/artifacts/Configuration;
|
public final fun getApiElementsPublishedConfiguration ()Lorg/gradle/api/artifacts/Configuration;
|
||||||
public fun getArtifactsTaskName ()Ljava/lang/String;
|
public fun getArtifactsTaskName ()Ljava/lang/String;
|
||||||
public fun getAttributes ()Lorg/gradle/api/attributes/AttributeContainer;
|
public fun getAttributes ()Lorg/gradle/api/attributes/AttributeContainer;
|
||||||
public fun getCompilations ()Lorg/gradle/api/NamedDomainObjectContainer;
|
public fun getCompilations ()Lorg/gradle/api/NamedDomainObjectContainer;
|
||||||
|
public fun getCompilerOptions ()Lorg/jetbrains/kotlin/gradle/dsl/KotlinCommonCompilerOptions;
|
||||||
public fun getComponents ()Ljava/util/Set;
|
public fun getComponents ()Ljava/util/Set;
|
||||||
public fun getDisambiguationClassifier ()Ljava/lang/String;
|
public fun getDisambiguationClassifier ()Ljava/lang/String;
|
||||||
public synthetic fun getExtras ()Lorg/jetbrains/kotlin/tooling/core/Extras;
|
public synthetic fun getExtras ()Lorg/jetbrains/kotlin/tooling/core/Extras;
|
||||||
|
|||||||
+12
-5
@@ -5,15 +5,14 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.gradle.internal
|
package org.jetbrains.kotlin.gradle.internal
|
||||||
|
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonCompilerOptions
|
import org.jetbrains.kotlin.gradle.dsl.*
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonCompilerOptionsDefault
|
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonCompilerOptionsDefault
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonCompilerOptionsHelper
|
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonCompilerOptionsHelper
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
import org.jetbrains.kotlin.gradle.plugin.*
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinPluginLifecycle
|
import org.jetbrains.kotlin.gradle.plugin.KotlinPluginLifecycle
|
||||||
import org.jetbrains.kotlin.gradle.plugin.await
|
import org.jetbrains.kotlin.gradle.plugin.await
|
||||||
import org.jetbrains.kotlin.gradle.plugin.launch
|
import org.jetbrains.kotlin.gradle.plugin.launch
|
||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.compilerOptions
|
import org.jetbrains.kotlin.gradle.plugin.mpp.external.DecoratedExternalKotlinTarget
|
||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.internal
|
|
||||||
import org.jetbrains.kotlin.gradle.plugin.sources.DefaultLanguageSettingsBuilder
|
import org.jetbrains.kotlin.gradle.plugin.sources.DefaultLanguageSettingsBuilder
|
||||||
import org.jetbrains.kotlin.gradle.utils.newInstance
|
import org.jetbrains.kotlin.gradle.utils.newInstance
|
||||||
|
|
||||||
@@ -23,7 +22,7 @@ internal fun KotlinMultiplatformExtension.syncCommonOptions(
|
|||||||
targets.configureEach { target ->
|
targets.configureEach { target ->
|
||||||
KotlinCommonCompilerOptionsHelper.syncOptionsAsConvention(
|
KotlinCommonCompilerOptionsHelper.syncOptionsAsConvention(
|
||||||
extensionCompilerOptions,
|
extensionCompilerOptions,
|
||||||
target.internal.compilerOptions
|
target.targetCompilerOptions
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,3 +44,11 @@ internal fun KotlinMultiplatformExtension.syncCommonOptions(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal val KotlinTarget.targetCompilerOptions: KotlinCommonCompilerOptions
|
||||||
|
get() = when (this) {
|
||||||
|
is HasConfigurableCompilerOptions<*> -> compilerOptions
|
||||||
|
// Required for external targets that do not implement 'HasConfigurableCompilerOptions' interface
|
||||||
|
is DecoratedExternalKotlinTarget -> delegate.compilerOptions
|
||||||
|
else -> throw IllegalStateException("'KotlinTarget' type ${this.javaClass} does not allow to configure compiler options!")
|
||||||
|
}
|
||||||
|
|||||||
-2
@@ -37,8 +37,6 @@ abstract class AbstractKotlinTarget(
|
|||||||
|
|
||||||
override fun getAttributes(): AttributeContainer = attributeContainer
|
override fun getAttributes(): AttributeContainer = attributeContainer
|
||||||
|
|
||||||
internal abstract val compilerOptions: KotlinCommonCompilerOptions
|
|
||||||
|
|
||||||
@Deprecated("Scheduled for removal with Kotlin 2.2")
|
@Deprecated("Scheduled for removal with Kotlin 2.2")
|
||||||
override var useDisambiguationClassifierAsSourceSetNamePrefix: Boolean = true
|
override var useDisambiguationClassifierAsSourceSetNamePrefix: Boolean = true
|
||||||
internal set
|
internal set
|
||||||
|
|||||||
-11
@@ -10,13 +10,10 @@ import org.gradle.api.NamedDomainObjectContainer
|
|||||||
import org.gradle.api.publish.maven.MavenPublication
|
import org.gradle.api.publish.maven.MavenPublication
|
||||||
import org.gradle.jvm.toolchain.JavaToolchainSpec
|
import org.gradle.jvm.toolchain.JavaToolchainSpec
|
||||||
import org.jetbrains.kotlin.gradle.InternalKotlinGradlePluginApi
|
import org.jetbrains.kotlin.gradle.InternalKotlinGradlePluginApi
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonCompilerOptions
|
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension
|
import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension
|
||||||
import org.jetbrains.kotlin.gradle.plugin.*
|
import org.jetbrains.kotlin.gradle.plugin.*
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinPluginLifecycle
|
import org.jetbrains.kotlin.gradle.plugin.KotlinPluginLifecycle
|
||||||
import org.jetbrains.kotlin.gradle.plugin.await
|
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.extrasStoredFuture
|
import org.jetbrains.kotlin.gradle.utils.extrasStoredFuture
|
||||||
import org.jetbrains.kotlin.gradle.utils.getByType
|
import org.jetbrains.kotlin.gradle.utils.getByType
|
||||||
import org.jetbrains.kotlin.tooling.core.HasMutableExtras
|
import org.jetbrains.kotlin.tooling.core.HasMutableExtras
|
||||||
@@ -53,14 +50,6 @@ internal val KotlinTarget.internal: InternalKotlinTarget
|
|||||||
"KotlinTarget($name) ${this::class} does not implement ${InternalKotlinTarget::class}"
|
"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 extrasStoredFuture {
|
internal val InternalKotlinTarget.isSourcesPublishableFuture by extrasStoredFuture {
|
||||||
KotlinPluginLifecycle.Stage.AfterFinaliseDsl.await()
|
KotlinPluginLifecycle.Stage.AfterFinaliseDsl.await()
|
||||||
isSourcesPublishable
|
isSourcesPublishable
|
||||||
|
|||||||
+4
-3
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.gradle.plugin.mpp
|
|||||||
|
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
|
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
|
||||||
|
import org.jetbrains.kotlin.gradle.dsl.HasConfigurableCompilerOptions
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonCompilerOptions
|
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonCompilerOptions
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonCompilerOptionsDefault
|
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonCompilerOptionsDefault
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation
|
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation
|
||||||
@@ -19,7 +20,8 @@ import javax.inject.Inject
|
|||||||
|
|
||||||
abstract class KotlinMetadataTarget @Inject constructor(
|
abstract class KotlinMetadataTarget @Inject constructor(
|
||||||
project: Project,
|
project: Project,
|
||||||
) : KotlinOnlyTarget<KotlinCompilation<*>>(project, KotlinPlatformType.common) {
|
) : KotlinOnlyTarget<KotlinCompilation<*>>(project, KotlinPlatformType.common),
|
||||||
|
HasConfigurableCompilerOptions<KotlinCommonCompilerOptions> {
|
||||||
|
|
||||||
override val artifactsTaskName: String
|
override val artifactsTaskName: String
|
||||||
// The IDE import looks at this task name to determine the artifact and register the path to the artifact;
|
// The IDE import looks at this task name to determine the artifact and register the path to the artifact;
|
||||||
@@ -37,9 +39,8 @@ abstract class KotlinMetadataTarget @Inject constructor(
|
|||||||
emptySet()
|
emptySet()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("RedundantVisibilityModifier")
|
|
||||||
@ExperimentalKotlinGradlePluginApi
|
@ExperimentalKotlinGradlePluginApi
|
||||||
internal override val compilerOptions: KotlinCommonCompilerOptions = project.objects
|
override val compilerOptions: KotlinCommonCompilerOptions = project.objects
|
||||||
.newInstance<KotlinCommonCompilerOptionsDefault>()
|
.newInstance<KotlinCommonCompilerOptionsDefault>()
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|||||||
+3
-2
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.gradle.plugin.mpp.compilationImpl
|
|||||||
import org.jetbrains.kotlin.gradle.dsl.*
|
import org.jetbrains.kotlin.gradle.dsl.*
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompilerOptionsHelper
|
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompilerOptionsHelper
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinNativeCompilerOptionsHelper
|
import org.jetbrains.kotlin.gradle.dsl.KotlinNativeCompilerOptionsHelper
|
||||||
|
import org.jetbrains.kotlin.gradle.internal.targetCompilerOptions
|
||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.*
|
import org.jetbrains.kotlin.gradle.plugin.mpp.*
|
||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.compilationImpl.factory.KotlinCompilationImplFactory
|
import org.jetbrains.kotlin.gradle.plugin.mpp.compilationImpl.factory.KotlinCompilationImplFactory
|
||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.moduleNameForCompilation
|
import org.jetbrains.kotlin.gradle.plugin.mpp.moduleNameForCompilation
|
||||||
@@ -90,13 +91,13 @@ internal object KotlinCompilationCompilerOptionsFromTargetConfigurator : KotlinC
|
|||||||
commonCompilerOptions: KotlinCommonCompilerOptions
|
commonCompilerOptions: KotlinCommonCompilerOptions
|
||||||
) {
|
) {
|
||||||
KotlinCommonCompilerOptionsHelper.syncOptionsAsConvention(
|
KotlinCommonCompilerOptionsHelper.syncOptionsAsConvention(
|
||||||
target.internal.compilerOptions,
|
target.targetCompilerOptions,
|
||||||
commonCompilerOptions
|
commonCompilerOptions
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private inline fun <reified T : KotlinCommonCompilerOptions> DecoratedKotlinCompilation<*>.requireTargetCompilerOptionsType(): T {
|
private inline fun <reified T : KotlinCommonCompilerOptions> DecoratedKotlinCompilation<*>.requireTargetCompilerOptionsType(): T {
|
||||||
val targetCompilerOptions = compilation.target.internal.compilerOptions
|
val targetCompilerOptions = compilation.target.targetCompilerOptions
|
||||||
require(targetCompilerOptions is T) {
|
require(targetCompilerOptions is T) {
|
||||||
"${compilation.compilationName} target ${compilation.target.name}:${compilation.target::class.qualifiedName} has incorrect 'compilerOptions' type " +
|
"${compilation.compilationName} target ${compilation.target.name}:${compilation.target::class.qualifiedName} has incorrect 'compilerOptions' type " +
|
||||||
"${targetCompilerOptions::class.qualifiedName}"
|
"${targetCompilerOptions::class.qualifiedName}"
|
||||||
|
|||||||
+34
-11
@@ -7,10 +7,12 @@ package org.jetbrains.kotlin.gradle.plugin.mpp.external
|
|||||||
|
|
||||||
import org.gradle.api.artifacts.Configuration
|
import org.gradle.api.artifacts.Configuration
|
||||||
import org.gradle.api.logging.Logger
|
import org.gradle.api.logging.Logger
|
||||||
|
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
|
||||||
import org.jetbrains.kotlin.gradle.ExternalKotlinTargetApi
|
import org.jetbrains.kotlin.gradle.ExternalKotlinTargetApi
|
||||||
import org.jetbrains.kotlin.gradle.dsl.*
|
import org.jetbrains.kotlin.gradle.dsl.*
|
||||||
import org.jetbrains.kotlin.gradle.dsl.multiplatformExtension
|
import org.jetbrains.kotlin.gradle.dsl.multiplatformExtension
|
||||||
import org.jetbrains.kotlin.gradle.dsl.multiplatformExtensionOrNull
|
import org.jetbrains.kotlin.gradle.dsl.multiplatformExtensionOrNull
|
||||||
|
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinTarget
|
import org.jetbrains.kotlin.gradle.plugin.KotlinTarget
|
||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.InternalKotlinTarget
|
import org.jetbrains.kotlin.gradle.plugin.mpp.InternalKotlinTarget
|
||||||
|
|
||||||
@@ -23,7 +25,10 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.InternalKotlinTarget
|
|||||||
* #### Sample
|
* #### Sample
|
||||||
*
|
*
|
||||||
* ```kotlin
|
* ```kotlin
|
||||||
* class MyCustomJvmTarget(delegate: Delegate): DecoratedExternalKotlinTarget(delegate) {
|
* @OptIn(ExperimentalKotlinGradlePluginApi::class)
|
||||||
|
* class MyCustomJvmTarget(delegate: Delegate): DecoratedExternalKotlinTarget(delegate),
|
||||||
|
* HasConfigurableCompilerOptions<KotlinJvmCompilerOptions> {
|
||||||
|
*
|
||||||
* // Some property decorating our target
|
* // Some property decorating our target
|
||||||
* val myCustomProperty: String = "hello there"
|
* val myCustomProperty: String = "hello there"
|
||||||
*
|
*
|
||||||
@@ -32,17 +37,9 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.InternalKotlinTarget
|
|||||||
* get() = super.compilations as NamedDomainObjectContainer<MyCustomCompilationType>
|
* get() = super.compilations as NamedDomainObjectContainer<MyCustomCompilationType>
|
||||||
*
|
*
|
||||||
* // Covariant override of target compiler options that should be used to configure all target compilation compiler options
|
* // Covariant override of target compiler options that should be used to configure all target compilation compiler options
|
||||||
|
* @ExperimentalKotlinGradlePluginApi
|
||||||
* override val compilerOptions: KotlinJvmCompilerOptions
|
* override val compilerOptions: KotlinJvmCompilerOptions
|
||||||
* get() = super.compilerOptions as KotlinJvmCompilerOptions
|
* get() = super.compilerOptions as KotlinJvmCompilerOptions
|
||||||
*
|
|
||||||
* // Optionally follow api exposed in Kotlin built-in targets to configure compiler options
|
|
||||||
* fun compilerOptions(configure: KotlinJvmCompilerOptions.() -> Unit) {
|
|
||||||
* configure(compilerOptions)
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* fun compilerOptions(configure: Action<KotlinJvmCompilerOptions>) {
|
|
||||||
* configure.execute(compilerOptions)
|
|
||||||
* }
|
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
@@ -52,7 +49,7 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.InternalKotlinTarget
|
|||||||
* providing a factory function in the [ExternalKotlinTargetDescriptor]
|
* providing a factory function in the [ExternalKotlinTargetDescriptor]
|
||||||
*/
|
*/
|
||||||
@ExternalKotlinTargetApi
|
@ExternalKotlinTargetApi
|
||||||
open class DecoratedExternalKotlinTarget internal constructor(
|
abstract class DecoratedExternalKotlinTarget internal constructor(
|
||||||
internal val delegate: ExternalKotlinTargetImpl,
|
internal val delegate: ExternalKotlinTargetImpl,
|
||||||
) : InternalKotlinTarget by delegate {
|
) : InternalKotlinTarget by delegate {
|
||||||
constructor(delegate: Delegate) : this(delegate.impl)
|
constructor(delegate: Delegate) : this(delegate.impl)
|
||||||
@@ -78,6 +75,32 @@ open class DecoratedExternalKotlinTarget internal constructor(
|
|||||||
val sourcesElementsPublishedConfiguration: Configuration = delegate.sourcesElementsPublishedConfiguration
|
val sourcesElementsPublishedConfiguration: Configuration = delegate.sourcesElementsPublishedConfiguration
|
||||||
|
|
||||||
internal val logger: Logger = delegate.logger
|
internal val logger: Logger = delegate.logger
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Target implementation could override return type to the specific platform type:
|
||||||
|
* - [KotlinPlatformType.common] - should be [KotlinCommonCompilerOptions]
|
||||||
|
* - [KotlinPlatformType.jvm] or [KotlinPlatformType.androidJvm] - could be [KotlinJvmCompilerOptions]
|
||||||
|
* - [KotlinPlatformType.js] or [KotlinPlatformType.wasm] - could be [KotlinJsCompilerOptions]
|
||||||
|
* - [KotlinPlatformType.native] - could be [KotlinNativeCompilerOptions]
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* ```kotlin
|
||||||
|
* @OptIn(ExperimentalKotlinGradlePluginApi::class)
|
||||||
|
* class MyCustomNativeTarget(delegate: Delegate): DecoratedExternalKotlinTarget(delegate),
|
||||||
|
* HasConfigurableCompilerOptions<KotlinNativeCompilerOptions> {
|
||||||
|
*
|
||||||
|
* // Covariant override of target compiler options that should be used to configure
|
||||||
|
* // all target compilation compiler options
|
||||||
|
* @ExperimentalKotlinGradlePluginApi
|
||||||
|
* override val compilerOptions: KotlinNativeCompilerOptions
|
||||||
|
* get() = super.compilerOptions as KotlinNativeCompilerOptions
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* @since 2.0.0
|
||||||
|
*/
|
||||||
|
@ExperimentalKotlinGradlePluginApi
|
||||||
|
open val compilerOptions: KotlinCommonCompilerOptions = delegate.compilerOptions
|
||||||
}
|
}
|
||||||
|
|
||||||
internal val ExternalKotlinTargetImpl.decoratedInstance: DecoratedExternalKotlinTarget
|
internal val ExternalKotlinTargetImpl.decoratedInstance: DecoratedExternalKotlinTarget
|
||||||
|
|||||||
+4
-3
@@ -8,13 +8,13 @@ package org.jetbrains.kotlin.gradle.plugin.mpp.external
|
|||||||
import org.gradle.api.*
|
import org.gradle.api.*
|
||||||
import org.gradle.api.artifacts.Configuration
|
import org.gradle.api.artifacts.Configuration
|
||||||
import org.gradle.api.attributes.AttributeContainer
|
import org.gradle.api.attributes.AttributeContainer
|
||||||
import org.gradle.api.component.SoftwareComponent
|
|
||||||
import org.gradle.api.logging.Logger
|
import org.gradle.api.logging.Logger
|
||||||
import org.gradle.api.logging.Logging
|
import org.gradle.api.logging.Logging
|
||||||
import org.gradle.api.publish.maven.MavenPublication
|
import org.gradle.api.publish.maven.MavenPublication
|
||||||
import org.gradle.api.tasks.TaskProvider
|
import org.gradle.api.tasks.TaskProvider
|
||||||
import org.jetbrains.kotlin.gradle.InternalKotlinGradlePluginApi
|
import org.jetbrains.kotlin.gradle.InternalKotlinGradlePluginApi
|
||||||
import org.jetbrains.kotlin.gradle.PRESETS_API_IS_DEPRECATED_MESSAGE
|
import org.jetbrains.kotlin.gradle.PRESETS_API_IS_DEPRECATED_MESSAGE
|
||||||
|
import org.jetbrains.kotlin.gradle.dsl.HasConfigurableCompilerOptions
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonCompilerOptions
|
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonCompilerOptions
|
||||||
import org.jetbrains.kotlin.gradle.dsl.multiplatformExtension
|
import org.jetbrains.kotlin.gradle.dsl.multiplatformExtension
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
|
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
|
||||||
@@ -29,7 +29,7 @@ internal class ExternalKotlinTargetImpl internal constructor(
|
|||||||
override val targetName: String,
|
override val targetName: String,
|
||||||
override val platformType: KotlinPlatformType,
|
override val platformType: KotlinPlatformType,
|
||||||
override val publishable: Boolean,
|
override val publishable: Boolean,
|
||||||
val compilerOptions: KotlinCommonCompilerOptions,
|
override val compilerOptions: KotlinCommonCompilerOptions,
|
||||||
val apiElementsConfiguration: Configuration,
|
val apiElementsConfiguration: Configuration,
|
||||||
val runtimeElementsConfiguration: Configuration,
|
val runtimeElementsConfiguration: Configuration,
|
||||||
val sourcesElementsConfiguration: Configuration,
|
val sourcesElementsConfiguration: Configuration,
|
||||||
@@ -38,7 +38,8 @@ internal class ExternalKotlinTargetImpl internal constructor(
|
|||||||
val sourcesElementsPublishedConfiguration: Configuration,
|
val sourcesElementsPublishedConfiguration: Configuration,
|
||||||
val kotlinTargetComponent: ExternalKotlinTargetComponent,
|
val kotlinTargetComponent: ExternalKotlinTargetComponent,
|
||||||
private val artifactsTaskLocator: ArtifactsTaskLocator,
|
private val artifactsTaskLocator: ArtifactsTaskLocator,
|
||||||
) : InternalKotlinTarget {
|
) : InternalKotlinTarget,
|
||||||
|
HasConfigurableCompilerOptions<KotlinCommonCompilerOptions> {
|
||||||
|
|
||||||
|
|
||||||
fun interface ArtifactsTaskLocator {
|
fun interface ArtifactsTaskLocator {
|
||||||
|
|||||||
+4
-13
@@ -11,6 +11,7 @@ import org.gradle.api.artifacts.Configuration
|
|||||||
import org.gradle.api.attributes.Attribute
|
import org.gradle.api.attributes.Attribute
|
||||||
import org.gradle.api.attributes.AttributeContainer
|
import org.gradle.api.attributes.AttributeContainer
|
||||||
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
|
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
|
||||||
|
import org.jetbrains.kotlin.gradle.dsl.HasConfigurableCompilerOptions
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompilerOptions
|
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompilerOptions
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompilerOptionsDefault
|
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompilerOptionsDefault
|
||||||
import org.jetbrains.kotlin.gradle.plugin.*
|
import org.jetbrains.kotlin.gradle.plugin.*
|
||||||
@@ -27,7 +28,8 @@ import javax.inject.Inject
|
|||||||
abstract class KotlinAndroidTarget @Inject constructor(
|
abstract class KotlinAndroidTarget @Inject constructor(
|
||||||
final override val targetName: String,
|
final override val targetName: String,
|
||||||
project: Project,
|
project: Project,
|
||||||
) : AbstractKotlinTarget(project) {
|
) : AbstractKotlinTarget(project),
|
||||||
|
HasConfigurableCompilerOptions<KotlinJvmCompilerOptions> {
|
||||||
|
|
||||||
final override val disambiguationClassifier: String = targetName
|
final override val disambiguationClassifier: String = targetName
|
||||||
|
|
||||||
@@ -328,22 +330,11 @@ abstract class KotlinAndroidTarget @Inject constructor(
|
|||||||
attribute: Attribute<*>,
|
attribute: Attribute<*>,
|
||||||
): Boolean = attribute.name != "com.android.build.api.attributes.AgpVersionAttr"
|
): Boolean = attribute.name != "com.android.build.api.attributes.AgpVersionAttr"
|
||||||
|
|
||||||
@Suppress("RedundantVisibilityModifier")
|
|
||||||
@ExperimentalKotlinGradlePluginApi
|
@ExperimentalKotlinGradlePluginApi
|
||||||
internal override val compilerOptions: KotlinJvmCompilerOptions = project.objects
|
override val compilerOptions: KotlinJvmCompilerOptions = project.objects
|
||||||
.newInstance<KotlinJvmCompilerOptionsDefault>()
|
.newInstance<KotlinJvmCompilerOptionsDefault>()
|
||||||
.apply {
|
.apply {
|
||||||
DefaultKotlinJavaToolchain.wireJvmTargetToToolchain(this, project)
|
DefaultKotlinJavaToolchain.wireJvmTargetToToolchain(this, project)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ExperimentalKotlinGradlePluginApi
|
|
||||||
internal fun compilerOptions(configure: KotlinJvmCompilerOptions.() -> Unit) {
|
|
||||||
configure(compilerOptions)
|
|
||||||
}
|
|
||||||
|
|
||||||
@ExperimentalKotlinGradlePluginApi
|
|
||||||
internal fun compilerOptions(configure: Action<KotlinJvmCompilerOptions>) {
|
|
||||||
configure.execute(compilerOptions)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-3
@@ -12,8 +12,6 @@ import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension
|
|||||||
import org.jetbrains.kotlin.gradle.dsl.kotlinExtension
|
import org.jetbrains.kotlin.gradle.dsl.kotlinExtension
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation.Companion.MAIN_COMPILATION_NAME
|
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.KotlinCompilation.Companion.TEST_COMPILATION_NAME
|
||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.compilerOptions
|
|
||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.internal
|
|
||||||
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrSingleTargetPreset
|
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrSingleTargetPreset
|
||||||
import org.jetbrains.kotlin.gradle.utils.*
|
import org.jetbrains.kotlin.gradle.utils.*
|
||||||
|
|
||||||
@@ -85,7 +83,7 @@ open class KotlinJsPlugin: Plugin<Project> {
|
|||||||
kotlinExtension.sourceSets.maybeCreate(TEST_COMPILATION_NAME)
|
kotlinExtension.sourceSets.maybeCreate(TEST_COMPILATION_NAME)
|
||||||
|
|
||||||
kotlinExtension.registerTargetObserver { target ->
|
kotlinExtension.registerTargetObserver { target ->
|
||||||
target?.internal?.compilerOptions?.configureExperimentalTryNext(project)
|
target?.compilerOptions?.configureExperimentalTryNext(project)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-1
@@ -8,6 +8,8 @@ package org.jetbrains.kotlin.gradle.targets.js.dsl
|
|||||||
import org.gradle.api.Action
|
import org.gradle.api.Action
|
||||||
import org.gradle.api.GradleException
|
import org.gradle.api.GradleException
|
||||||
import org.gradle.api.NamedDomainObjectContainer
|
import org.gradle.api.NamedDomainObjectContainer
|
||||||
|
import org.jetbrains.kotlin.gradle.dsl.HasConfigurableCompilerOptions
|
||||||
|
import org.jetbrains.kotlin.gradle.dsl.KotlinJsCompilerOptions
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJsDce
|
import org.jetbrains.kotlin.gradle.dsl.KotlinJsDce
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinTarget
|
import org.jetbrains.kotlin.gradle.plugin.KotlinTarget
|
||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.HasBinaries
|
import org.jetbrains.kotlin.gradle.plugin.mpp.HasBinaries
|
||||||
@@ -37,7 +39,9 @@ interface KotlinJsSubTargetContainerDsl : KotlinTarget {
|
|||||||
interface KotlinJsTargetDsl :
|
interface KotlinJsTargetDsl :
|
||||||
KotlinTarget,
|
KotlinTarget,
|
||||||
KotlinTargetWithNodeJsDsl,
|
KotlinTargetWithNodeJsDsl,
|
||||||
HasBinaries<KotlinJsBinaryContainer>{
|
HasBinaries<KotlinJsBinaryContainer>,
|
||||||
|
HasConfigurableCompilerOptions<KotlinJsCompilerOptions> {
|
||||||
|
|
||||||
var moduleName: String?
|
var moduleName: String?
|
||||||
|
|
||||||
fun browser() = browser { }
|
fun browser() = browser { }
|
||||||
|
|||||||
+1
-2
@@ -452,9 +452,8 @@ constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("RedundantVisibilityModifier")
|
|
||||||
@ExperimentalKotlinGradlePluginApi
|
@ExperimentalKotlinGradlePluginApi
|
||||||
internal override val compilerOptions: KotlinJsCompilerOptions = project.objects
|
override val compilerOptions: KotlinJsCompilerOptions = project.objects
|
||||||
.newInstance<KotlinJsCompilerOptionsDefault>()
|
.newInstance<KotlinJsCompilerOptionsDefault>()
|
||||||
.apply {
|
.apply {
|
||||||
configureJsDefaultOptions()
|
configureJsDefaultOptions()
|
||||||
|
|||||||
+2
-14
@@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.gradle.targets.jvm
|
package org.jetbrains.kotlin.gradle.targets.jvm
|
||||||
|
|
||||||
import org.gradle.api.Action
|
|
||||||
import org.gradle.api.InvalidUserCodeException
|
import org.gradle.api.InvalidUserCodeException
|
||||||
import org.gradle.api.NamedDomainObjectContainer
|
import org.gradle.api.NamedDomainObjectContainer
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
@@ -48,6 +47,7 @@ import javax.inject.Inject
|
|||||||
abstract class KotlinJvmTarget @Inject constructor(
|
abstract class KotlinJvmTarget @Inject constructor(
|
||||||
project: Project,
|
project: Project,
|
||||||
) : KotlinOnlyTarget<KotlinJvmCompilation>(project, KotlinPlatformType.jvm),
|
) : KotlinOnlyTarget<KotlinJvmCompilation>(project, KotlinPlatformType.jvm),
|
||||||
|
HasConfigurableCompilerOptions<KotlinJvmCompilerOptions>,
|
||||||
KotlinTargetWithTests<JvmClasspathTestRunSource, KotlinJvmTestRun> {
|
KotlinTargetWithTests<JvmClasspathTestRunSource, KotlinJvmTestRun> {
|
||||||
|
|
||||||
override val testRuns: NamedDomainObjectContainer<KotlinJvmTestRun> by lazy {
|
override val testRuns: NamedDomainObjectContainer<KotlinJvmTestRun> by lazy {
|
||||||
@@ -334,9 +334,8 @@ abstract class KotlinJvmTarget @Inject constructor(
|
|||||||
private fun areRuntimeOrCompileConfigurationsAvailable(): Boolean =
|
private fun areRuntimeOrCompileConfigurationsAvailable(): Boolean =
|
||||||
GradleVersion.version(project.gradle.gradleVersion) <= GradleVersion.version("6.8.3")
|
GradleVersion.version(project.gradle.gradleVersion) <= GradleVersion.version("6.8.3")
|
||||||
|
|
||||||
@Suppress("RedundantVisibilityModifier")
|
|
||||||
@ExperimentalKotlinGradlePluginApi
|
@ExperimentalKotlinGradlePluginApi
|
||||||
internal override val compilerOptions: KotlinJvmCompilerOptions = project.objects
|
override val compilerOptions: KotlinJvmCompilerOptions = project.objects
|
||||||
.newInstance<KotlinJvmCompilerOptionsDefault>()
|
.newInstance<KotlinJvmCompilerOptionsDefault>()
|
||||||
.apply {
|
.apply {
|
||||||
DefaultKotlinJavaToolchain.wireJvmTargetToToolchain(
|
DefaultKotlinJavaToolchain.wireJvmTargetToToolchain(
|
||||||
@@ -344,15 +343,4 @@ abstract class KotlinJvmTarget @Inject constructor(
|
|||||||
project
|
project
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ExperimentalKotlinGradlePluginApi
|
|
||||||
internal fun compilerOptions(configure: KotlinJvmCompilerOptions.() -> Unit) {
|
|
||||||
configure(compilerOptions)
|
|
||||||
}
|
|
||||||
|
|
||||||
@ExperimentalKotlinGradlePluginApi
|
|
||||||
internal fun compilerOptions(configure: Action<KotlinJvmCompilerOptions>) {
|
|
||||||
configure.execute(compilerOptions)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -30,7 +30,8 @@ abstract class KotlinWithJavaTarget<KotlinOptionsType : KotlinCommonOptions, CO
|
|||||||
override val targetName: String,
|
override val targetName: String,
|
||||||
compilerOptionsFactory: () -> HasCompilerOptions<CO>,
|
compilerOptionsFactory: () -> HasCompilerOptions<CO>,
|
||||||
kotlinOptionsFactory: (CO) -> KotlinOptionsType
|
kotlinOptionsFactory: (CO) -> KotlinOptionsType
|
||||||
) : AbstractKotlinTarget(project) {
|
) : AbstractKotlinTarget(project),
|
||||||
|
HasConfigurableCompilerOptions<KotlinJvmCompilerOptions> {
|
||||||
override var disambiguationClassifier: String? = null
|
override var disambiguationClassifier: String? = null
|
||||||
internal set
|
internal set
|
||||||
|
|
||||||
|
|||||||
+3
-13
@@ -6,7 +6,6 @@
|
|||||||
@file:Suppress("PackageDirectoryMismatch") // Old package for compatibility
|
@file:Suppress("PackageDirectoryMismatch") // Old package for compatibility
|
||||||
package org.jetbrains.kotlin.gradle.plugin.mpp
|
package org.jetbrains.kotlin.gradle.plugin.mpp
|
||||||
|
|
||||||
import org.gradle.api.Action
|
|
||||||
import org.gradle.api.NamedDomainObjectContainer
|
import org.gradle.api.NamedDomainObjectContainer
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import org.gradle.api.attributes.Attribute
|
import org.gradle.api.attributes.Attribute
|
||||||
@@ -34,7 +33,8 @@ import javax.inject.Inject
|
|||||||
abstract class KotlinNativeTarget @Inject constructor(
|
abstract class KotlinNativeTarget @Inject constructor(
|
||||||
project: Project,
|
project: Project,
|
||||||
val konanTarget: KonanTarget,
|
val konanTarget: KonanTarget,
|
||||||
) : KotlinTargetWithBinaries<KotlinNativeCompilation, KotlinNativeBinaryContainer>(
|
) : HasConfigurableCompilerOptions<KotlinNativeCompilerOptions>,
|
||||||
|
KotlinTargetWithBinaries<KotlinNativeCompilation, KotlinNativeBinaryContainer>(
|
||||||
project,
|
project,
|
||||||
KotlinPlatformType.native
|
KotlinPlatformType.native
|
||||||
) {
|
) {
|
||||||
@@ -100,7 +100,7 @@ abstract class KotlinNativeTarget @Inject constructor(
|
|||||||
get() = konanTarget.enabledOnCurrentHost
|
get() = konanTarget.enabledOnCurrentHost
|
||||||
|
|
||||||
@ExperimentalKotlinGradlePluginApi
|
@ExperimentalKotlinGradlePluginApi
|
||||||
internal override val compilerOptions: KotlinNativeCompilerOptions = project.objects
|
override val compilerOptions: KotlinNativeCompilerOptions = project.objects
|
||||||
.newInstance<KotlinNativeCompilerOptionsDefault>()
|
.newInstance<KotlinNativeCompilerOptionsDefault>()
|
||||||
.apply {
|
.apply {
|
||||||
moduleName.convention(
|
moduleName.convention(
|
||||||
@@ -110,16 +110,6 @@ abstract class KotlinNativeTarget @Inject constructor(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ExperimentalKotlinGradlePluginApi
|
|
||||||
internal fun compilerOptions(configure: KotlinNativeCompilerOptions.() -> Unit) {
|
|
||||||
configure(compilerOptions)
|
|
||||||
}
|
|
||||||
|
|
||||||
@ExperimentalKotlinGradlePluginApi
|
|
||||||
internal fun compilerOptions(configure: Action<KotlinNativeCompilerOptions>) {
|
|
||||||
configure.execute(compilerOptions)
|
|
||||||
}
|
|
||||||
|
|
||||||
// User-visible constants
|
// User-visible constants
|
||||||
val DEBUG = NativeBuildType.DEBUG
|
val DEBUG = NativeBuildType.DEBUG
|
||||||
val RELEASE = NativeBuildType.RELEASE
|
val RELEASE = NativeBuildType.RELEASE
|
||||||
|
|||||||
+158
-57
@@ -24,21 +24,20 @@ import kotlin.test.assertEquals
|
|||||||
|
|
||||||
class ProjectCompilerOptionsTests {
|
class ProjectCompilerOptionsTests {
|
||||||
|
|
||||||
@Ignore
|
|
||||||
@Test
|
@Test
|
||||||
fun nativeTargetCompilerOptionsDSL() {
|
fun nativeTargetCompilerOptionsDSL() {
|
||||||
val project = buildProjectWithMPP {
|
val project = buildProjectWithMPP {
|
||||||
with(multiplatformExtension) {
|
with(multiplatformExtension) {
|
||||||
linuxX64 {
|
linuxX64 {
|
||||||
// compilerOptions {
|
compilerOptions {
|
||||||
// progressiveMode.set(true)
|
progressiveMode.set(true)
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
iosX64 {
|
iosX64 {
|
||||||
// compilerOptions {
|
compilerOptions {
|
||||||
// suppressWarnings.set(true)
|
suppressWarnings.set(true)
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
applyDefaultHierarchyTemplate()
|
applyDefaultHierarchyTemplate()
|
||||||
@@ -57,7 +56,6 @@ class ProjectCompilerOptionsTests {
|
|||||||
assertEquals(false, project.kotlinNativeTask("compileTestKotlinIosX64").compilerOptions.progressiveMode.get())
|
assertEquals(false, project.kotlinNativeTask("compileTestKotlinIosX64").compilerOptions.progressiveMode.get())
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore
|
|
||||||
@Test
|
@Test
|
||||||
fun nativeTaskOverridesTargetOptions() {
|
fun nativeTaskOverridesTargetOptions() {
|
||||||
val project = buildProjectWithMPP {
|
val project = buildProjectWithMPP {
|
||||||
@@ -69,9 +67,9 @@ class ProjectCompilerOptionsTests {
|
|||||||
|
|
||||||
with(multiplatformExtension) {
|
with(multiplatformExtension) {
|
||||||
linuxX64 {
|
linuxX64 {
|
||||||
// compilerOptions {
|
compilerOptions {
|
||||||
// progressiveMode.set(true)
|
progressiveMode.set(true)
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
applyDefaultHierarchyTemplate()
|
applyDefaultHierarchyTemplate()
|
||||||
@@ -83,15 +81,105 @@ class ProjectCompilerOptionsTests {
|
|||||||
assertEquals(false, project.kotlinNativeTask("compileKotlinLinuxX64").compilerOptions.progressiveMode.get())
|
assertEquals(false, project.kotlinNativeTask("compileKotlinLinuxX64").compilerOptions.progressiveMode.get())
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore
|
@Test
|
||||||
|
fun nativeLanguageSettingsOverridesTargetOptions() {
|
||||||
|
val project = buildProjectWithMPP {
|
||||||
|
with(multiplatformExtension) {
|
||||||
|
linuxX64 {
|
||||||
|
compilerOptions {
|
||||||
|
progressiveMode.set(true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
applyDefaultHierarchyTemplate()
|
||||||
|
|
||||||
|
sourceSets.getByName("linuxX64Main").languageSettings {
|
||||||
|
progressiveMode = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
project.evaluate()
|
||||||
|
|
||||||
|
assertEquals(false, project.kotlinNativeTask("compileKotlinLinuxX64").compilerOptions.progressiveMode.get())
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun jvmTargetCompilerOptionsDSL() {
|
||||||
|
val project = buildProjectWithMPP {
|
||||||
|
with(multiplatformExtension) {
|
||||||
|
jvm {
|
||||||
|
compilerOptions {
|
||||||
|
noJdk.set(true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
applyDefaultHierarchyTemplate()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
project.evaluate()
|
||||||
|
|
||||||
|
assertEquals(true, project.kotlinJvmTask("compileKotlinJvm").compilerOptions.noJdk.get())
|
||||||
|
assertEquals(true, project.kotlinJvmTask("compileTestKotlinJvm").compilerOptions.noJdk.get())
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun jvmTaskOverridesTargetOptions() {
|
||||||
|
val project = buildProjectWithMPP {
|
||||||
|
tasks.withType<KotlinCompilationTask<*>>().configureEach {
|
||||||
|
if (it.name == "compileKotlinJvm") {
|
||||||
|
it.compilerOptions.progressiveMode.set(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
with(multiplatformExtension) {
|
||||||
|
jvm {
|
||||||
|
compilerOptions {
|
||||||
|
progressiveMode.set(true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
applyDefaultHierarchyTemplate()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
project.evaluate()
|
||||||
|
|
||||||
|
assertEquals(false, project.kotlinJvmTask("compileKotlinJvm").compilerOptions.progressiveMode.get())
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun jvmLanguageSettingsOverridesTargetOptions() {
|
||||||
|
val project = buildProjectWithMPP {
|
||||||
|
with(multiplatformExtension) {
|
||||||
|
jvm {
|
||||||
|
compilerOptions {
|
||||||
|
progressiveMode.set(true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
applyDefaultHierarchyTemplate()
|
||||||
|
|
||||||
|
sourceSets.getByName("jvmMain").languageSettings {
|
||||||
|
progressiveMode = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
project.evaluate()
|
||||||
|
|
||||||
|
assertEquals(false, project.kotlinJvmTask("compileKotlinJvm").compilerOptions.progressiveMode.get())
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun jsTargetCompilerOptionsDsl() {
|
fun jsTargetCompilerOptionsDsl() {
|
||||||
val project = buildProjectWithMPP {
|
val project = buildProjectWithMPP {
|
||||||
with(multiplatformExtension) {
|
with(multiplatformExtension) {
|
||||||
js {
|
js {
|
||||||
// compilerOptions {
|
compilerOptions {
|
||||||
// suppressWarnings.set(true)
|
suppressWarnings.set(true)
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
applyDefaultHierarchyTemplate()
|
applyDefaultHierarchyTemplate()
|
||||||
@@ -104,7 +192,6 @@ class ProjectCompilerOptionsTests {
|
|||||||
assertEquals(true, project.kotlinJsTask("compileTestKotlinJs").compilerOptions.suppressWarnings.get())
|
assertEquals(true, project.kotlinJsTask("compileTestKotlinJs").compilerOptions.suppressWarnings.get())
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore
|
|
||||||
@Test
|
@Test
|
||||||
fun jsTaskOptionsOverridesTargetOptions() {
|
fun jsTaskOptionsOverridesTargetOptions() {
|
||||||
val project = buildProjectWithMPP {
|
val project = buildProjectWithMPP {
|
||||||
@@ -116,9 +203,9 @@ class ProjectCompilerOptionsTests {
|
|||||||
|
|
||||||
with(multiplatformExtension) {
|
with(multiplatformExtension) {
|
||||||
js {
|
js {
|
||||||
// compilerOptions {
|
compilerOptions {
|
||||||
// suppressWarnings.set(true)
|
suppressWarnings.set(true)
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
applyDefaultHierarchyTemplate()
|
applyDefaultHierarchyTemplate()
|
||||||
@@ -130,7 +217,29 @@ class ProjectCompilerOptionsTests {
|
|||||||
assertEquals(false, project.kotlinJsTask("compileKotlinJs").compilerOptions.suppressWarnings.get())
|
assertEquals(false, project.kotlinJsTask("compileKotlinJs").compilerOptions.suppressWarnings.get())
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore
|
@Test
|
||||||
|
fun jsLanguageSettingsOverridesTargetOptions() {
|
||||||
|
val project = buildProjectWithMPP {
|
||||||
|
with(multiplatformExtension) {
|
||||||
|
js {
|
||||||
|
compilerOptions {
|
||||||
|
progressiveMode.set(true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
applyDefaultHierarchyTemplate()
|
||||||
|
|
||||||
|
sourceSets.getByName("jsMain").languageSettings {
|
||||||
|
progressiveMode = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
project.evaluate()
|
||||||
|
|
||||||
|
assertEquals(false, project.kotlinJsTask("compileKotlinJs").compilerOptions.progressiveMode.get())
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun metadataTargetDsl() {
|
fun metadataTargetDsl() {
|
||||||
val project = buildProjectWithMPP {
|
val project = buildProjectWithMPP {
|
||||||
@@ -140,9 +249,9 @@ class ProjectCompilerOptionsTests {
|
|||||||
iosArm64()
|
iosArm64()
|
||||||
|
|
||||||
targets.named("metadata", KotlinMetadataTarget::class.java) {
|
targets.named("metadata", KotlinMetadataTarget::class.java) {
|
||||||
// it.compilerOptions {
|
it.compilerOptions {
|
||||||
// progressiveMode.set(true)
|
progressiveMode.set(true)
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
applyDefaultHierarchyTemplate()
|
applyDefaultHierarchyTemplate()
|
||||||
@@ -154,7 +263,6 @@ class ProjectCompilerOptionsTests {
|
|||||||
assertEquals(true, project.kotlinCommonTask("compileKotlinMetadata").compilerOptions.progressiveMode.get())
|
assertEquals(true, project.kotlinCommonTask("compileKotlinMetadata").compilerOptions.progressiveMode.get())
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore
|
|
||||||
@Test
|
@Test
|
||||||
fun metadataTaskOptionsOverrideTargetOptions() {
|
fun metadataTaskOptionsOverrideTargetOptions() {
|
||||||
val project = buildProjectWithMPP {
|
val project = buildProjectWithMPP {
|
||||||
@@ -170,9 +278,9 @@ class ProjectCompilerOptionsTests {
|
|||||||
iosArm64()
|
iosArm64()
|
||||||
|
|
||||||
targets.named("metadata", KotlinMetadataTarget::class.java) {
|
targets.named("metadata", KotlinMetadataTarget::class.java) {
|
||||||
// it.compilerOptions {
|
it.compilerOptions {
|
||||||
// progressiveMode.set(true)
|
progressiveMode.set(true)
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
applyDefaultHierarchyTemplate()
|
applyDefaultHierarchyTemplate()
|
||||||
@@ -184,7 +292,6 @@ class ProjectCompilerOptionsTests {
|
|||||||
assertEquals(false, project.kotlinCommonTask("compileKotlinMetadata").compilerOptions.progressiveMode.get())
|
assertEquals(false, project.kotlinCommonTask("compileKotlinMetadata").compilerOptions.progressiveMode.get())
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore
|
|
||||||
@Test
|
@Test
|
||||||
fun externalTargetDsl() {
|
fun externalTargetDsl() {
|
||||||
val project = buildProjectWithMPP()
|
val project = buildProjectWithMPP()
|
||||||
@@ -194,9 +301,9 @@ class ProjectCompilerOptionsTests {
|
|||||||
target.createCompilation<FakeCompilation> { defaults(this@with) }
|
target.createCompilation<FakeCompilation> { defaults(this@with) }
|
||||||
target.createCompilation<FakeCompilation> { defaults(this@with, "test") }
|
target.createCompilation<FakeCompilation> { defaults(this@with, "test") }
|
||||||
|
|
||||||
// target.compilerOptions {
|
target.compilerOptions {
|
||||||
// javaParameters.set(true)
|
javaParameters.set(true)
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -204,7 +311,6 @@ class ProjectCompilerOptionsTests {
|
|||||||
assertEquals(true, project.kotlinJvmTask("compileTestKotlinFake").compilerOptions.javaParameters.get())
|
assertEquals(true, project.kotlinJvmTask("compileTestKotlinFake").compilerOptions.javaParameters.get())
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore
|
|
||||||
@Test
|
@Test
|
||||||
fun externalTaskOptionsOverridesTargetOptions() {
|
fun externalTaskOptionsOverridesTargetOptions() {
|
||||||
val project = buildProjectWithMPP()
|
val project = buildProjectWithMPP()
|
||||||
@@ -220,9 +326,9 @@ class ProjectCompilerOptionsTests {
|
|||||||
target.createCompilation<FakeCompilation> { defaults(this@with) }
|
target.createCompilation<FakeCompilation> { defaults(this@with) }
|
||||||
target.createCompilation<FakeCompilation> { defaults(this@with, "test") }
|
target.createCompilation<FakeCompilation> { defaults(this@with, "test") }
|
||||||
|
|
||||||
// target.compilerOptions {
|
target.compilerOptions {
|
||||||
// javaParameters.set(true)
|
javaParameters.set(true)
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -259,16 +365,15 @@ class ProjectCompilerOptionsTests {
|
|||||||
assertEquals(true, project.kotlinNativeTask("compileTestKotlinIosArm64").compilerOptions.progressiveMode.get())
|
assertEquals(true, project.kotlinNativeTask("compileTestKotlinIosArm64").compilerOptions.progressiveMode.get())
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore
|
|
||||||
@Test
|
@Test
|
||||||
fun testTargetDslOverridesTopLevelDsl() {
|
fun testTargetDslOverridesTopLevelDsl() {
|
||||||
val project = buildProjectWithMPP()
|
val project = buildProjectWithMPP()
|
||||||
project.runLifecycleAwareTest {
|
project.runLifecycleAwareTest {
|
||||||
with(multiplatformExtension) {
|
with(multiplatformExtension) {
|
||||||
jvm {
|
jvm {
|
||||||
// compilerOptions {
|
compilerOptions {
|
||||||
// languageVersion.set(KotlinVersion.KOTLIN_1_8)
|
languageVersion.set(KotlinVersion.KOTLIN_1_8)
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
compilerOptions {
|
compilerOptions {
|
||||||
@@ -320,7 +425,6 @@ class ProjectCompilerOptionsTests {
|
|||||||
assertEquals("2.0", project.multiplatformExtension.sourceSets.getByName("commonTest").languageSettings.languageVersion)
|
assertEquals("2.0", project.multiplatformExtension.sourceSets.getByName("commonTest").languageSettings.languageVersion)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore
|
|
||||||
@Test
|
@Test
|
||||||
fun testJvmModuleNameInMppIsConfigured() {
|
fun testJvmModuleNameInMppIsConfigured() {
|
||||||
val project = buildProjectWithMPP()
|
val project = buildProjectWithMPP()
|
||||||
@@ -335,17 +439,16 @@ class ProjectCompilerOptionsTests {
|
|||||||
assertEquals("my-custom-module-name", project.kotlinJvmTask("compileKotlinJvm").compilerOptions.moduleName.orNull)
|
assertEquals("my-custom-module-name", project.kotlinJvmTask("compileKotlinJvm").compilerOptions.moduleName.orNull)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore
|
|
||||||
@Test
|
@Test
|
||||||
fun testJsOptionsIsConfigured() {
|
fun testJsOptionsIsConfigured() {
|
||||||
val project = buildProjectWithMPP()
|
val project = buildProjectWithMPP()
|
||||||
project.runLifecycleAwareTest {
|
project.runLifecycleAwareTest {
|
||||||
with(multiplatformExtension) {
|
with(multiplatformExtension) {
|
||||||
js {
|
js {
|
||||||
// compilerOptions {
|
compilerOptions {
|
||||||
// moduleName.set("js-module-name")
|
moduleName.set("js-module-name")
|
||||||
// freeCompilerArgs.add("-Xstrict-implicit-export-types")
|
freeCompilerArgs.add("-Xstrict-implicit-export-types")
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -360,7 +463,6 @@ class ProjectCompilerOptionsTests {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore
|
|
||||||
@Test
|
@Test
|
||||||
fun testJsBrowserConfigDoesNotOverrideFreeCompilerArgsFromTarget() {
|
fun testJsBrowserConfigDoesNotOverrideFreeCompilerArgsFromTarget() {
|
||||||
val project = buildProjectWithMPP()
|
val project = buildProjectWithMPP()
|
||||||
@@ -369,9 +471,9 @@ class ProjectCompilerOptionsTests {
|
|||||||
js {
|
js {
|
||||||
binaries.executable()
|
binaries.executable()
|
||||||
browser()
|
browser()
|
||||||
// compilerOptions {
|
compilerOptions {
|
||||||
// freeCompilerArgs.addAll("-Xstrict-implicit-export-types", "-Xexplicit-api=warning")
|
freeCompilerArgs.addAll("-Xstrict-implicit-export-types", "-Xexplicit-api=warning")
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -384,7 +486,6 @@ class ProjectCompilerOptionsTests {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore
|
|
||||||
@Test
|
@Test
|
||||||
fun testJsLinkTaskAreAlsoConfiguredWithOptionsFromDSL() {
|
fun testJsLinkTaskAreAlsoConfiguredWithOptionsFromDSL() {
|
||||||
val project = buildProjectWithMPP()
|
val project = buildProjectWithMPP()
|
||||||
@@ -393,13 +494,13 @@ class ProjectCompilerOptionsTests {
|
|||||||
js {
|
js {
|
||||||
nodejs()
|
nodejs()
|
||||||
binaries.library()
|
binaries.library()
|
||||||
// compilerOptions {
|
compilerOptions {
|
||||||
// moduleName.set("my-custom-module")
|
moduleName.set("my-custom-module")
|
||||||
// languageVersion.set(KotlinVersion.KOTLIN_1_8)
|
languageVersion.set(KotlinVersion.KOTLIN_1_8)
|
||||||
// apiVersion.set(KotlinVersion.KOTLIN_1_8)
|
apiVersion.set(KotlinVersion.KOTLIN_1_8)
|
||||||
// moduleKind.set(JsModuleKind.MODULE_PLAIN)
|
moduleKind.set(JsModuleKind.MODULE_PLAIN)
|
||||||
// freeCompilerArgs.addAll("-Xstrict-implicit-export-types", "-Xexplicit-api=warning")
|
freeCompilerArgs.addAll("-Xstrict-implicit-export-types", "-Xexplicit-api=warning")
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-1
@@ -6,6 +6,7 @@
|
|||||||
package org.jetbrains.kotlin.gradle.util
|
package org.jetbrains.kotlin.gradle.util
|
||||||
|
|
||||||
import org.gradle.api.NamedDomainObjectContainer
|
import org.gradle.api.NamedDomainObjectContainer
|
||||||
|
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
|
||||||
import org.jetbrains.kotlin.gradle.dsl.*
|
import org.jetbrains.kotlin.gradle.dsl.*
|
||||||
import org.jetbrains.kotlin.gradle.plugin.HasCompilerOptions
|
import org.jetbrains.kotlin.gradle.plugin.HasCompilerOptions
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation
|
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation
|
||||||
@@ -20,11 +21,16 @@ class FakeCompilation(delegate: Delegate) : DecoratedExternalKotlinCompilation(d
|
|||||||
get() = super.compilerOptions as HasCompilerOptions<KotlinJvmCompilerOptions>
|
get() = super.compilerOptions as HasCompilerOptions<KotlinJvmCompilerOptions>
|
||||||
}
|
}
|
||||||
|
|
||||||
class FakeTarget(delegate: Delegate) : DecoratedExternalKotlinTarget(delegate) {
|
class FakeTarget(delegate: Delegate) : DecoratedExternalKotlinTarget(delegate),
|
||||||
|
HasConfigurableCompilerOptions<KotlinJvmCompilerOptions> {
|
||||||
|
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
override val compilations: NamedDomainObjectContainer<FakeCompilation>
|
override val compilations: NamedDomainObjectContainer<FakeCompilation>
|
||||||
get() = super.compilations as NamedDomainObjectContainer<FakeCompilation>
|
get() = super.compilations as NamedDomainObjectContainer<FakeCompilation>
|
||||||
|
|
||||||
|
@ExperimentalKotlinGradlePluginApi
|
||||||
|
override val compilerOptions: KotlinJvmCompilerOptions
|
||||||
|
get() = super.compilerOptions as KotlinJvmCompilerOptions
|
||||||
}
|
}
|
||||||
|
|
||||||
fun ExternalKotlinTargetDescriptorBuilder<FakeTarget>.defaults() {
|
fun ExternalKotlinTargetDescriptorBuilder<FakeTarget>.defaults() {
|
||||||
|
|||||||
Reference in New Issue
Block a user