[Gradle] Replace KotlinSourceSetTree interface with simpler class
^KT-58676 Verification Pending
This commit is contained in:
committed by
Space Team
parent
85f4b72c8b
commit
772bcb283d
@@ -1094,9 +1094,13 @@ public abstract interface class org/jetbrains/kotlin/gradle/plugin/KotlinSourceS
|
||||
public abstract fun getSourceSets ()Lorg/gradle/api/NamedDomainObjectContainer;
|
||||
}
|
||||
|
||||
public abstract interface class org/jetbrains/kotlin/gradle/plugin/KotlinSourceSetTree {
|
||||
public final class org/jetbrains/kotlin/gradle/plugin/KotlinSourceSetTree {
|
||||
public static final field Companion Lorg/jetbrains/kotlin/gradle/plugin/KotlinSourceSetTree$Companion;
|
||||
public abstract fun getName ()Ljava/lang/String;
|
||||
public fun <init> (Ljava/lang/String;)V
|
||||
public fun equals (Ljava/lang/Object;)Z
|
||||
public final fun getName ()Ljava/lang/String;
|
||||
public fun hashCode ()I
|
||||
public fun toString ()Ljava/lang/String;
|
||||
}
|
||||
|
||||
public final class org/jetbrains/kotlin/gradle/plugin/KotlinSourceSetTree$Companion {
|
||||
@@ -1107,10 +1111,6 @@ public final class org/jetbrains/kotlin/gradle/plugin/KotlinSourceSetTree$Compan
|
||||
public final fun getUnitTest ()Lorg/jetbrains/kotlin/gradle/plugin/KotlinSourceSetTree;
|
||||
}
|
||||
|
||||
public final class org/jetbrains/kotlin/gradle/plugin/KotlinSourceSetTreeKt {
|
||||
public static final fun KotlinSourceSetTree (Ljava/lang/String;)Lorg/jetbrains/kotlin/gradle/plugin/KotlinSourceSetTree;
|
||||
}
|
||||
|
||||
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 (Lorg/gradle/api/Action;)V
|
||||
@@ -1157,11 +1157,11 @@ public abstract interface class org/jetbrains/kotlin/gradle/plugin/KotlinTargetE
|
||||
public abstract interface class org/jetbrains/kotlin/gradle/plugin/KotlinTargetHierarchy {
|
||||
}
|
||||
|
||||
public final class org/jetbrains/kotlin/gradle/plugin/KotlinTargetHierarchy$SourceSetTree : org/jetbrains/kotlin/gradle/plugin/KotlinSourceSetTree {
|
||||
public final class org/jetbrains/kotlin/gradle/plugin/KotlinTargetHierarchy$SourceSetTree {
|
||||
public static final field Companion Lorg/jetbrains/kotlin/gradle/plugin/KotlinTargetHierarchy$SourceSetTree$Companion;
|
||||
public fun <init> (Ljava/lang/String;)V
|
||||
public fun equals (Ljava/lang/Object;)Z
|
||||
public fun getName ()Ljava/lang/String;
|
||||
public final fun getName ()Ljava/lang/String;
|
||||
public fun hashCode ()I
|
||||
public fun toString ()Ljava/lang/String;
|
||||
}
|
||||
|
||||
+33
-58
@@ -5,12 +5,6 @@
|
||||
|
||||
package org.jetbrains.kotlin.gradle.plugin
|
||||
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetTree.Companion.instrumentedTest
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetTree.Companion.integrationTest
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetTree.Companion.main
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetTree.Companion.test
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetTree.Companion.unitTest
|
||||
|
||||
/**
|
||||
* When applying any [KotlinHierarchyTemplate] (e.g. by calling `applyDefaultHierarchyTemplate()`), the descriptor will
|
||||
* be applied on individual compilations, creating multiple trees of shared SourceSets.
|
||||
@@ -60,59 +54,8 @@ import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetTree.Companion.unitTest
|
||||
* There are some exceptions, where the name of the compilations cannot be chosen by the user directly (Android)
|
||||
* In this case, the name of the SourceSet can be configured outside the target hierarchy DSL.
|
||||
*/
|
||||
sealed interface KotlinSourceSetTree {
|
||||
val name: String
|
||||
class KotlinSourceSetTree(val name: String) {
|
||||
|
||||
companion object {
|
||||
/**
|
||||
* The 'main' SourceSetTree. Typically, with 'commonMain' as the root SourceSet
|
||||
*/
|
||||
val main: KotlinSourceSetTree = KotlinSourceSetTreeImpl("main")
|
||||
|
||||
/**
|
||||
* The 'test' SourceSetTree. Typically, with 'commonTest' as the root SourceSet
|
||||
*/
|
||||
val test: KotlinSourceSetTree = KotlinSourceSetTreeImpl("test")
|
||||
|
||||
/**
|
||||
* Special pre-defined SourceSetTree: Can be used to introduce a new tree with 'commonUnitTest' as the root SourceSet
|
||||
* e.g. relevant for organising Android unitTest compilations/SourceSets
|
||||
*/
|
||||
val unitTest: KotlinSourceSetTree = KotlinSourceSetTreeImpl("unitTest")
|
||||
|
||||
|
||||
/**
|
||||
* Special pre-defined SourceSetTree: Can be used to introduce a new tree with 'commonInstrumentedTest' as the root SourceSet
|
||||
* e.g. relevant for organising Android instrumented compilations/SourceSets
|
||||
*/
|
||||
val instrumentedTest: KotlinSourceSetTree = KotlinSourceSetTreeImpl("instrumentedTest")
|
||||
|
||||
|
||||
/**
|
||||
* Special pre-defined SourceSetTree: Can be used to introduce a new tree with 'commonIntegrationTest' as root SourceSEt
|
||||
*/
|
||||
val integrationTest: KotlinSourceSetTree = KotlinSourceSetTreeImpl("integrationTest")
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
fun KotlinSourceSetTree(name: String): KotlinSourceSetTree {
|
||||
return when (name) {
|
||||
main.name -> main
|
||||
test.name -> test
|
||||
unitTest.name -> unitTest
|
||||
instrumentedTest.name -> instrumentedTest
|
||||
integrationTest.name -> integrationTest
|
||||
else -> KotlinSourceSetTreeImpl(name)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Implementation
|
||||
*/
|
||||
|
||||
|
||||
private class KotlinSourceSetTreeImpl(override val name: String) : KotlinSourceSetTree {
|
||||
override fun toString(): String = name
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
@@ -123,4 +66,36 @@ private class KotlinSourceSetTreeImpl(override val name: String) : KotlinSourceS
|
||||
override fun hashCode(): Int {
|
||||
return name.hashCode()
|
||||
}
|
||||
|
||||
companion object {
|
||||
/**
|
||||
* The 'main' SourceSetTree. Typically, with 'commonMain' as the root SourceSet
|
||||
*/
|
||||
val main: KotlinSourceSetTree = KotlinSourceSetTree("main")
|
||||
|
||||
/**
|
||||
* The 'test' SourceSetTree. Typically, with 'commonTest' as the root SourceSet
|
||||
*/
|
||||
val test: KotlinSourceSetTree = KotlinSourceSetTree("test")
|
||||
|
||||
/**
|
||||
* Special pre-defined SourceSetTree: Can be used to introduce a new tree with 'commonUnitTest' as the root SourceSet
|
||||
* e.g. relevant for organising Android unitTest compilations/SourceSets
|
||||
*/
|
||||
val unitTest: KotlinSourceSetTree = KotlinSourceSetTree("unitTest")
|
||||
|
||||
|
||||
/**
|
||||
* Special pre-defined SourceSetTree: Can be used to introduce a new tree with 'commonInstrumentedTest' as the root SourceSet
|
||||
* e.g. relevant for organising Android instrumented compilations/SourceSets
|
||||
*/
|
||||
val instrumentedTest: KotlinSourceSetTree = KotlinSourceSetTree("instrumentedTest")
|
||||
|
||||
|
||||
/**
|
||||
* Special pre-defined SourceSetTree: Can be used to introduce a new tree with 'commonIntegrationTest' as root SourceSEt
|
||||
*/
|
||||
val integrationTest: KotlinSourceSetTree = KotlinSourceSetTree("integrationTest")
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ package org.jetbrains.kotlin.gradle.plugin
|
||||
interface KotlinTargetHierarchy {
|
||||
|
||||
@Deprecated("Use KotlinSourceSetTree instead", replaceWith = ReplaceWith("KotlinSourceSetTree"))
|
||||
class SourceSetTree(override val name: String) : KotlinSourceSetTree {
|
||||
class SourceSetTree(val name: String) {
|
||||
override fun toString(): String = name
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
|
||||
+1
-1
@@ -106,7 +106,7 @@ internal suspend fun KotlinSourceSetTreeClassifier.classify(compilation: KotlinC
|
||||
is KotlinSourceSetTreeClassifier.Value -> tree
|
||||
is KotlinSourceSetTreeClassifier.Name -> KotlinSourceSetTree(name)
|
||||
is KotlinSourceSetTreeClassifier.None -> null
|
||||
is SourceSetTreeClassifierWrapper -> classifier.classify(compilation)
|
||||
is SourceSetTreeClassifierWrapper -> classifier.classify(compilation)?.name?.let(::KotlinSourceSetTree)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -41,13 +41,13 @@ sealed class SourceSetTreeClassifier {
|
||||
|
||||
|
||||
@ExternalKotlinTargetApi
|
||||
class Property(val property: org.gradle.api.provider.Property<KotlinSourceSetTree>) : SourceSetTreeClassifier() {
|
||||
class Property(val property: org.gradle.api.provider.Property<SourceSetTree>) : SourceSetTreeClassifier() {
|
||||
override fun toString(): String {
|
||||
return property.toString()
|
||||
}
|
||||
}
|
||||
|
||||
internal suspend fun classify(compilation: KotlinCompilation<*>): KotlinSourceSetTree? {
|
||||
internal suspend fun classify(compilation: KotlinCompilation<*>): SourceSetTree? {
|
||||
return when (this) {
|
||||
is Default -> SourceSetTree(compilation.name)
|
||||
is Property -> property.awaitFinalValue()
|
||||
|
||||
-1
@@ -13,7 +13,6 @@ import org.gradle.api.attributes.Attribute
|
||||
import org.gradle.api.attributes.AttributeContainer
|
||||
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
|
||||
import org.jetbrains.kotlin.gradle.plugin.*
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinTargetHierarchy.SourceSetTree
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.util.copyAttributes
|
||||
import org.jetbrains.kotlin.gradle.utils.dashSeparatedName
|
||||
import org.jetbrains.kotlin.gradle.utils.forAllAndroidVariants
|
||||
|
||||
+1
-2
@@ -10,14 +10,13 @@ import org.gradle.api.model.ObjectFactory
|
||||
import org.gradle.api.provider.Property
|
||||
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetTree
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinTargetHierarchy.SourceSetTree
|
||||
import org.jetbrains.kotlin.gradle.utils.property
|
||||
|
||||
|
||||
@ExperimentalKotlinGradlePluginApi
|
||||
interface KotlinAndroidTargetVariantDsl {
|
||||
/**
|
||||
* Configures under which [SourceSetTree] the currently configured Android Variant shall be placed.
|
||||
* Configures under which [KotlinSourceSetTree] the currently configured Android Variant shall be placed.
|
||||
* e.g.
|
||||
*
|
||||
* ```kotlin
|
||||
|
||||
Reference in New Issue
Block a user