Update Gradle plugin api to use compiler options
Binary compatible. Source incompatible via adding new methods to interfaces. ^KT-27301 In Progress
This commit is contained in:
+7
@@ -22,7 +22,13 @@ interface KotlinNativeArtifact : KotlinArtifact {
|
||||
val modes: Set<NativeBuildType>
|
||||
val isStatic: Boolean
|
||||
val linkerOptions: List<String>
|
||||
@Suppress("DEPRECATION")
|
||||
@Deprecated(
|
||||
message = "Replaced by compilerOptionsConfigure",
|
||||
replaceWith = ReplaceWith("compilerOptionsConfigure")
|
||||
)
|
||||
val kotlinOptionsFn: KotlinCommonToolOptions.() -> Unit
|
||||
val compilerOptionsConfigure: CompilerCommonToolOptions.() -> Unit
|
||||
val binaryOptions: Map<String, String>
|
||||
}
|
||||
|
||||
@@ -58,6 +64,7 @@ interface KotlinNativeArtifactConfig : KotlinArtifactConfig {
|
||||
fun modes(vararg modes: NativeBuildType)
|
||||
var isStatic: Boolean
|
||||
var linkerOptions: List<String>
|
||||
@Suppress("DEPRECATION")
|
||||
fun kotlinOptions(fn: Action<KotlinCommonToolOptions>)
|
||||
fun binaryOption(name: String, value: String)
|
||||
}
|
||||
|
||||
+22
@@ -10,18 +10,40 @@ import org.gradle.api.Action
|
||||
import org.gradle.api.Task
|
||||
import org.gradle.api.tasks.Internal
|
||||
|
||||
@Deprecated(
|
||||
message = "Replaced by KotlinCompilationTask",
|
||||
replaceWith = ReplaceWith(
|
||||
"KotlinCompilationTask",
|
||||
"org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask"
|
||||
)
|
||||
)
|
||||
@Suppress("DEPRECATION")
|
||||
interface KotlinCompile<out T : KotlinCommonOptions> : Task {
|
||||
|
||||
@Deprecated(
|
||||
message = "Replaced by compilerOptions input",
|
||||
replaceWith = ReplaceWith("compilerOptions")
|
||||
)
|
||||
@get:Internal
|
||||
val kotlinOptions: T
|
||||
|
||||
@Deprecated(
|
||||
message = "Replaced by compilerOptions { .. }",
|
||||
replaceWith = ReplaceWith("compilerOptions(fn)")
|
||||
)
|
||||
fun kotlinOptions(fn: T.() -> Unit) {
|
||||
kotlinOptions.fn()
|
||||
}
|
||||
|
||||
@Deprecated(
|
||||
message = "Replaced by compilerOptions(Action)",
|
||||
replaceWith = ReplaceWith("compilerOptions(fn)")
|
||||
)
|
||||
fun kotlinOptions(fn: Action<in T>) {
|
||||
fn.execute(kotlinOptions)
|
||||
}
|
||||
|
||||
@Deprecated("Should be autogenerated by Gradle")
|
||||
fun kotlinOptions(fn: Closure<*>) {
|
||||
project.configure(kotlinOptions, fn)
|
||||
}
|
||||
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Contains workarounds to suppress deprecated import without suppressing deprecation in the whole file.
|
||||
*/
|
||||
package org.jetbrains.kotlin.gradle.dsl
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
internal typealias KotlinCompileDeprecated<T> = KotlinCompile<T>
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
internal typealias KotlinJvmOptionsDeprecated = KotlinJvmOptions
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
internal typealias KotlinCommonOptionsDeprecated = KotlinCommonOptions
|
||||
+4
-2
@@ -3,12 +3,14 @@
|
||||
* 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.file.FileCollection
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonOptions
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonOptionsDeprecated
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.KotlinCompilationData
|
||||
|
||||
interface CInteropSettings : Named {
|
||||
@@ -22,7 +24,7 @@ interface CInteropSettings : Named {
|
||||
}
|
||||
|
||||
// TODO: Provide an interface for native compilations.
|
||||
val compilation: KotlinCompilationData<out KotlinCommonOptions>
|
||||
val compilation: KotlinCompilationData<out KotlinCommonOptionsDeprecated>
|
||||
|
||||
val dependencyConfigurationName: String
|
||||
var dependencyFiles: FileCollection
|
||||
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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.gradle.api.Action
|
||||
import org.jetbrains.kotlin.gradle.dsl.CompilerCommonOptions
|
||||
|
||||
interface HasCompilerOptions<out CO : CompilerCommonOptions> {
|
||||
val options: CO
|
||||
|
||||
fun configure(configuration: CO.() -> Unit) {
|
||||
configuration(options)
|
||||
}
|
||||
|
||||
fun configure(configuration: Action<@UnsafeVariance CO>) {
|
||||
configuration.execute(options)
|
||||
}
|
||||
}
|
||||
+47
-10
@@ -3,6 +3,8 @@
|
||||
* 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
|
||||
@@ -12,8 +14,10 @@ import org.gradle.api.attributes.HasAttributes
|
||||
import org.gradle.api.file.ConfigurableFileCollection
|
||||
import org.gradle.api.file.FileCollection
|
||||
import org.gradle.api.tasks.TaskProvider
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonOptions
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinCompile
|
||||
import org.jetbrains.kotlin.gradle.dsl.CompilerCommonOptions
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonOptionsDeprecated
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinCompileDeprecated
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask
|
||||
import java.io.File
|
||||
|
||||
interface KotlinCompilationOutput {
|
||||
@@ -24,7 +28,9 @@ interface KotlinCompilationOutput {
|
||||
val allOutputs: FileCollection
|
||||
}
|
||||
|
||||
interface KotlinCompilation<out T : KotlinCommonOptions> : Named, HasAttributes, HasKotlinDependencies {
|
||||
interface KotlinCompilation<out T : KotlinCommonOptionsDeprecated> : Named,
|
||||
HasAttributes,
|
||||
HasKotlinDependencies {
|
||||
val target: KotlinTarget
|
||||
|
||||
val compilationName: String
|
||||
@@ -51,14 +57,45 @@ interface KotlinCompilation<out T : KotlinCommonOptions> : Named, HasAttributes,
|
||||
|
||||
val compileKotlinTaskName: String
|
||||
|
||||
val compileKotlinTask: KotlinCompile<T>
|
||||
val compilerOptions: HasCompilerOptions<*>
|
||||
|
||||
val compileKotlinTaskProvider: TaskProvider<out KotlinCompile<T>>
|
||||
@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<*>>
|
||||
|
||||
@Deprecated(
|
||||
message = "Replaced by compilerOptions",
|
||||
replaceWith = ReplaceWith("compilerOptions.options")
|
||||
)
|
||||
val kotlinOptions: T
|
||||
|
||||
fun kotlinOptions(configure: T.() -> Unit)
|
||||
fun kotlinOptions(configure: Action<@UnsafeVariance T>) = kotlinOptions { configure.execute(this) }
|
||||
@Deprecated(
|
||||
message = "Replaced by compilerOptions.configure { }",
|
||||
replaceWith = ReplaceWith("compilerOptions.configure(configure)")
|
||||
)
|
||||
fun kotlinOptions(configure: T.() -> Unit) {
|
||||
@Suppress("DEPRECATION")
|
||||
configure(kotlinOptions)
|
||||
}
|
||||
|
||||
@Deprecated(
|
||||
message = "Replaced by compilerOptions(Action)",
|
||||
replaceWith = ReplaceWith("compilerOptions.configure(configure)")
|
||||
)
|
||||
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) }
|
||||
@@ -87,7 +124,7 @@ interface KotlinCompilation<out T : KotlinCommonOptions> : Named, HasAttributes,
|
||||
get() = target.disambiguationClassifier + name
|
||||
}
|
||||
|
||||
interface KotlinCompilationToRunnableFiles<T : KotlinCommonOptions> : KotlinCompilation<T> {
|
||||
interface KotlinCompilationToRunnableFiles<T : KotlinCommonOptionsDeprecated> : KotlinCompilation<T> {
|
||||
val runtimeDependencyConfigurationName: String
|
||||
|
||||
var runtimeDependencyFiles: FileCollection
|
||||
@@ -96,9 +133,9 @@ interface KotlinCompilationToRunnableFiles<T : KotlinCommonOptions> : KotlinComp
|
||||
get() = super.relatedConfigurationNames + runtimeDependencyConfigurationName
|
||||
}
|
||||
|
||||
val <T : KotlinCommonOptions> KotlinCompilation<T>.runtimeDependencyConfigurationName: String?
|
||||
val <T : KotlinCommonOptionsDeprecated> KotlinCompilation<T>.runtimeDependencyConfigurationName: String?
|
||||
get() = (this as? KotlinCompilationToRunnableFiles<T>)?.runtimeDependencyConfigurationName
|
||||
|
||||
interface KotlinCompilationWithResources<T : KotlinCommonOptions> : KotlinCompilation<T> {
|
||||
interface KotlinCompilationWithResources<T : KotlinCommonOptionsDeprecated> : KotlinCompilation<T> {
|
||||
val processResourcesTaskName: String
|
||||
}
|
||||
+10
-2
@@ -2,14 +2,16 @@
|
||||
* Copyright 2010-2021 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.file.FileCollection
|
||||
import org.gradle.api.provider.Provider
|
||||
import org.gradle.api.tasks.TaskProvider
|
||||
import org.jetbrains.kotlin.gradle.dsl.CompilerJvmOptions
|
||||
import org.jetbrains.kotlin.gradle.dsl.KaptExtensionConfig
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptions
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptionsDeprecated
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinTopLevelExtensionConfig
|
||||
import org.jetbrains.kotlin.gradle.tasks.KaptGenerateStubs
|
||||
import org.jetbrains.kotlin.gradle.tasks.Kapt
|
||||
@@ -24,7 +26,13 @@ interface KotlinJvmFactory {
|
||||
val kotlinExtension: KotlinTopLevelExtensionConfig
|
||||
|
||||
/** Creates instance of DSL object that should be used to configure JVM/android specific compilation. */
|
||||
fun createKotlinJvmOptions(): KotlinJvmOptions
|
||||
@Deprecated(
|
||||
message = "Replaced by compilerJvmOptions",
|
||||
replaceWith = ReplaceWith("createCompilerJvmOptions()")
|
||||
)
|
||||
fun createKotlinJvmOptions(): KotlinJvmOptionsDeprecated
|
||||
|
||||
fun createCompilerJvmOptions(): CompilerJvmOptions
|
||||
|
||||
/** Creates a Kotlin compile task. */
|
||||
fun registerKotlinJvmCompileTask(taskName: String): TaskProvider<out KotlinJvmCompile>
|
||||
|
||||
+4
-2
@@ -3,6 +3,8 @@
|
||||
* 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
|
||||
@@ -14,7 +16,7 @@ import org.gradle.api.attributes.AttributeContainer
|
||||
import org.gradle.api.attributes.HasAttributes
|
||||
import org.gradle.api.component.SoftwareComponent
|
||||
import org.gradle.api.publish.maven.MavenPublication
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonOptions
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonOptionsDeprecated
|
||||
|
||||
interface KotlinTargetComponent : SoftwareComponent {
|
||||
val target: KotlinTarget
|
||||
@@ -32,7 +34,7 @@ interface KotlinTarget : Named, HasAttributes {
|
||||
|
||||
val platformType: KotlinPlatformType
|
||||
|
||||
val compilations: NamedDomainObjectContainer<out KotlinCompilation<KotlinCommonOptions>>
|
||||
val compilations: NamedDomainObjectContainer<out KotlinCompilation<KotlinCommonOptionsDeprecated>>
|
||||
|
||||
val project: Project
|
||||
|
||||
|
||||
+4
-2
@@ -3,17 +3,19 @@
|
||||
* 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.mpp.pm20
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.file.FileCollection
|
||||
import org.gradle.api.file.SourceDirectorySet
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonOptions
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonOptionsDeprecated
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilationOutput
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
|
||||
import org.jetbrains.kotlin.project.model.LanguageSettings
|
||||
|
||||
interface GradleKpmVariantCompilationData<T : KotlinCommonOptions> : KotlinCompilationData<T> {
|
||||
interface GradleKpmVariantCompilationData<T : KotlinCommonOptionsDeprecated> : KotlinCompilationData<T> {
|
||||
override val owner: GradleKpmVariant
|
||||
|
||||
override val project: Project get() = owner.containingModule.project
|
||||
|
||||
+12
-2
@@ -3,17 +3,21 @@
|
||||
* 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.mpp.pm20
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.file.FileCollection
|
||||
import org.gradle.api.file.SourceDirectorySet
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonOptions
|
||||
import org.jetbrains.kotlin.gradle.dsl.CompilerCommonOptions
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonOptionsDeprecated
|
||||
import org.jetbrains.kotlin.gradle.plugin.HasCompilerOptions
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilationOutput
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
|
||||
import org.jetbrains.kotlin.project.model.LanguageSettings
|
||||
|
||||
interface KotlinCompilationData<T : KotlinCommonOptions> {
|
||||
interface KotlinCompilationData<T : KotlinCommonOptionsDeprecated> {
|
||||
val project: Project
|
||||
val owner: Any?
|
||||
|
||||
@@ -33,8 +37,14 @@ interface KotlinCompilationData<T : KotlinCommonOptions> {
|
||||
val moduleName: String
|
||||
val ownModuleName: String
|
||||
|
||||
@Deprecated(
|
||||
message = "Replaced with compilerOptions.options",
|
||||
replaceWith = ReplaceWith("compilerOptions.options")
|
||||
)
|
||||
val kotlinOptions: T
|
||||
|
||||
val compilerOptions: HasCompilerOptions<*>
|
||||
|
||||
val friendPaths: Iterable<FileCollection>
|
||||
}
|
||||
|
||||
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* 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.tasks
|
||||
|
||||
import org.gradle.api.Action
|
||||
import org.gradle.api.Task
|
||||
import org.gradle.api.tasks.Nested
|
||||
import org.jetbrains.kotlin.gradle.dsl.CompilerCommonOptions
|
||||
|
||||
interface KotlinCompilationTask<out CO : CompilerCommonOptions> : Task {
|
||||
@get:Nested
|
||||
val compilerOptions: CO
|
||||
|
||||
fun compilerOptions(configure: CO.() -> Unit) {
|
||||
configure(compilerOptions)
|
||||
}
|
||||
|
||||
fun compilerOptions(configure: Action<in CO>) {
|
||||
configure.execute(compilerOptions)
|
||||
}
|
||||
}
|
||||
+10
-4
@@ -15,8 +15,7 @@ import org.gradle.api.tasks.*
|
||||
import org.gradle.api.tasks.util.PatternFilterable
|
||||
import org.gradle.work.Incremental
|
||||
import org.gradle.work.NormalizeLineEndings
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinCompile
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptions
|
||||
import org.jetbrains.kotlin.gradle.dsl.*
|
||||
import org.jetbrains.kotlin.gradle.plugin.CompilerPluginConfig
|
||||
|
||||
interface KotlinCompileTool : PatternFilterable, Task {
|
||||
@@ -77,11 +76,18 @@ interface BaseKotlinCompile : KotlinCompileTool {
|
||||
val pluginOptions: ListProperty<CompilerPluginConfig>
|
||||
}
|
||||
|
||||
interface KotlinJvmCompile : BaseKotlinCompile, KotlinCompile<KotlinJvmOptions> {
|
||||
@Suppress("TYPEALIAS_EXPANSION_DEPRECATION")
|
||||
interface KotlinJvmCompile : BaseKotlinCompile,
|
||||
KotlinCompileDeprecated<KotlinJvmOptionsDeprecated>,
|
||||
KotlinCompilationTask<CompilerJvmOptions> {
|
||||
|
||||
// JVM specific
|
||||
@get:Internal("Takes part in compiler args.")
|
||||
val parentKotlinOptions: Property<KotlinJvmOptions>
|
||||
@Deprecated(
|
||||
message = "Configure compilerOptions directly",
|
||||
replaceWith = ReplaceWith("compilerOptions")
|
||||
)
|
||||
val parentKotlinOptions: Property<KotlinJvmOptionsDeprecated>
|
||||
}
|
||||
|
||||
interface KaptGenerateStubs : KotlinJvmCompile {
|
||||
|
||||
Reference in New Issue
Block a user