[Gradle] Introduce public KotlinGradlePluginDsl marker annotation
The purpose of this annotation is to distinguish different levels of DSL in KGP: - top level extension - target level DSL - compilation level DSL With this marker user should not be able to call implicit methods from upper levels of DSL, and it should reduce confusion with DSL usage. ^KT-57292 In Progress
This commit is contained in:
committed by
Space Team
parent
74b4adf8e2
commit
36e85fec95
@@ -11,22 +11,20 @@ val jsStdlibSources = "${projectDir}/../stdlib/js/src"
|
|||||||
@Suppress("UNUSED_VARIABLE")
|
@Suppress("UNUSED_VARIABLE")
|
||||||
kotlin {
|
kotlin {
|
||||||
explicitApi()
|
explicitApi()
|
||||||
js {
|
js()
|
||||||
sourceSets {
|
|
||||||
val main by getting {
|
sourceSets {
|
||||||
if (!kotlinBuildProperties.isInIdeaSync) {
|
val main by getting {
|
||||||
kotlin.srcDir("$jsStdlibSources/org.w3c")
|
if (!kotlinBuildProperties.isInIdeaSync) {
|
||||||
kotlin.srcDir("$jsStdlibSources/kotlinx")
|
kotlin.srcDir("$jsStdlibSources/org.w3c")
|
||||||
kotlin.srcDir("$jsStdlibSources/kotlin/browser")
|
kotlin.srcDir("$jsStdlibSources/kotlinx")
|
||||||
kotlin.srcDir("$jsStdlibSources/kotlin/dom")
|
kotlin.srcDir("$jsStdlibSources/kotlin/browser")
|
||||||
}
|
kotlin.srcDir("$jsStdlibSources/kotlin/dom")
|
||||||
dependencies {
|
}
|
||||||
api(project(":kotlin-stdlib"))
|
dependencies {
|
||||||
}
|
api(project(":kotlin-stdlib"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val main by compilations.getting
|
|
||||||
val test by compilations.getting
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -257,6 +257,9 @@ public final class org/jetbrains/kotlin/gradle/dsl/KotlinCompile$DefaultImpls {
|
|||||||
public static fun kotlinOptions (Lorg/jetbrains/kotlin/gradle/dsl/KotlinCompile;Lorg/gradle/api/Action;)V
|
public static fun kotlinOptions (Lorg/jetbrains/kotlin/gradle/dsl/KotlinCompile;Lorg/gradle/api/Action;)V
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract interface annotation class org/jetbrains/kotlin/gradle/dsl/KotlinGradlePluginDsl : java/lang/annotation/Annotation {
|
||||||
|
}
|
||||||
|
|
||||||
public abstract interface class org/jetbrains/kotlin/gradle/dsl/KotlinHierarchyDsl {
|
public abstract interface class org/jetbrains/kotlin/gradle/dsl/KotlinHierarchyDsl {
|
||||||
public abstract fun applyHierarchyTemplate (Lkotlin/jvm/functions/Function1;)V
|
public abstract fun applyHierarchyTemplate (Lkotlin/jvm/functions/Function1;)V
|
||||||
public abstract fun applyHierarchyTemplate (Lorg/jetbrains/kotlin/gradle/plugin/KotlinHierarchyTemplate;)V
|
public abstract fun applyHierarchyTemplate (Lorg/jetbrains/kotlin/gradle/plugin/KotlinHierarchyTemplate;)V
|
||||||
|
|||||||
+14
@@ -0,0 +1,14 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Marks a Kotlin Gradle plugin DSL language.
|
||||||
|
*
|
||||||
|
* @see DslMarker
|
||||||
|
*/
|
||||||
|
@DslMarker
|
||||||
|
annotation class KotlinGradlePluginDsl
|
||||||
+1
@@ -15,6 +15,7 @@ package org.jetbrains.kotlin.gradle.dsl
|
|||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
|
@KotlinGradlePluginDsl
|
||||||
interface KotlinTopLevelExtensionConfig {
|
interface KotlinTopLevelExtensionConfig {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+2
@@ -18,9 +18,11 @@ import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
|
|||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonCompilerOptions
|
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.KotlinCompileDeprecated
|
import org.jetbrains.kotlin.gradle.dsl.KotlinCompileDeprecated
|
||||||
|
import org.jetbrains.kotlin.gradle.dsl.KotlinGradlePluginDsl
|
||||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask
|
||||||
import org.jetbrains.kotlin.tooling.core.HasMutableExtras
|
import org.jetbrains.kotlin.tooling.core.HasMutableExtras
|
||||||
|
|
||||||
|
@KotlinGradlePluginDsl
|
||||||
interface KotlinCompilation<out T : KotlinCommonOptionsDeprecated> : Named,
|
interface KotlinCompilation<out T : KotlinCommonOptionsDeprecated> : Named,
|
||||||
HasProject,
|
HasProject,
|
||||||
HasMutableExtras,
|
HasMutableExtras,
|
||||||
|
|||||||
+2
@@ -20,8 +20,10 @@ import org.jetbrains.kotlin.gradle.InternalKotlinGradlePluginApi
|
|||||||
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
|
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonCompilerOptions
|
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.tooling.core.HasMutableExtras
|
import org.jetbrains.kotlin.tooling.core.HasMutableExtras
|
||||||
|
|
||||||
|
@KotlinGradlePluginDsl
|
||||||
interface KotlinTarget : Named, HasAttributes, HasProject, HasMutableExtras {
|
interface KotlinTarget : Named, HasAttributes, HasProject, HasMutableExtras {
|
||||||
val targetName: String
|
val targetName: String
|
||||||
val disambiguationClassifier: String? get() = targetName
|
val disambiguationClassifier: String? get() = targetName
|
||||||
|
|||||||
+4
-3
@@ -22,9 +22,6 @@ kotlin {
|
|||||||
namespace = "org.jetbrains.sample"
|
namespace = "org.jetbrains.sample"
|
||||||
|
|
||||||
withAndroidTestOnJvm {}
|
withAndroidTestOnJvm {}
|
||||||
sourceSets.getByName("androidTestOnJvm").dependencies {
|
|
||||||
implementation("junit:junit:4.13.2")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
@@ -33,6 +30,10 @@ kotlin {
|
|||||||
api(project(":lib"))
|
api(project(":lib"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getByName("androidTestOnJvm").dependencies {
|
||||||
|
implementation("junit:junit:4.13.2")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-3
@@ -18,8 +18,9 @@ kotlin {
|
|||||||
namespace = "org.jetbrains.sample"
|
namespace = "org.jetbrains.sample"
|
||||||
|
|
||||||
withAndroidTestOnJvm {}
|
withAndroidTestOnJvm {}
|
||||||
sourceSets.getByName("androidTestOnJvm").dependencies {
|
}
|
||||||
implementation("junit:junit:4.13.2")
|
|
||||||
}
|
sourceSets.getByName("androidTestOnJvm").dependencies {
|
||||||
|
implementation("junit:junit:4.13.2")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -12,8 +12,8 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
|
jvmToolchain(8)
|
||||||
jvm {
|
jvm {
|
||||||
jvmToolchain(8)
|
|
||||||
withJava()
|
withJava()
|
||||||
}
|
}
|
||||||
js(IR) {
|
js(IR) {
|
||||||
|
|||||||
+5
-4
@@ -20,10 +20,11 @@ kotlin {
|
|||||||
freeCompilerArgs.add("-Xpartial-linkage=disable")
|
freeCompilerArgs.add("-Xpartial-linkage=disable")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sourceSets["commonMain"].dependencies {
|
}
|
||||||
implementation("org.sample:libb:1.0") // libb:1.0 is compatible with liba:1.0 only!
|
|
||||||
implementation("org.sample:liba:2.0") // liba:1.0 -> liba:2.0
|
sourceSets["commonMain"].dependencies {
|
||||||
}
|
implementation("org.sample:libb:1.0") // libb:1.0 is compatible with liba:1.0 only!
|
||||||
|
implementation("org.sample:liba:2.0") // liba:1.0 -> liba:2.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -13,10 +13,10 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
<SingleNativeTarget>("native") {
|
<SingleNativeTarget>("native")
|
||||||
sourceSets["nativeMain"].dependencies {
|
|
||||||
implementation("org.sample:liba:1.0")
|
sourceSets["nativeMain"].dependencies {
|
||||||
}
|
implementation("org.sample:liba:1.0")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-4
@@ -19,10 +19,11 @@ kotlin {
|
|||||||
freeCompilerArgs.add("-Xpartial-linkage=disable")
|
freeCompilerArgs.add("-Xpartial-linkage=disable")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sourceSets["commonMain"].dependencies {
|
}
|
||||||
implementation("io.ktor:ktor-client-core:1.5.4")
|
|
||||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0-RC-native-mt")
|
sourceSets["commonMain"].dependencies {
|
||||||
}
|
implementation("io.ktor:ktor-client-core:1.5.4")
|
||||||
|
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0-RC-native-mt")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-4
@@ -20,10 +20,11 @@ kotlin {
|
|||||||
freeCompilerArgs.add("-Xpartial-linkage=disable")
|
freeCompilerArgs.add("-Xpartial-linkage=disable")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sourceSets["commonMain"].dependencies {
|
}
|
||||||
implementation("org.sample:libb:1.0")
|
|
||||||
implementation("org.sample:liba:2.0")
|
sourceSets["commonMain"].dependencies {
|
||||||
}
|
implementation("org.sample:libb:1.0")
|
||||||
|
implementation("org.sample:liba:2.0")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -13,10 +13,10 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
<SingleNativeTarget>("native") {
|
<SingleNativeTarget>("native")
|
||||||
sourceSets["nativeMain"].dependencies {
|
|
||||||
implementation("org.sample:liba:1.0")
|
sourceSets["nativeMain"].dependencies {
|
||||||
}
|
implementation("org.sample:liba:1.0")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -11,9 +11,10 @@ kotlin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val commonMainSourceSet = sourceSets.commonMain.get()
|
||||||
jvm("mixed") {
|
jvm("mixed") {
|
||||||
configure(listOf(compilations.create("junit"), compilations.create("testng"))) {
|
configure(listOf(compilations.create("junit"), compilations.create("testng"))) {
|
||||||
defaultSourceSet.dependsOn(sourceSets["commonMain"])
|
defaultSourceSet.dependsOn(commonMainSourceSet)
|
||||||
attributes {
|
attributes {
|
||||||
attribute(testFrameworkAttribute, compilationName)
|
attribute(testFrameworkAttribute, compilationName)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user