[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,7 +11,8 @@ val jsStdlibSources = "${projectDir}/../stdlib/js/src"
|
||||
@Suppress("UNUSED_VARIABLE")
|
||||
kotlin {
|
||||
explicitApi()
|
||||
js {
|
||||
js()
|
||||
|
||||
sourceSets {
|
||||
val main by getting {
|
||||
if (!kotlinBuildProperties.isInIdeaSync) {
|
||||
@@ -25,9 +26,6 @@ kotlin {
|
||||
}
|
||||
}
|
||||
}
|
||||
val main by compilations.getting
|
||||
val test by compilations.getting
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile>().configureEach {
|
||||
|
||||
@@ -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 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 fun applyHierarchyTemplate (Lkotlin/jvm/functions/Function1;)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 {
|
||||
|
||||
/**
|
||||
|
||||
+2
@@ -18,9 +18,11 @@ import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonCompilerOptions
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonOptionsDeprecated
|
||||
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.tooling.core.HasMutableExtras
|
||||
|
||||
@KotlinGradlePluginDsl
|
||||
interface KotlinCompilation<out T : KotlinCommonOptionsDeprecated> : Named,
|
||||
HasProject,
|
||||
HasMutableExtras,
|
||||
|
||||
+2
@@ -20,8 +20,10 @@ import org.jetbrains.kotlin.gradle.InternalKotlinGradlePluginApi
|
||||
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonCompilerOptions
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonOptionsDeprecated
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinGradlePluginDsl
|
||||
import org.jetbrains.kotlin.tooling.core.HasMutableExtras
|
||||
|
||||
@KotlinGradlePluginDsl
|
||||
interface KotlinTarget : Named, HasAttributes, HasProject, HasMutableExtras {
|
||||
val targetName: String
|
||||
val disambiguationClassifier: String? get() = targetName
|
||||
|
||||
+4
-3
@@ -22,9 +22,6 @@ kotlin {
|
||||
namespace = "org.jetbrains.sample"
|
||||
|
||||
withAndroidTestOnJvm {}
|
||||
sourceSets.getByName("androidTestOnJvm").dependencies {
|
||||
implementation("junit:junit:4.13.2")
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
@@ -33,6 +30,10 @@ kotlin {
|
||||
api(project(":lib"))
|
||||
}
|
||||
}
|
||||
|
||||
getByName("androidTestOnJvm").dependencies {
|
||||
implementation("junit:junit:4.13.2")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -18,8 +18,9 @@ kotlin {
|
||||
namespace = "org.jetbrains.sample"
|
||||
|
||||
withAndroidTestOnJvm {}
|
||||
}
|
||||
|
||||
sourceSets.getByName("androidTestOnJvm").dependencies {
|
||||
implementation("junit:junit:4.13.2")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -12,8 +12,8 @@ repositories {
|
||||
}
|
||||
|
||||
kotlin {
|
||||
jvm {
|
||||
jvmToolchain(8)
|
||||
jvm {
|
||||
withJava()
|
||||
}
|
||||
js(IR) {
|
||||
|
||||
+2
-1
@@ -20,12 +20,13 @@ kotlin {
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val konanHome: String? by ext.properties
|
||||
val kotlinNativeCompilerVersion = konanHome?.let { org.jetbrains.kotlin.konan.target.Distribution(it).compilerVersion }
|
||||
|
||||
+2
-2
@@ -13,12 +13,12 @@ repositories {
|
||||
}
|
||||
|
||||
kotlin {
|
||||
<SingleNativeTarget>("native") {
|
||||
<SingleNativeTarget>("native")
|
||||
|
||||
sourceSets["nativeMain"].dependencies {
|
||||
implementation("org.sample:liba:1.0")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
publishing {
|
||||
repositories {
|
||||
|
||||
+2
-1
@@ -19,12 +19,13 @@ kotlin {
|
||||
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")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val konanHome: String? by ext.properties
|
||||
val kotlinNativeCompilerVersion = konanHome?.let { org.jetbrains.kotlin.konan.target.Distribution(it).compilerVersion }
|
||||
|
||||
+2
-1
@@ -20,12 +20,13 @@ kotlin {
|
||||
freeCompilerArgs.add("-Xpartial-linkage=disable")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets["commonMain"].dependencies {
|
||||
implementation("org.sample:libb:1.0")
|
||||
implementation("org.sample:liba:2.0")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val konanHome: String? by ext.properties
|
||||
val kotlinNativeCompilerVersion = konanHome?.let { org.jetbrains.kotlin.konan.target.Distribution(it).compilerVersion }
|
||||
|
||||
+2
-2
@@ -13,12 +13,12 @@ repositories {
|
||||
}
|
||||
|
||||
kotlin {
|
||||
<SingleNativeTarget>("native") {
|
||||
<SingleNativeTarget>("native")
|
||||
|
||||
sourceSets["nativeMain"].dependencies {
|
||||
implementation("org.sample:liba:1.0")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
publishing {
|
||||
repositories {
|
||||
|
||||
+2
-1
@@ -11,9 +11,10 @@ kotlin {
|
||||
}
|
||||
}
|
||||
|
||||
val commonMainSourceSet = sourceSets.commonMain.get()
|
||||
jvm("mixed") {
|
||||
configure(listOf(compilations.create("junit"), compilations.create("testng"))) {
|
||||
defaultSourceSet.dependsOn(sourceSets["commonMain"])
|
||||
defaultSourceSet.dependsOn(commonMainSourceSet)
|
||||
attributes {
|
||||
attribute(testFrameworkAttribute, compilationName)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user