(minor) Fixes for review KT-MR-1290
This commit is contained in:
+4
-4
@@ -32,12 +32,12 @@ class AllOpenGradleSubplugin @Inject internal constructor(private val registry:
|
|||||||
|
|
||||||
private const val ALLOPEN_ARTIFACT_NAME = "kotlin-allopen"
|
private const val ALLOPEN_ARTIFACT_NAME = "kotlin-allopen"
|
||||||
|
|
||||||
private val ANNOTATION_ARG_NAME = "annotation"
|
private const val ANNOTATION_ARG_NAME = "annotation"
|
||||||
private val PRESET_ARG_NAME = "preset"
|
private const val PRESET_ARG_NAME = "preset"
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun apply(project: Project) {
|
override fun apply(target: Project) {
|
||||||
project.extensions.create("allOpen", AllOpenExtension::class.java)
|
target.extensions.create("allOpen", AllOpenExtension::class.java)
|
||||||
registry.register(AllOpenModelBuilder())
|
registry.register(AllOpenModelBuilder())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -68,7 +68,8 @@ open class InternalSubpluginOption(key: String, value: String) : SubpluginOption
|
|||||||
// Deprecated because most calls require the tasks to be instantiated, which is not compatible with Gradle task configuration avoidance.
|
// Deprecated because most calls require the tasks to be instantiated, which is not compatible with Gradle task configuration avoidance.
|
||||||
@Deprecated(
|
@Deprecated(
|
||||||
message = "This interface will be removed due to performance considerations. " +
|
message = "This interface will be removed due to performance considerations. " +
|
||||||
"Please use the KotlinCompilerPluginSupportPlugin interface instead.",
|
"Please use the KotlinCompilerPluginSupportPlugin interface instead " +
|
||||||
|
"and remove the META-INF/services/org.jetbrains.kotlin.gradle.plugin.KotlinGradleSubplugin entry.",
|
||||||
replaceWith = ReplaceWith("KotlinCompilerPluginSupportPlugin")
|
replaceWith = ReplaceWith("KotlinCompilerPluginSupportPlugin")
|
||||||
)
|
)
|
||||||
interface KotlinGradleSubplugin<in KotlinCompile : AbstractCompile> {
|
interface KotlinGradleSubplugin<in KotlinCompile : AbstractCompile> {
|
||||||
|
|||||||
+6
-6
@@ -43,13 +43,13 @@ import javax.inject.Inject
|
|||||||
class Kapt3GradleSubplugin @Inject internal constructor(private val registry: ToolingModelBuilderRegistry) :
|
class Kapt3GradleSubplugin @Inject internal constructor(private val registry: ToolingModelBuilderRegistry) :
|
||||||
KotlinCompilerPluginSupportPlugin {
|
KotlinCompilerPluginSupportPlugin {
|
||||||
|
|
||||||
override fun apply(project: Project) {
|
override fun apply(target: Project) {
|
||||||
project.extensions.create("kapt", KaptExtension::class.java)
|
target.extensions.create("kapt", KaptExtension::class.java)
|
||||||
|
|
||||||
project.configurations.create(KAPT_WORKER_DEPENDENCIES_CONFIGURATION_NAME).apply {
|
target.configurations.create(KAPT_WORKER_DEPENDENCIES_CONFIGURATION_NAME).apply {
|
||||||
project.getKotlinPluginVersion()?.let { kotlinPluginVersion ->
|
target.getKotlinPluginVersion()?.let { kotlinPluginVersion ->
|
||||||
val kaptDependency = getPluginArtifact().run { "$groupId:$artifactId:$kotlinPluginVersion" }
|
val kaptDependency = getPluginArtifact().run { "$groupId:$artifactId:$kotlinPluginVersion" }
|
||||||
dependencies.add(project.dependencies.create(kaptDependency))
|
dependencies.add(target.dependencies.create(kaptDependency))
|
||||||
} ?: throw GradleException("Kotlin plugin should be enabled before 'kotlin-kapt'")
|
} ?: throw GradleException("Kotlin plugin should be enabled before 'kotlin-kapt'")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -482,7 +482,7 @@ class Kapt3GradleSubplugin @Inject internal constructor(private val registry: To
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taskClass == KaptWithKotlincTask::class.java) {
|
if (KaptWithKotlincTask::class.java.isAssignableFrom(taskClass)) {
|
||||||
val subpluginOptions = buildOptions("apt", dslJavacOptions)
|
val subpluginOptions = buildOptions("apt", dslJavacOptions)
|
||||||
registerSubpluginOptions(kaptTaskProvider, subpluginOptions)
|
registerSubpluginOptions(kaptTaskProvider, subpluginOptions)
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-1
@@ -33,6 +33,8 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.*
|
|||||||
import org.jetbrains.kotlin.gradle.targets.js.KotlinJsCompilerAttribute
|
import org.jetbrains.kotlin.gradle.targets.js.KotlinJsCompilerAttribute
|
||||||
import org.jetbrains.kotlin.gradle.targets.js.KotlinJsTarget
|
import org.jetbrains.kotlin.gradle.targets.js.KotlinJsTarget
|
||||||
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrTarget
|
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrTarget
|
||||||
|
import org.jetbrains.kotlin.gradle.tasks.locateOrRegisterTask
|
||||||
|
import org.jetbrains.kotlin.gradle.tasks.locateTask
|
||||||
import org.jetbrains.kotlin.gradle.tasks.registerTask
|
import org.jetbrains.kotlin.gradle.tasks.registerTask
|
||||||
import org.jetbrains.kotlin.gradle.tasks.withType
|
import org.jetbrains.kotlin.gradle.tasks.withType
|
||||||
import org.jetbrains.kotlin.gradle.utils.COMPILE
|
import org.jetbrains.kotlin.gradle.utils.COMPILE
|
||||||
@@ -130,7 +132,7 @@ abstract class AbstractKotlinTargetConfigurator<KotlinTargetType : KotlinTarget>
|
|||||||
) {
|
) {
|
||||||
val project = compilation.target.project
|
val project = compilation.target.project
|
||||||
|
|
||||||
project.registerTask<ProcessResources>(compilation.processResourcesTaskName) { resourcesTask ->
|
project.locateOrRegisterTask<ProcessResources>(compilation.processResourcesTaskName) { resourcesTask ->
|
||||||
resourcesTask.description = "Processes $resourceSet."
|
resourcesTask.description = "Processes $resourceSet."
|
||||||
DslObject(resourcesTask).conventionMapping.map("destinationDir") { project.file(compilation.output.resourcesDir) }
|
DslObject(resourcesTask).conventionMapping.map("destinationDir") { project.file(compilation.output.resourcesDir) }
|
||||||
resourcesTask.from(resourceSet)
|
resourcesTask.from(resourceSet)
|
||||||
|
|||||||
+4
-3
@@ -37,6 +37,8 @@ import org.jetbrains.kotlin.gradle.plugin.statistics.KotlinBuildStatsService
|
|||||||
import org.jetbrains.kotlin.gradle.scripting.internal.ScriptingGradleSubplugin
|
import org.jetbrains.kotlin.gradle.scripting.internal.ScriptingGradleSubplugin
|
||||||
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrTargetPreset
|
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrTargetPreset
|
||||||
import org.jetbrains.kotlin.gradle.targets.metadata.isKotlinGranularMetadataEnabled
|
import org.jetbrains.kotlin.gradle.targets.metadata.isKotlinGranularMetadataEnabled
|
||||||
|
import org.jetbrains.kotlin.gradle.tasks.locateOrRegisterTask
|
||||||
|
import org.jetbrains.kotlin.gradle.tasks.locateTask
|
||||||
import org.jetbrains.kotlin.gradle.tasks.registerTask
|
import org.jetbrains.kotlin.gradle.tasks.registerTask
|
||||||
import org.jetbrains.kotlin.gradle.tasks.withType
|
import org.jetbrains.kotlin.gradle.tasks.withType
|
||||||
import org.jetbrains.kotlin.gradle.utils.*
|
import org.jetbrains.kotlin.gradle.utils.*
|
||||||
@@ -351,9 +353,8 @@ internal fun sourcesJarTask(
|
|||||||
): TaskProvider<Jar> {
|
): TaskProvider<Jar> {
|
||||||
val taskName = lowerCamelCaseName(componentName, "sourcesJar")
|
val taskName = lowerCamelCaseName(componentName, "sourcesJar")
|
||||||
|
|
||||||
project.tasks.withType<Jar>().run {
|
project.locateTask<Jar>(taskName)?.let {
|
||||||
if (taskName in names)
|
return it
|
||||||
return named(taskName)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val result = project.registerTask<Jar>(taskName) { sourcesJar ->
|
val result = project.registerTask<Jar>(taskName) { sourcesJar ->
|
||||||
|
|||||||
+1
-9
@@ -99,16 +99,8 @@ abstract class AbstractKotlinCompilation<T : KotlinCommonOptions>(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note! Invocation of withType-all results in preliminary task instantiation.
|
|
||||||
// After fix of this issue the following code should be uncommented:
|
|
||||||
// if (useLazyTaskConfiguration) {
|
|
||||||
// (target.project.tasks.named(compileKotlinTaskName) as TaskProvider<AbstractKotlinCompile<*>>).configure {
|
|
||||||
// it.configureAction()
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
target.project.tasks
|
target.project.tasks
|
||||||
// To configure a task that may have not yet been created at this point, use 'withType-matching-all`:
|
// To configure a task that may have not yet been created at this point, use 'withType-matching-configureEach`:
|
||||||
.withType(AbstractKotlinCompile::class.java)
|
.withType(AbstractKotlinCompile::class.java)
|
||||||
.matching { it.name == compileKotlinTaskName }
|
.matching { it.name == compileKotlinTaskName }
|
||||||
.configureEach { compileKotlinTask ->
|
.configureEach { compileKotlinTask ->
|
||||||
|
|||||||
+7
-3
@@ -6,6 +6,7 @@
|
|||||||
package org.jetbrains.kotlin.gradle.targets.js
|
package org.jetbrains.kotlin.gradle.targets.js
|
||||||
|
|
||||||
import org.gradle.api.DefaultTask
|
import org.gradle.api.DefaultTask
|
||||||
|
import org.gradle.api.Task
|
||||||
import org.gradle.api.attributes.Usage
|
import org.gradle.api.attributes.Usage
|
||||||
import org.gradle.language.base.plugins.LifecycleBasePlugin
|
import org.gradle.language.base.plugins.LifecycleBasePlugin
|
||||||
import org.jetbrains.kotlin.gradle.dsl.kotlinExtension
|
import org.jetbrains.kotlin.gradle.dsl.kotlinExtension
|
||||||
@@ -13,6 +14,7 @@ import org.jetbrains.kotlin.gradle.plugin.*
|
|||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJsCompilation
|
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJsCompilation
|
||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinUsages
|
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinUsages
|
||||||
import org.jetbrains.kotlin.gradle.tasks.KotlinTasksProvider
|
import org.jetbrains.kotlin.gradle.tasks.KotlinTasksProvider
|
||||||
|
import org.jetbrains.kotlin.gradle.tasks.locateTask
|
||||||
import org.jetbrains.kotlin.gradle.tasks.registerTask
|
import org.jetbrains.kotlin.gradle.tasks.registerTask
|
||||||
import org.jetbrains.kotlin.gradle.testing.internal.kotlinTestRegistry
|
import org.jetbrains.kotlin.gradle.testing.internal.kotlinTestRegistry
|
||||||
import org.jetbrains.kotlin.gradle.testing.testTaskName
|
import org.jetbrains.kotlin.gradle.testing.testTaskName
|
||||||
@@ -75,10 +77,12 @@ open class KotlinJsTargetConfigurator(kotlinPluginVersion: String) :
|
|||||||
|
|
||||||
compilation.output.classesDirs.from(project.files().builtBy(compilation.compileAllTaskName))
|
compilation.output.classesDirs.from(project.files().builtBy(compilation.compileAllTaskName))
|
||||||
|
|
||||||
val compileAllTask = project.tasks.findByPath(compilation.compileAllTaskName)
|
val compileAllTask = project.locateTask<Task>(compilation.compileAllTaskName)
|
||||||
if (compileAllTask != null) {
|
if (compileAllTask != null) {
|
||||||
compileAllTask.dependsOn(compilation.compileKotlinTaskName)
|
compileAllTask.configure {
|
||||||
compileAllTask.dependsOn(compilation.processResourcesTaskName)
|
it.dependsOn(compilation.compileKotlinTaskName)
|
||||||
|
it.dependsOn(compilation.processResourcesTaskName)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
project.registerTask<DefaultTask>(compilation.compileAllTaskName) {
|
project.registerTask<DefaultTask>(compilation.compileAllTaskName) {
|
||||||
it.group = LifecycleBasePlugin.BUILD_GROUP
|
it.group = LifecycleBasePlugin.BUILD_GROUP
|
||||||
|
|||||||
+1
-3
@@ -196,9 +196,7 @@ class KotlinMetadataTargetConfigurator(kotlinPluginVersion: String) :
|
|||||||
val generateMetadata = project.createGenerateProjectStructureMetadataTask()
|
val generateMetadata = project.createGenerateProjectStructureMetadataTask()
|
||||||
|
|
||||||
allMetadataJar.configure {
|
allMetadataJar.configure {
|
||||||
it.from(
|
it.from(generateMetadata.map { it.resultXmlFile }) { spec ->
|
||||||
project.files(Callable { generateMetadata.get().resultXmlFile }).builtBy(generateMetadata)
|
|
||||||
) { spec ->
|
|
||||||
spec.into("META-INF").rename { MULTIPLATFORM_PROJECT_METADATA_FILE_NAME }
|
spec.into("META-INF").rename { MULTIPLATFORM_PROJECT_METADATA_FILE_NAME }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-2
@@ -57,9 +57,13 @@ open class DefaultCInteropSettings @Inject constructor(
|
|||||||
target.disambiguationClassifier
|
target.disambiguationClassifier
|
||||||
)
|
)
|
||||||
|
|
||||||
val defFile: Property<File> = project.objects.property(File::class.java)
|
val defFileProperty: Property<File> = project.objects.property(File::class.java)
|
||||||
.apply { set(project.projectDir.resolve("src/nativeInterop/cinterop/$name.def")) }
|
.apply { set(project.projectDir.resolve("src/nativeInterop/cinterop/$name.def")) }
|
||||||
|
|
||||||
|
var defFile: File
|
||||||
|
get() = defFileProperty.get()
|
||||||
|
set(value) { defFileProperty.set(value) }
|
||||||
|
|
||||||
var packageName: String? = null
|
var packageName: String? = null
|
||||||
|
|
||||||
val compilerOpts = mutableListOf<String>()
|
val compilerOpts = mutableListOf<String>()
|
||||||
@@ -72,7 +76,7 @@ open class DefaultCInteropSettings @Inject constructor(
|
|||||||
// DSL methods.
|
// DSL methods.
|
||||||
|
|
||||||
override fun defFile(file: Any) {
|
override fun defFile(file: Any) {
|
||||||
defFile.set(project.file(file))
|
defFileProperty.set(project.file(file))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun packageName(value: String) {
|
override fun packageName(value: String) {
|
||||||
|
|||||||
+1
-1
@@ -195,7 +195,7 @@ open class KotlinCocoapodsPlugin : Plugin<Project> {
|
|||||||
|
|
||||||
interopTask.dependsOn(defTask)
|
interopTask.dependsOn(defTask)
|
||||||
|
|
||||||
interop.defFile.set(defTask.map { it.outputFile })
|
interop.defFileProperty.set(defTask.map { it.outputFile })
|
||||||
interop.packageName = "cocoapods.${pod.moduleName}"
|
interop.packageName = "cocoapods.${pod.moduleName}"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -951,7 +951,7 @@ open class CInteropProcess : DefaultTask() {
|
|||||||
project.provider { destinationDir.get().resolve(outputFileName) }
|
project.provider { destinationDir.get().resolve(outputFileName) }
|
||||||
|
|
||||||
val defFile: File
|
val defFile: File
|
||||||
@InputFile get() = settings.defFile.get()
|
@InputFile get() = settings.defFileProperty.get()
|
||||||
|
|
||||||
val packageName: String?
|
val packageName: String?
|
||||||
@Optional @Input get() = settings.packageName
|
@Optional @Input get() = settings.packageName
|
||||||
|
|||||||
+1
-1
@@ -45,7 +45,7 @@ internal fun Project.newFileProperty(initialize: (() -> File)? = null): RegularF
|
|||||||
|
|
||||||
return regularFileProperty.apply {
|
return regularFileProperty.apply {
|
||||||
if (initialize != null) {
|
if (initialize != null) {
|
||||||
set(provider { RegularFile(initialize) })
|
set(project.layout.file(project.provider(initialize)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-2
@@ -38,8 +38,8 @@ class NoArgGradleSubplugin @Inject internal constructor(private val registry: To
|
|||||||
private const val INVOKE_INITIALIZERS_ARG_NAME = "invokeInitializers"
|
private const val INVOKE_INITIALIZERS_ARG_NAME = "invokeInitializers"
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun apply(project: Project) {
|
override fun apply(target: Project) {
|
||||||
project.extensions.create("noArg", NoArgExtension::class.java)
|
target.extensions.create("noArg", NoArgExtension::class.java)
|
||||||
registry.register(NoArgModelBuilder())
|
registry.register(NoArgModelBuilder())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -24,16 +24,16 @@ import org.jetbrains.kotlin.noarg.gradle.model.builder.SamWithReceiverModelBuild
|
|||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class SamWithReceiverGradleSubplugin @Inject internal constructor(private val registry: ToolingModelBuilderRegistry) : KotlinCompilerPluginSupportPlugin {
|
class SamWithReceiverGradleSubplugin @Inject internal constructor(private val registry: ToolingModelBuilderRegistry) : KotlinCompilerPluginSupportPlugin {
|
||||||
override fun apply(project: Project) {
|
override fun apply(target: Project) {
|
||||||
project.extensions.create("samWithReceiver", SamWithReceiverExtension::class.java)
|
target.extensions.create("samWithReceiver", SamWithReceiverExtension::class.java)
|
||||||
registry.register(SamWithReceiverModelBuilder())
|
registry.register(SamWithReceiverModelBuilder())
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val SAM_WITH_RECEIVER_ARTIFACT_NAME = "kotlin-sam-with-receiver"
|
const val SAM_WITH_RECEIVER_ARTIFACT_NAME = "kotlin-sam-with-receiver"
|
||||||
|
|
||||||
private val ANNOTATION_ARG_NAME = "annotation"
|
private const val ANNOTATION_ARG_NAME = "annotation"
|
||||||
private val PRESET_ARG_NAME = "preset"
|
private const val PRESET_ARG_NAME = "preset"
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun isApplicable(kotlinCompilation: KotlinCompilation<*>): Boolean = true
|
override fun isApplicable(kotlinCompilation: KotlinCompilation<*>): Boolean = true
|
||||||
|
|||||||
Reference in New Issue
Block a user