/
KotlinCompilation.kt
132 lines (92 loc) · 4.43 KB
/
KotlinCompilation.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/*
* Copyright 2010-2018 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.
*/
@file:Suppress("TYPEALIAS_EXPANSION_DEPRECATION")
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
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.tasks.KotlinCompilationTask
import org.jetbrains.kotlin.tooling.core.HasMutableExtras
interface KotlinCompilation<out T : KotlinCommonOptionsDeprecated> : Named,
HasProject,
HasMutableExtras,
HasAttributes,
HasKotlinDependencies {
val target: KotlinTarget
val compilationName: String
val kotlinSourceSets: Set<KotlinSourceSet>
val allKotlinSourceSets: Set<KotlinSourceSet>
@Deprecated("Use defaultSourceSet.name instead", ReplaceWith("defaultSourceSet.name"))
val defaultSourceSetName: String get() = defaultSourceSet.name
val defaultSourceSet: KotlinSourceSet
fun defaultSourceSet(configure: KotlinSourceSet.() -> Unit)
fun defaultSourceSet(configure: Action<KotlinSourceSet>) = defaultSourceSet { configure.execute(this) }
val compileDependencyConfigurationName: String
var compileDependencyFiles: FileCollection
val runtimeDependencyConfigurationName: String?
val runtimeDependencyFiles: FileCollection?
val output: KotlinCompilationOutput
val platformType get() = target.platformType
val compileKotlinTaskName: String
val compilerOptions: HasCompilerOptions<*>
@Deprecated(
message = "Accessing task instance directly is deprecated",
replaceWith = ReplaceWith("compileTaskProvider")
)
val compileKotlinTask: KotlinCompileDeprecated<T>
@Deprecated(
message = "Replaced with compileTaskProvider",
replaceWith = ReplaceWith("compileTaskProvider")
)
val compileKotlinTaskProvider: TaskProvider<out KotlinCompileDeprecated<T>>
val compileTaskProvider: TaskProvider<out KotlinCompilationTask<*>>
val kotlinOptions: T
fun kotlinOptions(configure: T.() -> Unit) {
@Suppress("DEPRECATION")
configure(kotlinOptions)
}
fun kotlinOptions(configure: Action<@UnsafeVariance T>) {
@Suppress("DEPRECATION")
configure.execute(kotlinOptions)
}
fun attributes(configure: AttributeContainer.() -> Unit) = attributes.configure()
fun attributes(configure: Action<AttributeContainer>) = attributes { configure.execute(this) }
val compileAllTaskName: String
companion object {
const val MAIN_COMPILATION_NAME = "main"
const val TEST_COMPILATION_NAME = "test"
}
fun source(sourceSet: KotlinSourceSet)
fun associateWith(other: KotlinCompilation<*>)
val associateWith: List<KotlinCompilation<*>>
override fun getName(): String = compilationName
override val relatedConfigurationNames: List<String>
get() = super.relatedConfigurationNames + compileDependencyConfigurationName
@Deprecated("Scheduled for removal with Kotlin 1.9. Use compilerOptions instead")
val moduleName: String
val disambiguatedName
get() = target.disambiguationClassifier + name
}
@Deprecated("Scheduled for removal with Kotlin 1.9")
interface KotlinCompilationToRunnableFiles<T : KotlinCommonOptionsDeprecated> : KotlinCompilation<T> {
override val runtimeDependencyConfigurationName: String
override var runtimeDependencyFiles: FileCollection
override val relatedConfigurationNames: List<String>
get() = super.relatedConfigurationNames + runtimeDependencyConfigurationName
}
@Deprecated("Scheduled for removal with Kotlin 1.9")
@Suppress("EXTENSION_SHADOWED_BY_MEMBER", "deprecation") // kept for compatibility
val <T : KotlinCommonOptionsDeprecated> KotlinCompilation<T>.runtimeDependencyConfigurationName: String?
get() = (this as? KotlinCompilationToRunnableFiles<T>)?.runtimeDependencyConfigurationName
@Deprecated("Scheduled for removal with Kotlin 1.9")
interface KotlinCompilationWithResources<T : KotlinCommonOptionsDeprecated> : KotlinCompilation<T> {
val processResourcesTaskName: String
}