[Gradle] Introduce HasConfigurableCompilerOptions DSL interface
This interface should be attached to the KGP DSL entities that want to provide an ability to configure Kotlin compiler options. ^KT-60733 In Progress
This commit is contained in:
committed by
Space Team
parent
58fd558308
commit
e527781772
@@ -8,6 +8,17 @@ public final class org/jetbrains/kotlin/gradle/dsl/ExplicitApiMode : java/lang/E
|
||||
public static fun values ()[Lorg/jetbrains/kotlin/gradle/dsl/ExplicitApiMode;
|
||||
}
|
||||
|
||||
public abstract interface class org/jetbrains/kotlin/gradle/dsl/HasConfigurableCompilerOptions {
|
||||
public abstract fun compilerOptions (Lkotlin/jvm/functions/Function1;)V
|
||||
public abstract fun compilerOptions (Lorg/gradle/api/Action;)V
|
||||
public abstract fun getCompilerOptions ()Lorg/jetbrains/kotlin/gradle/dsl/KotlinCommonCompilerOptions;
|
||||
}
|
||||
|
||||
public final class org/jetbrains/kotlin/gradle/dsl/HasConfigurableCompilerOptions$DefaultImpls {
|
||||
public static fun compilerOptions (Lorg/jetbrains/kotlin/gradle/dsl/HasConfigurableCompilerOptions;Lkotlin/jvm/functions/Function1;)V
|
||||
public static fun compilerOptions (Lorg/jetbrains/kotlin/gradle/dsl/HasConfigurableCompilerOptions;Lorg/gradle/api/Action;)V
|
||||
}
|
||||
|
||||
public final class org/jetbrains/kotlin/gradle/dsl/JsDiagnosticMode : java/lang/Enum {
|
||||
public static final field Companion Lorg/jetbrains/kotlin/gradle/dsl/JsDiagnosticMode$Companion;
|
||||
public static final field RUNTIME_DIAGNOSTIC_EXCEPTION Lorg/jetbrains/kotlin/gradle/dsl/JsDiagnosticMode;
|
||||
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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.dsl
|
||||
|
||||
import org.gradle.api.Action
|
||||
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
|
||||
|
||||
/**
|
||||
* DSL entity with the ability to configure Kotlin compiler options.
|
||||
*/
|
||||
@ExperimentalKotlinGradlePluginApi
|
||||
interface HasConfigurableCompilerOptions<CO : KotlinCommonCompilerOptions> {
|
||||
|
||||
/**
|
||||
* Represents the compiler options used by a Kotlin compilation process.
|
||||
*
|
||||
* This can be used to get the values of currently configured options or modify them.
|
||||
*/
|
||||
@ExperimentalKotlinGradlePluginApi
|
||||
val compilerOptions: CO
|
||||
|
||||
/**
|
||||
* Configures the [compilerOptions] with the provided configuration.
|
||||
*/
|
||||
@ExperimentalKotlinGradlePluginApi
|
||||
fun compilerOptions(configure: CO.() -> Unit) {
|
||||
configure(compilerOptions)
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the [compilerOptions] with the provided configuration.
|
||||
*/
|
||||
@ExperimentalKotlinGradlePluginApi
|
||||
fun compilerOptions(configure: Action<CO>) {
|
||||
configure.execute(compilerOptions)
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
public abstract class org/jetbrains/kotlin/gradle/dsl/KotlinMultiplatformExtension : org/jetbrains/kotlin/gradle/dsl/KotlinProjectExtension, org/jetbrains/kotlin/gradle/dsl/KotlinHierarchyDsl, org/jetbrains/kotlin/gradle/dsl/KotlinMultiplatformSourceSetConventions, org/jetbrains/kotlin/gradle/dsl/KotlinTargetContainerWithJsPresetFunctions, org/jetbrains/kotlin/gradle/dsl/KotlinTargetContainerWithNativeShortcuts, org/jetbrains/kotlin/gradle/dsl/KotlinTargetContainerWithPresetFunctions, org/jetbrains/kotlin/gradle/dsl/KotlinTargetContainerWithWasmPresetFunctions {
|
||||
public abstract class org/jetbrains/kotlin/gradle/dsl/KotlinMultiplatformExtension : org/jetbrains/kotlin/gradle/dsl/KotlinProjectExtension, org/jetbrains/kotlin/gradle/dsl/HasConfigurableCompilerOptions, org/jetbrains/kotlin/gradle/dsl/KotlinHierarchyDsl, org/jetbrains/kotlin/gradle/dsl/KotlinMultiplatformSourceSetConventions, org/jetbrains/kotlin/gradle/dsl/KotlinTargetContainerWithJsPresetFunctions, org/jetbrains/kotlin/gradle/dsl/KotlinTargetContainerWithNativeShortcuts, org/jetbrains/kotlin/gradle/dsl/KotlinTargetContainerWithPresetFunctions, org/jetbrains/kotlin/gradle/dsl/KotlinTargetContainerWithWasmPresetFunctions {
|
||||
public fun android ()Lorg/jetbrains/kotlin/gradle/plugin/mpp/KotlinAndroidTarget;
|
||||
public fun android (Ljava/lang/String;)Lorg/jetbrains/kotlin/gradle/plugin/mpp/KotlinAndroidTarget;
|
||||
public fun android (Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lorg/jetbrains/kotlin/gradle/plugin/mpp/KotlinAndroidTarget;
|
||||
@@ -34,8 +34,8 @@ 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 compilerOptions (Lkotlin/jvm/functions/Function1;)V
|
||||
public 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,6 +45,7 @@ public abstract class org/jetbrains/kotlin/gradle/dsl/KotlinMultiplatformExtensi
|
||||
public synthetic 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 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;
|
||||
|
||||
+2
-11
@@ -36,6 +36,7 @@ abstract class KotlinMultiplatformExtension
|
||||
KotlinTargetContainerWithWasmPresetFunctions,
|
||||
KotlinTargetContainerWithNativeShortcuts,
|
||||
KotlinHierarchyDsl,
|
||||
HasConfigurableCompilerOptions<KotlinCommonCompilerOptions>,
|
||||
KotlinMultiplatformSourceSetConventions by KotlinMultiplatformSourceSetConventionsImpl {
|
||||
@Deprecated(
|
||||
PRESETS_API_IS_DEPRECATED_MESSAGE,
|
||||
@@ -244,22 +245,12 @@ abstract class KotlinMultiplatformExtension
|
||||
}
|
||||
|
||||
@ExperimentalKotlinGradlePluginApi
|
||||
internal val compilerOptions: KotlinCommonCompilerOptions = project.objects
|
||||
override val compilerOptions: KotlinCommonCompilerOptions = project.objects
|
||||
.newInstance<KotlinCommonCompilerOptionsDefault>()
|
||||
.configureExperimentalTryNext(project)
|
||||
.also {
|
||||
syncCommonOptions(it)
|
||||
}
|
||||
|
||||
@ExperimentalKotlinGradlePluginApi
|
||||
fun compilerOptions(configure: KotlinCommonCompilerOptions.() -> Unit) {
|
||||
configure(compilerOptions)
|
||||
}
|
||||
|
||||
@ExperimentalKotlinGradlePluginApi
|
||||
fun compilerOptions(configure: Action<KotlinCommonCompilerOptions>) {
|
||||
configure.execute(compilerOptions)
|
||||
}
|
||||
}
|
||||
|
||||
@DeprecatedTargetPresetApi
|
||||
|
||||
Reference in New Issue
Block a user