[Gradle] Stabilise Kotlin Hierarchy Template DSL
- Remove 'Target' name from hierarchy components as in
- KotlinTargetHierarchyBuilder -> KotlinHierarchyBuilder
- KotlinTargetHierarchyDsl -> KotlinHierarchyDsl
- Rename KotlinTargetHierarchyDescriptor -> KotlinHierarchyTemplate
To convey a better intuition about the 'template' vs 'layout' separation:
A 'template' is used to 'layout' the actual 'hierarchy' on a given project.
- Move entities from .mpp.targetHierarchy to .hierarchy package
As the .targetHierarchy package was using the 'target' term as well
- Rename SourceSetTree to KotlinSourceSetTree
- Rename SourceSetTreeClassifier to KotlinSourceSetTreeClassifier
(Support external target APIs by introducing a V2 api version)
^KT-58676 In Progress
This commit is contained in:
committed by
Space Team
parent
cb087b7def
commit
b2dd83515c
@@ -242,6 +242,12 @@ 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 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
|
||||
public abstract fun applyHierarchyTemplate (Lorg/jetbrains/kotlin/gradle/plugin/KotlinHierarchyTemplate;Lkotlin/jvm/functions/Function1;)V
|
||||
}
|
||||
|
||||
public abstract interface class org/jetbrains/kotlin/gradle/dsl/KotlinJsCompilerOptions : org/jetbrains/kotlin/gradle/dsl/KotlinCommonCompilerOptions {
|
||||
public abstract fun getFriendModulesDisabled ()Lorg/gradle/api/provider/Property;
|
||||
public abstract fun getMain ()Lorg/gradle/api/provider/Property;
|
||||
@@ -519,17 +525,6 @@ public abstract interface class org/jetbrains/kotlin/gradle/dsl/KotlinNativeXCFr
|
||||
public abstract fun targets ([Lorg/jetbrains/kotlin/konan/target/KonanTarget;)V
|
||||
}
|
||||
|
||||
public abstract interface class org/jetbrains/kotlin/gradle/dsl/KotlinTargetHierarchyDsl {
|
||||
public abstract fun apply (Lorg/jetbrains/kotlin/gradle/plugin/KotlinTargetHierarchyDescriptor;Lkotlin/jvm/functions/Function1;)V
|
||||
public abstract fun custom (Lkotlin/jvm/functions/Function1;)V
|
||||
public abstract fun default (Lkotlin/jvm/functions/Function1;)V
|
||||
}
|
||||
|
||||
public final class org/jetbrains/kotlin/gradle/dsl/KotlinTargetHierarchyDsl$DefaultImpls {
|
||||
public static synthetic fun apply$default (Lorg/jetbrains/kotlin/gradle/dsl/KotlinTargetHierarchyDsl;Lorg/jetbrains/kotlin/gradle/plugin/KotlinTargetHierarchyDescriptor;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)V
|
||||
public static synthetic fun default$default (Lorg/jetbrains/kotlin/gradle/dsl/KotlinTargetHierarchyDsl;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)V
|
||||
}
|
||||
|
||||
public abstract interface class org/jetbrains/kotlin/gradle/dsl/KotlinTopLevelExtensionConfig {
|
||||
public abstract fun explicitApi ()V
|
||||
public abstract fun explicitApiWarning ()V
|
||||
@@ -902,6 +897,87 @@ public abstract interface class org/jetbrains/kotlin/gradle/plugin/KotlinExecuti
|
||||
public abstract interface class org/jetbrains/kotlin/gradle/plugin/KotlinGradleSubplugin {
|
||||
}
|
||||
|
||||
public abstract interface class org/jetbrains/kotlin/gradle/plugin/KotlinHierarchyBuilder {
|
||||
public abstract fun common (Lkotlin/jvm/functions/Function1;)V
|
||||
public abstract fun excludeCompilations (Lkotlin/jvm/functions/Function1;)V
|
||||
public abstract fun filterCompilations (Lkotlin/jvm/functions/Function1;)V
|
||||
public abstract fun group (Ljava/lang/String;Lkotlin/jvm/functions/Function1;)V
|
||||
public abstract fun withAndroid ()V
|
||||
public abstract fun withAndroidNative ()V
|
||||
public abstract fun withAndroidNativeArm32 ()V
|
||||
public abstract fun withAndroidNativeArm64 ()V
|
||||
public abstract fun withAndroidNativeX64 ()V
|
||||
public abstract fun withAndroidNativeX86 ()V
|
||||
public abstract fun withAndroidTarget ()V
|
||||
public abstract fun withApple ()V
|
||||
public abstract fun withCompilations (Lkotlin/jvm/functions/Function1;)V
|
||||
public abstract fun withIos ()V
|
||||
public abstract fun withIosArm32 ()V
|
||||
public abstract fun withIosArm64 ()V
|
||||
public abstract fun withIosSimulatorArm64 ()V
|
||||
public abstract fun withIosX64 ()V
|
||||
public abstract fun withJs ()V
|
||||
public abstract fun withJvm ()V
|
||||
public abstract fun withLinux ()V
|
||||
public abstract fun withLinuxArm32Hfp ()V
|
||||
public abstract fun withLinuxArm64 ()V
|
||||
public abstract fun withLinuxMips32 ()V
|
||||
public abstract fun withLinuxMipsel32 ()V
|
||||
public abstract fun withLinuxX64 ()V
|
||||
public abstract fun withMacos ()V
|
||||
public abstract fun withMacosArm64 ()V
|
||||
public abstract fun withMacosX64 ()V
|
||||
public abstract fun withMingw ()V
|
||||
public abstract fun withMingwX64 ()V
|
||||
public abstract fun withMingwX86 ()V
|
||||
public abstract fun withNative ()V
|
||||
public abstract fun withTvos ()V
|
||||
public abstract fun withTvosArm64 ()V
|
||||
public abstract fun withTvosSimulatorArm64 ()V
|
||||
public abstract fun withTvosX64 ()V
|
||||
public abstract fun withWasm ()V
|
||||
public abstract fun withWasm32 ()V
|
||||
public abstract fun withWatchos ()V
|
||||
public abstract fun withWatchosArm32 ()V
|
||||
public abstract fun withWatchosArm64 ()V
|
||||
public abstract fun withWatchosDeviceArm64 ()V
|
||||
public abstract fun withWatchosSimulatorArm64 ()V
|
||||
public abstract fun withWatchosX64 ()V
|
||||
public abstract fun withWatchosX86 ()V
|
||||
public abstract fun withoutCompilations (Lkotlin/jvm/functions/Function1;)V
|
||||
}
|
||||
|
||||
public final class org/jetbrains/kotlin/gradle/plugin/KotlinHierarchyBuilder$DefaultImpls {
|
||||
public static fun common (Lorg/jetbrains/kotlin/gradle/plugin/KotlinHierarchyBuilder;Lkotlin/jvm/functions/Function1;)V
|
||||
public static fun filterCompilations (Lorg/jetbrains/kotlin/gradle/plugin/KotlinHierarchyBuilder;Lkotlin/jvm/functions/Function1;)V
|
||||
public static synthetic fun group$default (Lorg/jetbrains/kotlin/gradle/plugin/KotlinHierarchyBuilder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)V
|
||||
public static fun withoutCompilations (Lorg/jetbrains/kotlin/gradle/plugin/KotlinHierarchyBuilder;Lkotlin/jvm/functions/Function1;)V
|
||||
}
|
||||
|
||||
public abstract interface class org/jetbrains/kotlin/gradle/plugin/KotlinHierarchyBuilder$Root : org/jetbrains/kotlin/gradle/plugin/KotlinHierarchyBuilder {
|
||||
public abstract fun excludeSourceSetTree ([Lorg/jetbrains/kotlin/gradle/plugin/KotlinSourceSetTree;)V
|
||||
public abstract fun sourceSetTrees ([Lorg/jetbrains/kotlin/gradle/plugin/KotlinSourceSetTree;)V
|
||||
public abstract fun withSourceSetTree ([Lorg/jetbrains/kotlin/gradle/plugin/KotlinSourceSetTree;)V
|
||||
}
|
||||
|
||||
public final class org/jetbrains/kotlin/gradle/plugin/KotlinHierarchyBuilder$Root$DefaultImpls {
|
||||
public static fun common (Lorg/jetbrains/kotlin/gradle/plugin/KotlinHierarchyBuilder$Root;Lkotlin/jvm/functions/Function1;)V
|
||||
public static fun filterCompilations (Lorg/jetbrains/kotlin/gradle/plugin/KotlinHierarchyBuilder$Root;Lkotlin/jvm/functions/Function1;)V
|
||||
public static fun withoutCompilations (Lorg/jetbrains/kotlin/gradle/plugin/KotlinHierarchyBuilder$Root;Lkotlin/jvm/functions/Function1;)V
|
||||
}
|
||||
|
||||
public abstract interface class org/jetbrains/kotlin/gradle/plugin/KotlinHierarchyTemplate {
|
||||
public static final field Templates Lorg/jetbrains/kotlin/gradle/plugin/KotlinHierarchyTemplate$Templates;
|
||||
}
|
||||
|
||||
public final class org/jetbrains/kotlin/gradle/plugin/KotlinHierarchyTemplate$Templates {
|
||||
}
|
||||
|
||||
public final class org/jetbrains/kotlin/gradle/plugin/KotlinHierarchyTemplateKt {
|
||||
public static final fun KotlinHierarchyTemplate (Lkotlin/jvm/functions/Function1;)Lorg/jetbrains/kotlin/gradle/plugin/KotlinHierarchyTemplate;
|
||||
public static final fun extend (Lorg/jetbrains/kotlin/gradle/plugin/KotlinHierarchyTemplate;Lkotlin/jvm/functions/Function1;)Lorg/jetbrains/kotlin/gradle/plugin/KotlinHierarchyTemplate;
|
||||
}
|
||||
|
||||
public final class org/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerType : java/lang/Enum {
|
||||
public static final field BOTH Lorg/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerType;
|
||||
public static final field Companion Lorg/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerType$Companion;
|
||||
@@ -1017,6 +1093,23 @@ 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 static final field Companion Lorg/jetbrains/kotlin/gradle/plugin/KotlinSourceSetTree$Companion;
|
||||
public abstract fun getName ()Ljava/lang/String;
|
||||
}
|
||||
|
||||
public final class org/jetbrains/kotlin/gradle/plugin/KotlinSourceSetTree$Companion {
|
||||
public final fun getInstrumentedTest ()Lorg/jetbrains/kotlin/gradle/plugin/KotlinSourceSetTree;
|
||||
public final fun getIntegrationTest ()Lorg/jetbrains/kotlin/gradle/plugin/KotlinSourceSetTree;
|
||||
public final fun getMain ()Lorg/jetbrains/kotlin/gradle/plugin/KotlinSourceSetTree;
|
||||
public final fun getTest ()Lorg/jetbrains/kotlin/gradle/plugin/KotlinSourceSetTree;
|
||||
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
|
||||
@@ -1063,11 +1156,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 {
|
||||
public final class org/jetbrains/kotlin/gradle/plugin/KotlinTargetHierarchy$SourceSetTree : org/jetbrains/kotlin/gradle/plugin/KotlinSourceSetTree {
|
||||
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 final fun getName ()Ljava/lang/String;
|
||||
public fun getName ()Ljava/lang/String;
|
||||
public fun hashCode ()I
|
||||
public fun toString ()Ljava/lang/String;
|
||||
}
|
||||
@@ -1080,84 +1173,6 @@ public final class org/jetbrains/kotlin/gradle/plugin/KotlinTargetHierarchy$Sour
|
||||
public final fun getUnitTest ()Lorg/jetbrains/kotlin/gradle/plugin/KotlinTargetHierarchy$SourceSetTree;
|
||||
}
|
||||
|
||||
public abstract interface class org/jetbrains/kotlin/gradle/plugin/KotlinTargetHierarchyBuilder {
|
||||
public abstract fun common (Lkotlin/jvm/functions/Function1;)V
|
||||
public abstract fun excludeCompilations (Lkotlin/jvm/functions/Function1;)V
|
||||
public abstract fun filterCompilations (Lkotlin/jvm/functions/Function1;)V
|
||||
public abstract fun group (Ljava/lang/String;Lkotlin/jvm/functions/Function1;)V
|
||||
public abstract fun withAndroid ()V
|
||||
public abstract fun withAndroidNative ()V
|
||||
public abstract fun withAndroidNativeArm32 ()V
|
||||
public abstract fun withAndroidNativeArm64 ()V
|
||||
public abstract fun withAndroidNativeX64 ()V
|
||||
public abstract fun withAndroidNativeX86 ()V
|
||||
public abstract fun withAndroidTarget ()V
|
||||
public abstract fun withApple ()V
|
||||
public abstract fun withCompilations (Lkotlin/jvm/functions/Function1;)V
|
||||
public abstract fun withIos ()V
|
||||
public abstract fun withIosArm32 ()V
|
||||
public abstract fun withIosArm64 ()V
|
||||
public abstract fun withIosSimulatorArm64 ()V
|
||||
public abstract fun withIosX64 ()V
|
||||
public abstract fun withJs ()V
|
||||
public abstract fun withJvm ()V
|
||||
public abstract fun withLinux ()V
|
||||
public abstract fun withLinuxArm32Hfp ()V
|
||||
public abstract fun withLinuxArm64 ()V
|
||||
public abstract fun withLinuxMips32 ()V
|
||||
public abstract fun withLinuxMipsel32 ()V
|
||||
public abstract fun withLinuxX64 ()V
|
||||
public abstract fun withMacos ()V
|
||||
public abstract fun withMacosArm64 ()V
|
||||
public abstract fun withMacosX64 ()V
|
||||
public abstract fun withMingw ()V
|
||||
public abstract fun withMingwX64 ()V
|
||||
public abstract fun withMingwX86 ()V
|
||||
public abstract fun withNative ()V
|
||||
public abstract fun withTvos ()V
|
||||
public abstract fun withTvosArm64 ()V
|
||||
public abstract fun withTvosSimulatorArm64 ()V
|
||||
public abstract fun withTvosX64 ()V
|
||||
public abstract fun withWasm ()V
|
||||
public abstract fun withWasm32 ()V
|
||||
public abstract fun withWatchos ()V
|
||||
public abstract fun withWatchosArm32 ()V
|
||||
public abstract fun withWatchosArm64 ()V
|
||||
public abstract fun withWatchosDeviceArm64 ()V
|
||||
public abstract fun withWatchosSimulatorArm64 ()V
|
||||
public abstract fun withWatchosX64 ()V
|
||||
public abstract fun withWatchosX86 ()V
|
||||
public abstract fun withoutCompilations (Lkotlin/jvm/functions/Function1;)V
|
||||
}
|
||||
|
||||
public final class org/jetbrains/kotlin/gradle/plugin/KotlinTargetHierarchyBuilder$DefaultImpls {
|
||||
public static fun common (Lorg/jetbrains/kotlin/gradle/plugin/KotlinTargetHierarchyBuilder;Lkotlin/jvm/functions/Function1;)V
|
||||
public static fun filterCompilations (Lorg/jetbrains/kotlin/gradle/plugin/KotlinTargetHierarchyBuilder;Lkotlin/jvm/functions/Function1;)V
|
||||
public static synthetic fun group$default (Lorg/jetbrains/kotlin/gradle/plugin/KotlinTargetHierarchyBuilder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)V
|
||||
public static fun withoutCompilations (Lorg/jetbrains/kotlin/gradle/plugin/KotlinTargetHierarchyBuilder;Lkotlin/jvm/functions/Function1;)V
|
||||
}
|
||||
|
||||
public abstract interface class org/jetbrains/kotlin/gradle/plugin/KotlinTargetHierarchyBuilder$Root : org/jetbrains/kotlin/gradle/plugin/KotlinTargetHierarchyBuilder {
|
||||
public abstract fun excludeSourceSetTree ([Lorg/jetbrains/kotlin/gradle/plugin/KotlinTargetHierarchy$SourceSetTree;)V
|
||||
public abstract fun sourceSetTrees ([Lorg/jetbrains/kotlin/gradle/plugin/KotlinTargetHierarchy$SourceSetTree;)V
|
||||
public abstract fun withSourceSetTree ([Lorg/jetbrains/kotlin/gradle/plugin/KotlinTargetHierarchy$SourceSetTree;)V
|
||||
}
|
||||
|
||||
public final class org/jetbrains/kotlin/gradle/plugin/KotlinTargetHierarchyBuilder$Root$DefaultImpls {
|
||||
public static fun common (Lorg/jetbrains/kotlin/gradle/plugin/KotlinTargetHierarchyBuilder$Root;Lkotlin/jvm/functions/Function1;)V
|
||||
public static fun filterCompilations (Lorg/jetbrains/kotlin/gradle/plugin/KotlinTargetHierarchyBuilder$Root;Lkotlin/jvm/functions/Function1;)V
|
||||
public static fun withoutCompilations (Lorg/jetbrains/kotlin/gradle/plugin/KotlinTargetHierarchyBuilder$Root;Lkotlin/jvm/functions/Function1;)V
|
||||
}
|
||||
|
||||
public abstract interface class org/jetbrains/kotlin/gradle/plugin/KotlinTargetHierarchyDescriptor {
|
||||
public abstract fun describe (Lorg/jetbrains/kotlin/gradle/plugin/KotlinTargetHierarchyBuilder$Root;)V
|
||||
public abstract fun extend (Lkotlin/jvm/functions/Function1;)Lorg/jetbrains/kotlin/gradle/plugin/KotlinTargetHierarchyDescriptor;
|
||||
}
|
||||
|
||||
public final class org/jetbrains/kotlin/gradle/plugin/KotlinTargetHierarchyDescriptorKt {
|
||||
public static final fun KotlinTargetHierarchyDescriptor (Lkotlin/jvm/functions/Function1;)Lorg/jetbrains/kotlin/gradle/plugin/KotlinTargetHierarchyDescriptor;
|
||||
}
|
||||
|
||||
public abstract interface class org/jetbrains/kotlin/gradle/plugin/KotlinTargetPreset : org/gradle/api/Named {
|
||||
public abstract fun createTarget (Ljava/lang/String;)Lorg/jetbrains/kotlin/gradle/plugin/KotlinTarget;
|
||||
}
|
||||
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* 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.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinHierarchyBuilder
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinHierarchyTemplate
|
||||
|
||||
interface KotlinHierarchyDsl {
|
||||
fun applyHierarchyTemplate(template: KotlinHierarchyTemplate)
|
||||
|
||||
@ExperimentalKotlinGradlePluginApi
|
||||
fun applyHierarchyTemplate(template: KotlinHierarchyTemplate, extension: KotlinHierarchyBuilder.Root.() -> Unit)
|
||||
|
||||
@ExperimentalKotlinGradlePluginApi
|
||||
fun applyHierarchyTemplate(template: KotlinHierarchyBuilder.Root.() -> Unit)
|
||||
}
|
||||
-171
@@ -1,171 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2022 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.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinTarget
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinTargetHierarchy.SourceSetTree
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinTargetHierarchyBuilder
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinTargetHierarchyDescriptor
|
||||
|
||||
@ExperimentalKotlinGradlePluginApi
|
||||
interface KotlinTargetHierarchyDsl {
|
||||
fun apply(
|
||||
hierarchyDescriptor: KotlinTargetHierarchyDescriptor,
|
||||
describeExtension: (KotlinTargetHierarchyBuilder.Root.() -> Unit)? = null
|
||||
)
|
||||
|
||||
/**
|
||||
* Set's up a 'natural'/'default' hierarchy withing [KotlinTarget]'s in the project.
|
||||
*
|
||||
* #### Example 1
|
||||
*
|
||||
* ```kotlin
|
||||
* kotlin {
|
||||
* targetHierarchy.default() // <- position of this call is not relevant!
|
||||
*
|
||||
* iosX64()
|
||||
* iosArm64()
|
||||
* linuxX64()
|
||||
* linuxArm64()
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* Will create the following SourceSets:
|
||||
* `[iosMain, iosTest, appleMain, appleTest, linuxMain, linuxTest, nativeMain, nativeTest]
|
||||
*
|
||||
*
|
||||
* Hierarchy:
|
||||
* ```
|
||||
* common
|
||||
* |
|
||||
* +-----------------+-------------------+
|
||||
* | |
|
||||
*
|
||||
* native ...
|
||||
*
|
||||
* |
|
||||
* |
|
||||
* |
|
||||
* +----------------------+--------------------+-----------------------+
|
||||
* | | | |
|
||||
*
|
||||
* apple linux mingw androidNative
|
||||
*
|
||||
* |
|
||||
* +-----------+------------+------------+
|
||||
* | | | |
|
||||
*
|
||||
* macos ios tvos watchos
|
||||
* ```
|
||||
*
|
||||
* #### Example 2: Adding custom groups
|
||||
* Let's imagine we would additionally like to share code between linux and apple (unixLike)
|
||||
*
|
||||
* ```kotlin
|
||||
* kotlin {
|
||||
* targetHierarchy.default { target ->
|
||||
* group("native") { // <- we can re-declare already existing groups and connect children to it!
|
||||
* group("unixLike") {
|
||||
* withLinux()
|
||||
* withApple()
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @param describeExtension: Additional groups can be described to extend the 'default'/'natural' hierarchy:
|
||||
* @see KotlinTargetHierarchyDescriptor.extend
|
||||
*/
|
||||
fun default(describeExtension: (KotlinTargetHierarchyBuilder.Root.() -> Unit)? = null)
|
||||
|
||||
/**
|
||||
* Allows to create a fully custom hierarchy (no defaults applied)
|
||||
* Note: Using the custom hierarchy will also require to set the edges to 'commonMain' and 'commonTest' SourceSets by
|
||||
* using the `common` group.
|
||||
*
|
||||
* #### Example 1:
|
||||
* Sharing code between iOS and a jvmTarget:
|
||||
* ```kotlin
|
||||
* targetHierarchy.custom {
|
||||
* common {
|
||||
* withJvm()
|
||||
* group("ios") {
|
||||
* withIos()
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* Will create two [SourceSetTree] using the 'common' and 'ios' groups, applied on the "test" and "main" compilations:
|
||||
* When the following targets are specified:
|
||||
* - jvm()
|
||||
* - iosX64()
|
||||
* - iosArm64()
|
||||
* ```
|
||||
* "main" "test"
|
||||
* commonMain commonTest
|
||||
* | |
|
||||
* | |
|
||||
* +----------+----------+ +----------+----------+
|
||||
* | | | |
|
||||
* iosMain jvmMain iosTest jvmTest
|
||||
* | |
|
||||
* +----+-----+ +----+-----+
|
||||
* | | | |
|
||||
* iosX64Main iosArm64Main iosX64Test iosArm64Test
|
||||
* ```
|
||||
*
|
||||
* #### Example 2: Creating a 'diamond structure'
|
||||
* ```kotlin
|
||||
* targetHierarchy.custom {
|
||||
* common {
|
||||
* group("ios") {
|
||||
* withIos()
|
||||
* }
|
||||
*
|
||||
* group("frontend") {
|
||||
* withJvm()
|
||||
* group("ios") // <- ! We can again reference the 'ios' group
|
||||
* }
|
||||
*
|
||||
* group("apple") {
|
||||
* withMacos()
|
||||
* group("ios") // <- ! We can again reference the 'ios' group
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* In this case, the _group_ "ios" can be created with 'group("ios")' and later referenced with the same construction to build
|
||||
* the tree. Applying the descriptor from the example to the following targets:
|
||||
* - iosX64()
|
||||
* - iosArm64()
|
||||
* - macosX64()
|
||||
* - jvm()
|
||||
*
|
||||
* will create the following 'main' SourceSetTree:
|
||||
*
|
||||
* ```
|
||||
* commonMain
|
||||
* |
|
||||
* +------------+----------+
|
||||
* | |
|
||||
* frontendMain appleMain
|
||||
* | |
|
||||
* +---------+------------+-----------+----------+
|
||||
* | | |
|
||||
* jvmMain iosMain macosX64Main
|
||||
* |
|
||||
* |
|
||||
* +----+----+
|
||||
* | |
|
||||
* iosX64Main iosArm64Main
|
||||
* ```
|
||||
*/
|
||||
fun custom(describe: KotlinTargetHierarchyBuilder.Root.() -> Unit)
|
||||
}
|
||||
-2
@@ -9,7 +9,6 @@ package org.jetbrains.kotlin.gradle.plugin
|
||||
|
||||
import org.gradle.api.Action
|
||||
import org.gradle.api.Named
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.attributes.AttributeContainer
|
||||
import org.gradle.api.attributes.HasAttributes
|
||||
import org.gradle.api.file.FileCollection
|
||||
@@ -17,7 +16,6 @@ import org.gradle.api.file.SourceDirectorySet
|
||||
import org.gradle.api.tasks.TaskProvider
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonOptionsDeprecated
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinCompileDeprecated
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinTargetHierarchyDsl
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask
|
||||
import org.jetbrains.kotlin.tooling.core.HasMutableExtras
|
||||
|
||||
|
||||
+12
-14
@@ -1,5 +1,3 @@
|
||||
// DO NOT EDIT MANUALLY! Generated by org.jetbrains.kotlin.generators.gradle.dsl.MppKotlinTargetHierarchyBuilderCodegenKt
|
||||
|
||||
package org.jetbrains.kotlin.gradle.plugin
|
||||
|
||||
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
|
||||
@@ -7,18 +5,18 @@ import org.jetbrains.kotlin.konan.target.DEPRECATED_TARGET_MESSAGE
|
||||
|
||||
@KotlinTargetsDsl
|
||||
@ExperimentalKotlinGradlePluginApi
|
||||
interface KotlinTargetHierarchyBuilder {
|
||||
interface KotlinHierarchyBuilder {
|
||||
|
||||
@KotlinTargetsDsl
|
||||
@ExperimentalKotlinGradlePluginApi
|
||||
interface Root : KotlinTargetHierarchyBuilder {
|
||||
interface Root : KotlinHierarchyBuilder {
|
||||
/**
|
||||
* Defines the trees that the described hierarchy is applied to.
|
||||
* ### Example 1: Only apply a hierarchy for the "main" and "test" [KotlinTargetHierarchy.SourceSetTree]
|
||||
* ### Example 1: Only apply a hierarchy for the "main" and "test" [KotlinSourceSetTree]
|
||||
*
|
||||
* ```kotlin
|
||||
* targetHierarchy.custom {
|
||||
* sourceSetTrees(SourceSetTree.main, SourceSetTree.test)
|
||||
* applyHierarchyTemplate {
|
||||
* sourceSetTrees(KotlinSourceSetTree.main, KotlinSourceSetTree.test)
|
||||
* common {
|
||||
* withJvm()
|
||||
* group("ios") {
|
||||
@@ -45,7 +43,7 @@ interface KotlinTargetHierarchyBuilder {
|
||||
* ### Example 2:
|
||||
* Using a different hierarchy for "main" and "test"
|
||||
*```kotlin
|
||||
* targetHierarchy.custom {
|
||||
* applyHierarchyTemplate {
|
||||
* sourceSetTrees(SourceSetTree.main) // ! <- only applied to the "main" tree
|
||||
* common {
|
||||
* withJvm()
|
||||
@@ -55,7 +53,7 @@ interface KotlinTargetHierarchyBuilder {
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* targetHierarchy.custom {
|
||||
* applyHierarchyTemplate {
|
||||
* sourceSetTrees(SourceSetTree.test) // ! <- only applied to the "test" tree
|
||||
* common {
|
||||
* withJvm()
|
||||
@@ -78,19 +76,19 @@ interface KotlinTargetHierarchyBuilder {
|
||||
* iosX64Main iosArm64Main
|
||||
* ```
|
||||
*/
|
||||
fun sourceSetTrees(vararg tree: KotlinTargetHierarchy.SourceSetTree)
|
||||
fun sourceSetTrees(vararg tree: KotlinSourceSetTree)
|
||||
|
||||
/**
|
||||
* Will add the given [tree]s into for this descriptor.
|
||||
* @see sourceSetTrees
|
||||
*/
|
||||
fun withSourceSetTree(vararg tree: KotlinTargetHierarchy.SourceSetTree)
|
||||
fun withSourceSetTree(vararg tree: KotlinSourceSetTree)
|
||||
|
||||
/**
|
||||
* Will remove the given [tree]s from this descriptor
|
||||
* @see sourceSetTrees
|
||||
*/
|
||||
fun excludeSourceSetTree(vararg tree: KotlinTargetHierarchy.SourceSetTree)
|
||||
fun excludeSourceSetTree(vararg tree: KotlinSourceSetTree)
|
||||
}
|
||||
|
||||
/* Declaring groups */
|
||||
@@ -112,8 +110,8 @@ interface KotlinTargetHierarchyBuilder {
|
||||
* depend on the usual 'commonMain'
|
||||
*
|
||||
*/
|
||||
fun common(build: KotlinTargetHierarchyBuilder.() -> Unit) = group("common", build)
|
||||
fun group(name: String, build: KotlinTargetHierarchyBuilder.() -> Unit = {})
|
||||
fun common(build: KotlinHierarchyBuilder.() -> Unit) = group("common", build)
|
||||
fun group(name: String, build: KotlinHierarchyBuilder.() -> Unit = {})
|
||||
|
||||
/* low-level APIs */
|
||||
fun withCompilations(predicate: (KotlinCompilation<*>) -> Boolean)
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* 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.plugin
|
||||
|
||||
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
|
||||
import org.jetbrains.kotlin.gradle.InternalKotlinGradlePluginApi
|
||||
|
||||
|
||||
|
||||
sealed interface KotlinHierarchyTemplate {
|
||||
companion object Templates
|
||||
}
|
||||
|
||||
/*
|
||||
EXPERIMENTAL API
|
||||
*/
|
||||
|
||||
@ExperimentalKotlinGradlePluginApi
|
||||
fun KotlinHierarchyTemplate(
|
||||
describe: KotlinHierarchyBuilder.Root.() -> Unit
|
||||
): KotlinHierarchyTemplate {
|
||||
return KotlinHierarchyTemplateImpl(describe)
|
||||
}
|
||||
|
||||
@ExperimentalKotlinGradlePluginApi
|
||||
fun KotlinHierarchyTemplate.extend(describe: KotlinHierarchyBuilder.Root.() -> Unit): KotlinHierarchyTemplate {
|
||||
return KotlinHierarchyTemplate {
|
||||
this@extend.internal.layout(this)
|
||||
describe()
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
INTERNAL API
|
||||
*/
|
||||
|
||||
@InternalKotlinGradlePluginApi
|
||||
@OptIn(ExperimentalKotlinGradlePluginApi::class)
|
||||
fun KotlinHierarchyBuilder.Root.applyHierarchyTemplate(template: KotlinHierarchyTemplate) {
|
||||
template.internal.layout(this)
|
||||
}
|
||||
|
||||
internal val KotlinHierarchyTemplate.internal
|
||||
get() = when (this) {
|
||||
is InternalKotlinHierarchyTemplate -> this
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalKotlinGradlePluginApi::class)
|
||||
internal interface InternalKotlinHierarchyTemplate : KotlinHierarchyTemplate {
|
||||
fun layout(builder: KotlinHierarchyBuilder.Root)
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalKotlinGradlePluginApi::class)
|
||||
internal class KotlinHierarchyTemplateImpl(
|
||||
private val describe: KotlinHierarchyBuilder.Root.() -> Unit
|
||||
) : InternalKotlinHierarchyTemplate {
|
||||
override fun layout(builder: KotlinHierarchyBuilder.Root) {
|
||||
describe(builder)
|
||||
}
|
||||
}
|
||||
+231
@@ -0,0 +1,231 @@
|
||||
/*
|
||||
* 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.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
|
||||
import org.jetbrains.kotlin.tooling.core.Interner
|
||||
|
||||
/**
|
||||
* When applying any [KotlinHierarchyTemplate] (e.g. by calling `applyDefaultHierarchyTemplate()`), the descriptor will
|
||||
* be applied on individual compilations, creating multiple trees of shared SourceSets.
|
||||
*
|
||||
* The name of given shared source set within the target hierarchy will be built by
|
||||
* `lowerCamelCase(nameOfGroup, nameOfSourceSetTree)`
|
||||
* So for the 'common' group within the 'main' tree the shared SourceSet name will be 'commonMain'
|
||||
*
|
||||
* The most default case will create two well known SourceSetTrees:
|
||||
* - The `main` tree with `commonMain` as its root SourceSet
|
||||
* - The `test` tree with `commonTest` as its root SourceSet
|
||||
*
|
||||
* e.g.
|
||||
* ```kotlin
|
||||
* kotlin {
|
||||
* applyDefaultHierarchyTemplate()
|
||||
* jvm()
|
||||
* iosX64()
|
||||
* iosArm64()
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* will create two SourceSetTrees: "main" and "test"
|
||||
* ```
|
||||
* "main" "test"
|
||||
*
|
||||
* commonMain commonTest
|
||||
* | |
|
||||
* | |
|
||||
* +----------+----------+ +----------+----------+
|
||||
* | | | |
|
||||
* ... jvmMain ... jvmTest
|
||||
* | |
|
||||
* | |
|
||||
* iosMain iosTest
|
||||
* | |
|
||||
* +----+-----+ +----+-----+
|
||||
* | | | |
|
||||
* iosX64Main iosArm64Main iosX64Test iosArm64Test
|
||||
* ```
|
||||
*
|
||||
*
|
||||
* Usually, the name of the compilation correlates to the name of the SourceSetTree:
|
||||
* As seen in the previous example, the "main" tree under the "commonMain" root contains all 'main' compilations of the projects
|
||||
* targets. The "test" tree under the "commonTest" root contains all 'test' compilations of the projects targets.
|
||||
*
|
||||
* 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
|
||||
|
||||
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 {
|
||||
if (other !is KotlinSourceSetTree) return false
|
||||
return this.name == other.name
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return name.hashCode()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Deprecated APIs
|
||||
*/
|
||||
|
||||
@Deprecated("Use KotlinSourceSetTree instead")
|
||||
interface KotlinTargetHierarchy {
|
||||
|
||||
/**
|
||||
* When applying any [KotlinTargetHierarchyDescriptor] (e.g. by calling `applyDefaultHierarchyTemplate()`), the descriptor will
|
||||
* be applied on individual compilations, creating multiple trees of shared SourceSets.
|
||||
*
|
||||
* The name of given shared source set within the target hierarchy will be built by
|
||||
* `lowerCamelCase(nameOfGroup, nameOfSourceSetTree)`
|
||||
* So for the 'common' group within the 'main' tree the shared SourceSet name will be 'commonMain'
|
||||
*
|
||||
* The most default case will create two well known SourceSetTrees:
|
||||
* - The `main` tree with `commonMain` as its root SourceSet
|
||||
* - The `test` tree with `commonTest` as its root SourceSet
|
||||
*
|
||||
* e.g.
|
||||
* ```kotlin
|
||||
* kotlin {
|
||||
* applyDefaultHierarchyTemplate()
|
||||
* jvm()
|
||||
* iosX64()
|
||||
* iosArm64()
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* will create two SourceSetTrees: "main" and "test"
|
||||
* ```
|
||||
* "main" "test"
|
||||
*
|
||||
* commonMain commonTest
|
||||
* | |
|
||||
* | |
|
||||
* +----------+----------+ +----------+----------+
|
||||
* | | | |
|
||||
* ... jvmMain ... jvmTest
|
||||
* | |
|
||||
* | |
|
||||
* iosMain iosTest
|
||||
* | |
|
||||
* +----+-----+ +----+-----+
|
||||
* | | | |
|
||||
* iosX64Main iosArm64Main iosX64Test iosArm64Test
|
||||
* ```
|
||||
*
|
||||
*
|
||||
* Usually, the name of the compilation correlates to the name of the SourceSetTree:
|
||||
* As seen in the previous example, the "main" tree under the "commonMain" root contains all 'main' compilations of the projects
|
||||
* targets. The "test" tree under the "commonTest" root contains all 'test' compilations of the projects targets.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
@Deprecated("Use KotlinSourceSetTree instead", replaceWith = ReplaceWith("KotlinSourceSetTree"))
|
||||
class SourceSetTree(override val name: String) : KotlinSourceSetTree {
|
||||
override fun toString(): String = name
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (other !is KotlinSourceSetTree) return false
|
||||
return this.name == other.name
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return name.hashCode()
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
companion object {
|
||||
/**
|
||||
* The 'main' SourceSetTree. Typically, with 'commonMain' as the root SourceSet
|
||||
*/
|
||||
val main = SourceSetTree("main")
|
||||
|
||||
/**
|
||||
* The 'test' SourceSetTree. Typically, with 'commonTest' as the root SourceSet
|
||||
*/
|
||||
val test = SourceSetTree("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 = SourceSetTree("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 = SourceSetTree("instrumentedTest")
|
||||
|
||||
|
||||
/**
|
||||
* Special pre-defined SourceSetTree: Can be used to introduce a new tree with 'commonIntegrationTest' as root SourceSEt
|
||||
*/
|
||||
val integrationTest = SourceSetTree("integrationTest")
|
||||
}
|
||||
}
|
||||
}
|
||||
-102
@@ -1,102 +0,0 @@
|
||||
/*
|
||||
* 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.plugin
|
||||
|
||||
interface KotlinTargetHierarchy {
|
||||
|
||||
/**
|
||||
* When applying any [KotlinTargetHierarchyDescriptor] (e.g. by calling `targetHierarchy.default()`), the descriptor will
|
||||
* be applied on individual compilations, creating multiple trees of shared SourceSets.
|
||||
*
|
||||
* The name of given shared source set within the target hierarchy will be built by
|
||||
* `lowerCamelCase(nameOfGroup, nameOfSourceSetTree)`
|
||||
* So for the 'common' group within the 'main' tree the shared SourceSet name will be 'commonMain'
|
||||
*
|
||||
* The most default case will create two well known SourceSetTrees:
|
||||
* - The `main` tree with `commonMain` as its root SourceSet
|
||||
* - The `test` tree with `commonTest` as its root SourceSet
|
||||
*
|
||||
* e.g.
|
||||
* ```kotlin
|
||||
* kotlin {
|
||||
* targetHierarchy.default()
|
||||
* jvm()
|
||||
* iosX64()
|
||||
* iosArm64()
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* will create two SourceSetTrees: "main" and "test"
|
||||
* ```
|
||||
* "main" "test"
|
||||
*
|
||||
* commonMain commonTest
|
||||
* | |
|
||||
* | |
|
||||
* +----------+----------+ +----------+----------+
|
||||
* | | | |
|
||||
* ... jvmMain ... jvmTest
|
||||
* | |
|
||||
* | |
|
||||
* iosMain iosTest
|
||||
* | |
|
||||
* +----+-----+ +----+-----+
|
||||
* | | | |
|
||||
* iosX64Main iosArm64Main iosX64Test iosArm64Test
|
||||
* ```
|
||||
*
|
||||
*
|
||||
* Usually, the name of the compilation correlates to the name of the SourceSetTree:
|
||||
* As seen in the previous example, the "main" tree under the "commonMain" root contains all 'main' compilations of the projects
|
||||
* targets. The "test" tree under the "commonTest" root contains all 'test' compilations of the projects targets.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
class SourceSetTree(val name: String) {
|
||||
override fun toString(): String = name
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (other !is SourceSetTree) return false
|
||||
return this.name == other.name
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return name.hashCode()
|
||||
}
|
||||
|
||||
companion object {
|
||||
/**
|
||||
* The 'main' SourceSetTree. Typically, with 'commonMain' as the root SourceSet
|
||||
*/
|
||||
val main = SourceSetTree("main")
|
||||
|
||||
/**
|
||||
* The 'test' SourceSetTree. Typically, with 'commonTest' as the root SourceSet
|
||||
*/
|
||||
val test = SourceSetTree("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 = SourceSetTree("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 = SourceSetTree("instrumentedTest")
|
||||
|
||||
|
||||
/**
|
||||
* Special pre-defined SourceSetTree: Can be used to introduce a new tree with 'commonIntegrationTest' as root SourceSEt
|
||||
*/
|
||||
val integrationTest = SourceSetTree("integrationTest")
|
||||
}
|
||||
}
|
||||
}
|
||||
-37
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2022 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.plugin
|
||||
|
||||
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
|
||||
|
||||
@ExperimentalKotlinGradlePluginApi
|
||||
interface KotlinTargetHierarchyDescriptor {
|
||||
fun describe(builder: KotlinTargetHierarchyBuilder.Root)
|
||||
fun extend(describe: KotlinTargetHierarchyBuilder.Root.() -> Unit): KotlinTargetHierarchyDescriptor
|
||||
}
|
||||
|
||||
@ExperimentalKotlinGradlePluginApi
|
||||
fun KotlinTargetHierarchyDescriptor(
|
||||
describe: KotlinTargetHierarchyBuilder.Root.() -> Unit
|
||||
): KotlinTargetHierarchyDescriptor {
|
||||
return KotlinTargetHierarchyDescriptorImpl(describe)
|
||||
}
|
||||
|
||||
@ExperimentalKotlinGradlePluginApi
|
||||
private class KotlinTargetHierarchyDescriptorImpl(
|
||||
private val describe: KotlinTargetHierarchyBuilder.Root.() -> Unit
|
||||
) : KotlinTargetHierarchyDescriptor {
|
||||
|
||||
override fun extend(describe: KotlinTargetHierarchyBuilder.Root.() -> Unit): KotlinTargetHierarchyDescriptor {
|
||||
val sourceDescribe = this.describe
|
||||
return KotlinTargetHierarchyDescriptor {
|
||||
sourceDescribe()
|
||||
describe()
|
||||
}
|
||||
}
|
||||
|
||||
override fun describe(builder: KotlinTargetHierarchyBuilder.Root) = builder.describe()
|
||||
}
|
||||
Reference in New Issue
Block a user