Fix some warnings in kotlin-gradle-plugin
This commit is contained in:
committed by
TeamCityServer
parent
19a5c2f1c8
commit
37ccd82b6c
@@ -28,7 +28,9 @@ tasks {
|
|||||||
kotlinOptions.languageVersion = "1.3"
|
kotlinOptions.languageVersion = "1.3"
|
||||||
kotlinOptions.apiVersion = "1.3"
|
kotlinOptions.apiVersion = "1.3"
|
||||||
kotlinOptions.freeCompilerArgs += listOf(
|
kotlinOptions.freeCompilerArgs += listOf(
|
||||||
"-Xskip-prerelease-check", "-Xsuppress-version-warnings"
|
"-Xskip-prerelease-check",
|
||||||
|
"-Xskip-runtime-version-check",
|
||||||
|
"-Xsuppress-version-warnings"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -129,7 +129,9 @@ tasks {
|
|||||||
kotlinOptions.languageVersion = "1.3"
|
kotlinOptions.languageVersion = "1.3"
|
||||||
kotlinOptions.apiVersion = "1.3"
|
kotlinOptions.apiVersion = "1.3"
|
||||||
kotlinOptions.freeCompilerArgs += listOf(
|
kotlinOptions.freeCompilerArgs += listOf(
|
||||||
"-Xskip-prerelease-check", "-Xsuppress-version-warnings"
|
"-Xskip-prerelease-check",
|
||||||
|
"-Xskip-runtime-version-check",
|
||||||
|
"-Xsuppress-version-warnings"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -79,9 +79,9 @@ internal fun <T : KotlinTarget> KotlinTargetsContainerWithPresets.configureOrCre
|
|||||||
else -> {
|
else -> {
|
||||||
throw InvalidUserCodeException(
|
throw InvalidUserCodeException(
|
||||||
"The target '$targetName' already exists, but it was not created with the '${targetPreset.name}' preset. " +
|
"The target '$targetName' already exists, but it was not created with the '${targetPreset.name}' preset. " +
|
||||||
"To configure it, access it by name in `kotlin.targets`" +
|
"To configure it, access it by name in `kotlin.targets`" +
|
||||||
" or use the preset function '${existingTarget.preset?.name}'."
|
(" or use the preset function '${existingTarget.preset?.name}'."
|
||||||
.takeIf { existingTarget.preset != null } ?: "."
|
.takeIf { existingTarget.preset != null } ?: ".")
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-2
@@ -5,7 +5,10 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.gradle.dsl
|
package org.jetbrains.kotlin.gradle.dsl
|
||||||
|
|
||||||
import org.gradle.api.*
|
import org.gradle.api.DomainObjectSet
|
||||||
|
import org.gradle.api.Named
|
||||||
|
import org.gradle.api.NamedDomainObjectSet
|
||||||
|
import org.gradle.api.Project
|
||||||
import org.gradle.api.plugins.ExtensionAware
|
import org.gradle.api.plugins.ExtensionAware
|
||||||
import org.gradle.util.WrapUtil
|
import org.gradle.util.WrapUtil
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation
|
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation
|
||||||
@@ -51,7 +54,7 @@ open class KotlinNativeBinaryContainer @Inject constructor(
|
|||||||
"Binary $name has incorrect outputKind or build type.\n" +
|
"Binary $name has incorrect outputKind or build type.\n" +
|
||||||
"Expected: ${buildType.getName()} $classifier. Actual: ${binary.buildType.getName()} ${binary.outputKind.taskNameClassifier}."
|
"Expected: ${buildType.getName()} $classifier. Actual: ${binary.buildType.getName()} ${binary.outputKind.taskNameClassifier}."
|
||||||
}
|
}
|
||||||
return binary as T
|
return binary
|
||||||
}
|
}
|
||||||
|
|
||||||
private inline fun <reified T : NativeBinary> findBinary(
|
private inline fun <reified T : NativeBinary> findBinary(
|
||||||
|
|||||||
+3
@@ -129,6 +129,7 @@ open class KotlinJsProjectExtension(project: Project) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated("Use js() instead", ReplaceWith("js()"))
|
@Deprecated("Use js() instead", ReplaceWith("js()"))
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
override var target: KotlinJsTargetDsl
|
override var target: KotlinJsTargetDsl
|
||||||
get() {
|
get() {
|
||||||
if (_target == null) {
|
if (_target == null) {
|
||||||
@@ -142,6 +143,7 @@ open class KotlinJsProjectExtension(project: Project) :
|
|||||||
|
|
||||||
override lateinit var defaultJsCompilerType: KotlinJsCompilerType
|
override lateinit var defaultJsCompilerType: KotlinJsCompilerType
|
||||||
|
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
private fun jsInternal(
|
private fun jsInternal(
|
||||||
compiler: KotlinJsCompilerType? = null,
|
compiler: KotlinJsCompilerType? = null,
|
||||||
body: KotlinJsTargetDsl.() -> Unit
|
body: KotlinJsTargetDsl.() -> Unit
|
||||||
@@ -230,6 +232,7 @@ open class KotlinJsProjectExtension(project: Project) :
|
|||||||
"Needed for IDE import using the MPP import mechanism",
|
"Needed for IDE import using the MPP import mechanism",
|
||||||
level = DeprecationLevel.HIDDEN
|
level = DeprecationLevel.HIDDEN
|
||||||
)
|
)
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
fun getTargets(): NamedDomainObjectContainer<KotlinTarget>? =
|
fun getTargets(): NamedDomainObjectContainer<KotlinTarget>? =
|
||||||
_target?.let { target ->
|
_target?.let { target ->
|
||||||
target.project.container(KotlinTarget::class.java)
|
target.project.container(KotlinTarget::class.java)
|
||||||
|
|||||||
+1
@@ -96,6 +96,7 @@ private fun KotlinTargetContainerWithJsPresetFunctions.jsInternal(
|
|||||||
}
|
}
|
||||||
|
|
||||||
reportJsCompilerMode(compilerOrDefault)
|
reportJsCompilerMode(compilerOrDefault)
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
return configureOrCreate(
|
return configureOrCreate(
|
||||||
targetName,
|
targetName,
|
||||||
presets.getByName(
|
presets.getByName(
|
||||||
|
|||||||
+3
-3
@@ -5,12 +5,12 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.gradle.incremental
|
package org.jetbrains.kotlin.gradle.incremental
|
||||||
|
|
||||||
import org.gradle.api.tasks.incremental.IncrementalTaskInputs
|
|
||||||
import org.jetbrains.kotlin.incremental.ChangedFiles
|
import org.jetbrains.kotlin.incremental.ChangedFiles
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
internal fun ChangedFiles(taskInputs: IncrementalTaskInputs): ChangedFiles {
|
internal fun ChangedFiles(
|
||||||
|
@Suppress("DEPRECATION") taskInputs: org.gradle.api.tasks.incremental.IncrementalTaskInputs
|
||||||
|
): ChangedFiles {
|
||||||
if (!taskInputs.isIncremental) return ChangedFiles.Unknown()
|
if (!taskInputs.isIncremental) return ChangedFiles.Unknown()
|
||||||
|
|
||||||
val modified = ArrayList<File>()
|
val modified = ArrayList<File>()
|
||||||
|
|||||||
+1
-1
@@ -757,7 +757,7 @@ internal fun registerGeneratedJavaSource(kaptTask: TaskProvider<out KaptTask>, j
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun Configuration.getNamedDependencies(): List<Dependency> = allDependencies.filter { it.group != null && it.name != null }
|
internal fun Configuration.getNamedDependencies(): List<Dependency> = allDependencies.filter { it.group != null }
|
||||||
|
|
||||||
private val ANNOTATION_PROCESSOR = "annotationProcessor"
|
private val ANNOTATION_PROCESSOR = "annotationProcessor"
|
||||||
private val ANNOTATION_PROCESSOR_CAP = ANNOTATION_PROCESSOR.capitalize()
|
private val ANNOTATION_PROCESSOR_CAP = ANNOTATION_PROCESSOR.capitalize()
|
||||||
|
|||||||
+4
-5
@@ -6,7 +6,6 @@
|
|||||||
package org.jetbrains.kotlin.gradle.internal
|
package org.jetbrains.kotlin.gradle.internal
|
||||||
|
|
||||||
import org.gradle.api.file.ConfigurableFileCollection
|
import org.gradle.api.file.ConfigurableFileCollection
|
||||||
import org.gradle.api.file.DirectoryProperty
|
|
||||||
import org.gradle.api.model.ObjectFactory
|
import org.gradle.api.model.ObjectFactory
|
||||||
import org.gradle.api.provider.Property
|
import org.gradle.api.provider.Property
|
||||||
import org.gradle.api.tasks.*
|
import org.gradle.api.tasks.*
|
||||||
@@ -84,10 +83,10 @@ abstract class KaptWithoutKotlincTask @Inject constructor(
|
|||||||
for (option in options) {
|
for (option in options) {
|
||||||
result[option.key] = option.value
|
result[option.key] = option.value
|
||||||
}
|
}
|
||||||
annotationProcessorOptionProviders.forEach {
|
annotationProcessorOptionProviders.forEach { providers ->
|
||||||
(it as List<Any>).forEach {
|
(providers as List<*>).forEach { provider ->
|
||||||
(it as CommandLineArgumentProvider).asArguments().forEach {
|
(provider as CommandLineArgumentProvider).asArguments().forEach { argument ->
|
||||||
result[it.removePrefix("-A")] = ""
|
result[argument.removePrefix("-A")] = ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -6,8 +6,8 @@
|
|||||||
package org.jetbrains.kotlin.gradle.logging
|
package org.jetbrains.kotlin.gradle.logging
|
||||||
|
|
||||||
import org.gradle.api.logging.Logger
|
import org.gradle.api.logging.Logger
|
||||||
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSourceLocation
|
|
||||||
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
|
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
|
||||||
|
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSourceLocation
|
||||||
import org.jetbrains.kotlin.cli.common.messages.GradleStyleMessageRenderer
|
import org.jetbrains.kotlin.cli.common.messages.GradleStyleMessageRenderer
|
||||||
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
|
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
|
||||||
import org.jetbrains.kotlin.compilerRunner.KotlinLogger
|
import org.jetbrains.kotlin.compilerRunner.KotlinLogger
|
||||||
@@ -32,6 +32,7 @@ internal class GradlePrintingMessageCollector(
|
|||||||
override fun report(severity: CompilerMessageSeverity, message: String, location: CompilerMessageSourceLocation?) {
|
override fun report(severity: CompilerMessageSeverity, message: String, location: CompilerMessageSourceLocation?) {
|
||||||
val renderedMessage = messageRenderer.render(severity, message, location)
|
val renderedMessage = messageRenderer.render(severity, message, location)
|
||||||
|
|
||||||
|
@Suppress("UNNECESSARY_NOT_NULL_ASSERTION")
|
||||||
when (severity) {
|
when (severity) {
|
||||||
CompilerMessageSeverity.ERROR,
|
CompilerMessageSeverity.ERROR,
|
||||||
CompilerMessageSeverity.EXCEPTION -> {
|
CompilerMessageSeverity.EXCEPTION -> {
|
||||||
|
|||||||
+1
@@ -65,6 +65,7 @@ open class KaptExtension {
|
|||||||
private var apOptionsClosure: Closure<*>? = null
|
private var apOptionsClosure: Closure<*>? = null
|
||||||
private var javacOptionsClosure: Closure<*>? = null
|
private var javacOptionsClosure: Closure<*>? = null
|
||||||
|
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
open fun annotationProcessor(fqName: String) {
|
open fun annotationProcessor(fqName: String) {
|
||||||
val oldProcessors = this.processors
|
val oldProcessors = this.processors
|
||||||
this.processors = if (oldProcessors.isEmpty()) fqName else "$oldProcessors,$fqName"
|
this.processors = if (oldProcessors.isEmpty()) fqName else "$oldProcessors,$fqName"
|
||||||
|
|||||||
+5
-8
@@ -701,9 +701,7 @@ internal open class KotlinAndroidPlugin(
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun androidTargetHandler(
|
fun androidTargetHandler(): AbstractAndroidProjectHandler {
|
||||||
androidTarget: KotlinAndroidTarget
|
|
||||||
): AbstractAndroidProjectHandler {
|
|
||||||
val tasksProvider = AndroidTasksProvider()
|
val tasksProvider = AndroidTasksProvider()
|
||||||
|
|
||||||
if (androidPluginVersion != null) {
|
if (androidPluginVersion != null) {
|
||||||
@@ -720,15 +718,14 @@ internal open class KotlinAndroidPlugin(
|
|||||||
return Android25ProjectHandler(kotlinTools)
|
return Android25ProjectHandler(kotlinTools)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun applyToTarget(
|
fun applyToTarget(kotlinTarget: KotlinAndroidTarget) {
|
||||||
kotlinTarget: KotlinAndroidTarget
|
androidTargetHandler().configureTarget(kotlinTarget)
|
||||||
) {
|
|
||||||
androidTargetHandler(kotlinTarget).configureTarget(kotlinTarget)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class KotlinConfigurationTools internal constructor(
|
class KotlinConfigurationTools internal constructor(
|
||||||
|
@Suppress("EXPOSED_PROPERTY_TYPE_IN_CONSTRUCTOR")
|
||||||
val kotlinTasksProvider: KotlinTasksProvider
|
val kotlinTasksProvider: KotlinTasksProvider
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -841,7 +838,7 @@ abstract class AbstractAndroidProjectHandler(private val kotlinConfigurationTool
|
|||||||
project.addExtendsFromRelation(androidSourceSet.apiConfigurationName, apiConfigurationName)
|
project.addExtendsFromRelation(androidSourceSet.apiConfigurationName, apiConfigurationName)
|
||||||
} else {
|
} else {
|
||||||
// If any dependency is added to this configuration, report an error:
|
// If any dependency is added to this configuration, report an error:
|
||||||
project.configurations.getByName(apiConfigurationName).dependencies.all { dependency ->
|
project.configurations.getByName(apiConfigurationName).dependencies.all {
|
||||||
throw InvalidUserCodeException(
|
throw InvalidUserCodeException(
|
||||||
"API dependencies are not allowed for Android source set ${androidSourceSet.name}. " +
|
"API dependencies are not allowed for Android source set ${androidSourceSet.name}. " +
|
||||||
"Please use an implementation dependency instead."
|
"Please use an implementation dependency instead."
|
||||||
|
|||||||
+2
-2
@@ -37,7 +37,7 @@ import org.jetbrains.kotlin.gradle.plugin.statistics.KotlinBuildStatsService
|
|||||||
import org.jetbrains.kotlin.gradle.targets.js.KotlinJsCompilerAttribute
|
import org.jetbrains.kotlin.gradle.targets.js.KotlinJsCompilerAttribute
|
||||||
import org.jetbrains.kotlin.gradle.targets.js.KotlinJsPlugin
|
import org.jetbrains.kotlin.gradle.targets.js.KotlinJsPlugin
|
||||||
import org.jetbrains.kotlin.gradle.targets.js.npm.addNpmDependencyExtension
|
import org.jetbrains.kotlin.gradle.targets.js.npm.addNpmDependencyExtension
|
||||||
import org.jetbrains.kotlin.gradle.tasks.*
|
import org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile
|
||||||
import org.jetbrains.kotlin.gradle.tasks.KOTLIN_COMPILER_EMBEDDABLE
|
import org.jetbrains.kotlin.gradle.tasks.KOTLIN_COMPILER_EMBEDDABLE
|
||||||
import org.jetbrains.kotlin.gradle.tasks.KOTLIN_KLIB_COMMONIZER_EMBEDDABLE
|
import org.jetbrains.kotlin.gradle.tasks.KOTLIN_KLIB_COMMONIZER_EMBEDDABLE
|
||||||
import org.jetbrains.kotlin.gradle.tasks.KOTLIN_MODULE_GROUP
|
import org.jetbrains.kotlin.gradle.tasks.KOTLIN_MODULE_GROUP
|
||||||
@@ -63,7 +63,7 @@ abstract class KotlinBasePluginWrapper : Plugin<Project> {
|
|||||||
val kotlinPluginVersion = project.getKotlinPluginVersion()
|
val kotlinPluginVersion = project.getKotlinPluginVersion()
|
||||||
|
|
||||||
val listenerRegistryHolder = BuildEventsListenerRegistryHolder.getInstance(project)
|
val listenerRegistryHolder = BuildEventsListenerRegistryHolder.getInstance(project)
|
||||||
val statisticsReporter = KotlinBuildStatsService.getOrCreateInstance(project, listenerRegistryHolder)
|
val statisticsReporter = KotlinBuildStatsService.getOrCreateInstance(project)
|
||||||
statisticsReporter?.report(StringMetrics.KOTLIN_COMPILER_VERSION, kotlinPluginVersion)
|
statisticsReporter?.report(StringMetrics.KOTLIN_COMPILER_VERSION, kotlinPluginVersion)
|
||||||
|
|
||||||
checkGradleCompatibility()
|
checkGradleCompatibility()
|
||||||
|
|||||||
+3
-4
@@ -16,7 +16,6 @@ import org.gradle.api.attributes.Usage
|
|||||||
import org.gradle.api.attributes.Usage.USAGE_ATTRIBUTE
|
import org.gradle.api.attributes.Usage.USAGE_ATTRIBUTE
|
||||||
import org.gradle.api.file.FileCollection
|
import org.gradle.api.file.FileCollection
|
||||||
import org.gradle.api.internal.artifacts.ArtifactAttributes
|
import org.gradle.api.internal.artifacts.ArtifactAttributes
|
||||||
import org.gradle.api.internal.plugins.DslObject
|
|
||||||
import org.gradle.api.plugins.BasePlugin
|
import org.gradle.api.plugins.BasePlugin
|
||||||
import org.gradle.api.plugins.ExtensionAware
|
import org.gradle.api.plugins.ExtensionAware
|
||||||
import org.gradle.api.plugins.JavaBasePlugin
|
import org.gradle.api.plugins.JavaBasePlugin
|
||||||
@@ -272,7 +271,7 @@ abstract class AbstractKotlinTargetConfigurator<KotlinTargetType : KotlinTarget>
|
|||||||
val target = compilation.target
|
val target = compilation.target
|
||||||
val configurations = target.project.configurations
|
val configurations = target.project.configurations
|
||||||
|
|
||||||
val pluginConfiguration = configurations.maybeCreate(compilation.pluginConfigurationName).apply {
|
configurations.maybeCreate(compilation.pluginConfigurationName).apply {
|
||||||
if (target.platformType == KotlinPlatformType.native) {
|
if (target.platformType == KotlinPlatformType.native) {
|
||||||
extendsFrom(configurations.getByName(NATIVE_COMPILER_PLUGIN_CLASSPATH_CONFIGURATION_NAME))
|
extendsFrom(configurations.getByName(NATIVE_COMPILER_PLUGIN_CLASSPATH_CONFIGURATION_NAME))
|
||||||
isTransitive = false
|
isTransitive = false
|
||||||
@@ -317,7 +316,7 @@ abstract class AbstractKotlinTargetConfigurator<KotlinTargetType : KotlinTarget>
|
|||||||
description = "Compile only dependencies for $compilation."
|
description = "Compile only dependencies for $compilation."
|
||||||
}
|
}
|
||||||
|
|
||||||
val compileClasspathConfiguration = configurations.maybeCreate(compilation.compileDependencyConfigurationName).apply {
|
configurations.maybeCreate(compilation.compileDependencyConfigurationName).apply {
|
||||||
extendsFrom(compileOnlyConfiguration, implementationConfiguration)
|
extendsFrom(compileOnlyConfiguration, implementationConfiguration)
|
||||||
usesPlatformOf(target)
|
usesPlatformOf(target)
|
||||||
isVisible = false
|
isVisible = false
|
||||||
@@ -344,7 +343,7 @@ abstract class AbstractKotlinTargetConfigurator<KotlinTargetType : KotlinTarget>
|
|||||||
description = "Runtime only dependencies for $compilation."
|
description = "Runtime only dependencies for $compilation."
|
||||||
}
|
}
|
||||||
|
|
||||||
val runtimeClasspathConfiguration = configurations.maybeCreate(compilation.runtimeDependencyConfigurationName).apply {
|
configurations.maybeCreate(compilation.runtimeDependencyConfigurationName).apply {
|
||||||
extendsFrom(runtimeOnlyConfiguration, implementationConfiguration)
|
extendsFrom(runtimeOnlyConfiguration, implementationConfiguration)
|
||||||
runtimeConfiguration?.let { extendsFrom(it) }
|
runtimeConfiguration?.let { extendsFrom(it) }
|
||||||
usesPlatformOf(target)
|
usesPlatformOf(target)
|
||||||
|
|||||||
+7
-7
@@ -7,8 +7,10 @@ import org.gradle.api.tasks.compile.AbstractCompile
|
|||||||
import org.gradle.api.tasks.compile.JavaCompile
|
import org.gradle.api.tasks.compile.JavaCompile
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinCompile
|
import org.jetbrains.kotlin.gradle.dsl.KotlinCompile
|
||||||
import org.jetbrains.kotlin.gradle.logging.kotlinDebug
|
import org.jetbrains.kotlin.gradle.logging.kotlinDebug
|
||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.*
|
import org.jetbrains.kotlin.gradle.plugin.mpp.AbstractKotlinNativeCompilation
|
||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.KotlinCompilationData
|
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJvmAndroidCompilation
|
||||||
|
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJvmCompilation
|
||||||
|
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinWithJavaCompilation
|
||||||
import org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile
|
import org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile
|
||||||
import org.jetbrains.kotlin.gradle.tasks.CompilerPluginOptions
|
import org.jetbrains.kotlin.gradle.tasks.CompilerPluginOptions
|
||||||
import org.jetbrains.kotlin.gradle.tasks.KotlinNativeCompile
|
import org.jetbrains.kotlin.gradle.tasks.KotlinNativeCompile
|
||||||
@@ -127,7 +129,7 @@ internal fun addCompilationSourcesToExternalCompileTask(compilation: KotlinCompi
|
|||||||
internal class LegacyKotlinCompilerPluginSupportPlugin(
|
internal class LegacyKotlinCompilerPluginSupportPlugin(
|
||||||
@Suppress("deprecation") // support for deprecated API
|
@Suppress("deprecation") // support for deprecated API
|
||||||
val oldPlugin: KotlinGradleSubplugin<AbstractCompile>
|
val oldPlugin: KotlinGradleSubplugin<AbstractCompile>
|
||||||
): KotlinCompilerPluginSupportPlugin {
|
) : KotlinCompilerPluginSupportPlugin {
|
||||||
override fun isApplicable(kotlinCompilation: KotlinCompilation<*>): Boolean =
|
override fun isApplicable(kotlinCompilation: KotlinCompilation<*>): Boolean =
|
||||||
oldPlugin.isApplicable(kotlinCompilation.target.project, kotlinCompilation.compileKotlinTaskProvider.get() as AbstractCompile)
|
oldPlugin.isApplicable(kotlinCompilation.target.project, kotlinCompilation.compileKotlinTaskProvider.get() as AbstractCompile)
|
||||||
|
|
||||||
@@ -136,10 +138,8 @@ internal class LegacyKotlinCompilerPluginSupportPlugin(
|
|||||||
): Provider<List<SubpluginOption>> {
|
): Provider<List<SubpluginOption>> {
|
||||||
val project = kotlinCompilation.target.project
|
val project = kotlinCompilation.target.project
|
||||||
|
|
||||||
val androidProjectHandlerOrNull: AbstractAndroidProjectHandler? = if (kotlinCompilation is KotlinJvmAndroidCompilation)
|
val androidProjectHandlerOrNull: AbstractAndroidProjectHandler? =
|
||||||
KotlinAndroidPlugin.androidTargetHandler(
|
if (kotlinCompilation is KotlinJvmAndroidCompilation) KotlinAndroidPlugin.androidTargetHandler() else null
|
||||||
kotlinCompilation.target as KotlinAndroidTarget
|
|
||||||
) else null
|
|
||||||
|
|
||||||
val variantData = (kotlinCompilation as? KotlinJvmAndroidCompilation)?.androidVariant
|
val variantData = (kotlinCompilation as? KotlinJvmAndroidCompilation)?.androidVariant
|
||||||
|
|
||||||
|
|||||||
-1
@@ -391,7 +391,6 @@ private class ProjectMppDependencyMetadataExtractor(
|
|||||||
is KotlinMultiplatformExtension -> projectExtension.targets.getByName(KotlinMultiplatformPlugin.METADATA_TARGET_NAME).compilations
|
is KotlinMultiplatformExtension -> projectExtension.targets.getByName(KotlinMultiplatformPlugin.METADATA_TARGET_NAME).compilations
|
||||||
.filter { it.name in visibleSourceSetNames }.associate { it.defaultSourceSet.name to it.output.classesDirs }
|
.filter { it.name in visibleSourceSetNames }.associate { it.defaultSourceSet.name to it.output.classesDirs }
|
||||||
is KotlinPm20ProjectExtension -> {
|
is KotlinPm20ProjectExtension -> {
|
||||||
require(moduleIdentifier != null)
|
|
||||||
val moduleId = moduleIdentifier
|
val moduleId = moduleIdentifier
|
||||||
val module = projectExtension.modules.single { it.moduleIdentifier == moduleId }
|
val module = projectExtension.modules.single { it.moduleIdentifier == moduleId }
|
||||||
val metadataCompilationRegistry = projectExtension.metadataCompilationRegistryByModuleId.getValue(moduleId)
|
val metadataCompilationRegistry = projectExtension.metadataCompilationRegistryByModuleId.getValue(moduleId)
|
||||||
|
|||||||
+2
-3
@@ -82,7 +82,7 @@ sealed class SourceSetMetadataLayout(
|
|||||||
|
|
||||||
fun byName(name: String): SourceSetMetadataLayout? = values.firstOrNull { it.name == name }
|
fun byName(name: String): SourceSetMetadataLayout? = values.firstOrNull { it.name == name }
|
||||||
|
|
||||||
fun chooseForProducingProject(project: Project) =
|
fun chooseForProducingProject() =
|
||||||
/** A producing project will now only generate Granular source sets metadata as a KLIB */
|
/** A producing project will now only generate Granular source sets metadata as a KLIB */
|
||||||
KLIB
|
KLIB
|
||||||
}
|
}
|
||||||
@@ -173,7 +173,7 @@ internal fun buildKotlinProjectStructureMetadata(project: Project): KotlinProjec
|
|||||||
.filter { it in sourceSetsWithMetadataCompilations }.map { it.name }
|
.filter { it in sourceSetsWithMetadataCompilations }.map { it.name }
|
||||||
.toSet(),
|
.toSet(),
|
||||||
sourceSetBinaryLayout = sourceSetsWithMetadataCompilations.keys.associate { sourceSet ->
|
sourceSetBinaryLayout = sourceSetsWithMetadataCompilations.keys.associate { sourceSet ->
|
||||||
sourceSet.name to SourceSetMetadataLayout.chooseForProducingProject(project)
|
sourceSet.name to SourceSetMetadataLayout.chooseForProducingProject()
|
||||||
},
|
},
|
||||||
isPublishedAsRoot = true
|
isPublishedAsRoot = true
|
||||||
)
|
)
|
||||||
@@ -285,7 +285,6 @@ private val NodeList.elements: Iterable<Element> get() = (0 until length).map {
|
|||||||
internal fun parseKotlinSourceSetMetadataFromJson(string: String): KotlinProjectStructureMetadata? {
|
internal fun parseKotlinSourceSetMetadataFromJson(string: String): KotlinProjectStructureMetadata? {
|
||||||
@Suppress("DEPRECATION") // The replacement doesn't compile against old dependencies such as AS 4.0
|
@Suppress("DEPRECATION") // The replacement doesn't compile against old dependencies such as AS 4.0
|
||||||
val json = JsonParser().parse(string).asJsonObject
|
val json = JsonParser().parse(string).asJsonObject
|
||||||
val nodeNamed: JsonObject.(String) -> JsonObject? = { name -> get(name)?.asJsonObject }
|
|
||||||
val valueNamed: JsonObject.(String) -> String? = { name -> get(name)?.asString }
|
val valueNamed: JsonObject.(String) -> String? = { name -> get(name)?.asString }
|
||||||
val multiObjects: JsonObject.(String?) -> Iterable<JsonObject> = { name -> get(name).asJsonArray.map { it.asJsonObject } }
|
val multiObjects: JsonObject.(String?) -> Iterable<JsonObject> = { name -> get(name).asJsonArray.map { it.asJsonObject } }
|
||||||
val multiValues: JsonObject.(String?) -> Iterable<String> = { name -> get(name).asJsonArray.map { it.asString } }
|
val multiValues: JsonObject.(String?) -> Iterable<String> = { name -> get(name).asJsonArray.map { it.asString } }
|
||||||
|
|||||||
+1
-1
@@ -139,7 +139,7 @@ abstract class AbstractKotlinTarget(
|
|||||||
object : ComponentWithVariants, ComponentWithCoordinates, SoftwareComponentInternal {
|
object : ComponentWithVariants, ComponentWithCoordinates, SoftwareComponentInternal {
|
||||||
override fun getCoordinates() = (kotlinVariant as? ComponentWithCoordinates)?.coordinates
|
override fun getCoordinates() = (kotlinVariant as? ComponentWithCoordinates)?.coordinates
|
||||||
|
|
||||||
override fun getVariants(): Set<out SoftwareComponent> =
|
override fun getVariants(): Set<SoftwareComponent> =
|
||||||
(kotlinVariant as? KotlinVariantWithMetadataVariant)?.variants.orEmpty()
|
(kotlinVariant as? KotlinVariantWithMetadataVariant)?.variants.orEmpty()
|
||||||
|
|
||||||
override fun getName(): String = adhocVariant.name
|
override fun getName(): String = adhocVariant.name
|
||||||
|
|||||||
+2
-2
@@ -151,7 +151,7 @@ private fun associateDependenciesWithActualModuleDependencies(
|
|||||||
val dependencyProjectKotlinExtension = dependencyProject.multiplatformExtensionOrNull
|
val dependencyProjectKotlinExtension = dependencyProject.multiplatformExtensionOrNull
|
||||||
?: return@associate noMapping
|
?: return@associate noMapping
|
||||||
|
|
||||||
val resolved = resolvedDependencies[Triple(dependency.group, dependency.name, dependency.version)]
|
val resolved = resolvedDependencies[Triple(dependency.group!!, dependency.name, dependency.version!!)]
|
||||||
?: return@associate noMapping
|
?: return@associate noMapping
|
||||||
|
|
||||||
val resolvedToConfiguration = resolved.configuration
|
val resolvedToConfiguration = resolved.configuration
|
||||||
@@ -185,7 +185,7 @@ private fun associateDependenciesWithActualModuleDependencies(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
val resolvedDependency = resolvedDependencies[Triple(dependency.group, dependency.name, dependency.version)]
|
val resolvedDependency = resolvedDependencies[Triple(dependency.group!!, dependency.name, dependency.version!!)]
|
||||||
?: return@associate noMapping
|
?: return@associate noMapping
|
||||||
|
|
||||||
if (resolvedDependency.moduleArtifacts.isEmpty() && resolvedDependency.children.size == 1) {
|
if (resolvedDependency.moduleArtifacts.isEmpty() && resolvedDependency.children.size == 1) {
|
||||||
|
|||||||
+1
-1
@@ -146,7 +146,7 @@ open class KotlinPm20ProjectExtension(project: Project) : KotlinTopLevelExtensio
|
|||||||
|
|
||||||
@PublishedApi
|
@PublishedApi
|
||||||
@JvmName("isAllowCommonizer")
|
@JvmName("isAllowCommonizer")
|
||||||
internal fun isAllowCommonizerForIde(project: Project): Boolean = false
|
internal fun isAllowCommonizerForIde(@Suppress("UNUSED_PARAMETER") project: Project): Boolean = false
|
||||||
}
|
}
|
||||||
|
|
||||||
val KotlinGradleModule.jvm: KotlinJvmVariant
|
val KotlinGradleModule.jvm: KotlinJvmVariant
|
||||||
|
|||||||
+1
-1
@@ -246,7 +246,7 @@ internal fun KotlinSourceSet.disambiguateName(simpleName: String): String {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun createDefaultSourceDirectorySet(project: Project, name: String?): SourceDirectorySet =
|
private fun createDefaultSourceDirectorySet(project: Project, name: String?): SourceDirectorySet =
|
||||||
project.objects.sourceDirectorySet(name, name)
|
project.objects.sourceDirectorySet(name!!, name)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Like [resolveAllDependsOnSourceSets] but will include the receiver source set also!
|
* Like [resolveAllDependsOnSourceSets] but will include the receiver source set also!
|
||||||
|
|||||||
+1
-1
@@ -102,7 +102,7 @@ class KotlinBuildStatHandler {
|
|||||||
when (configurationName) {
|
when (configurationName) {
|
||||||
"kapt" -> {
|
"kapt" -> {
|
||||||
sessionLogger.report(BooleanMetrics.ENABLED_KAPT, true)
|
sessionLogger.report(BooleanMetrics.ENABLED_KAPT, true)
|
||||||
dependencies?.forEach { dependency ->
|
for (dependency in dependencies) {
|
||||||
when (dependency.group) {
|
when (dependency.group) {
|
||||||
"com.google.dagger" -> sessionLogger.report(BooleanMetrics.ENABLED_DAGGER, true)
|
"com.google.dagger" -> sessionLogger.report(BooleanMetrics.ENABLED_DAGGER, true)
|
||||||
"com.android.databinding" -> sessionLogger.report(BooleanMetrics.ENABLED_DATABINDING, true)
|
"com.android.databinding" -> sessionLogger.report(BooleanMetrics.ENABLED_DATABINDING, true)
|
||||||
|
|||||||
+3
-4
@@ -12,7 +12,6 @@ import org.gradle.api.invocation.Gradle
|
|||||||
import org.gradle.api.logging.Logging
|
import org.gradle.api.logging.Logging
|
||||||
import org.gradle.initialization.BuildRequestMetaData
|
import org.gradle.initialization.BuildRequestMetaData
|
||||||
import org.gradle.invocation.DefaultGradle
|
import org.gradle.invocation.DefaultGradle
|
||||||
import org.jetbrains.kotlin.gradle.plugin.BuildEventsListenerRegistryHolder
|
|
||||||
import org.jetbrains.kotlin.gradle.plugin.statistics.KotlinBuildStatHandler.Companion.runSafe
|
import org.jetbrains.kotlin.gradle.plugin.statistics.KotlinBuildStatHandler.Companion.runSafe
|
||||||
import org.jetbrains.kotlin.gradle.utils.isConfigurationCacheAvailable
|
import org.jetbrains.kotlin.gradle.utils.isConfigurationCacheAvailable
|
||||||
import org.jetbrains.kotlin.statistics.BuildSessionLogger
|
import org.jetbrains.kotlin.statistics.BuildSessionLogger
|
||||||
@@ -85,7 +84,7 @@ internal abstract class KotlinBuildStatsService internal constructor() : BuildAd
|
|||||||
*/
|
*/
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@Synchronized
|
@Synchronized
|
||||||
internal fun getOrCreateInstance(project: Project, listenerRegistryHolder: BuildEventsListenerRegistryHolder): IStatisticsValuesConsumer? {
|
internal fun getOrCreateInstance(project: Project): IStatisticsValuesConsumer? {
|
||||||
|
|
||||||
return runSafe("${KotlinBuildStatsService::class.java}.getOrCreateInstance") {
|
return runSafe("${KotlinBuildStatsService::class.java}.getOrCreateInstance") {
|
||||||
val gradle = project.gradle
|
val gradle = project.gradle
|
||||||
@@ -106,7 +105,7 @@ internal abstract class KotlinBuildStatsService internal constructor() : BuildAd
|
|||||||
)
|
)
|
||||||
instance = JMXKotlinBuildStatsService(mbs, beanName)
|
instance = JMXKotlinBuildStatsService(mbs, beanName)
|
||||||
} else {
|
} else {
|
||||||
val kotlinBuildStatProvider = project.provider{ KotlinBuildStatListener(beanName) }
|
project.provider { KotlinBuildStatListener(beanName) }
|
||||||
val newInstance = DefaultKotlinBuildStatsService(gradle, beanName)
|
val newInstance = DefaultKotlinBuildStatsService(gradle, beanName)
|
||||||
|
|
||||||
instance = newInstance
|
instance = newInstance
|
||||||
@@ -115,7 +114,7 @@ internal abstract class KotlinBuildStatsService internal constructor() : BuildAd
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!isConfigurationCacheAvailable(gradle)) {
|
if (!isConfigurationCacheAvailable(gradle)) {
|
||||||
gradle.addBuildListener(instance)
|
gradle.addBuildListener(instance!!)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
instance
|
instance
|
||||||
|
|||||||
+2
-4
@@ -71,9 +71,7 @@ open class KotlinAndroidTarget(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val variantNames =
|
val variantNames = KotlinAndroidPlugin.androidTargetHandler().getLibraryVariantNames()
|
||||||
KotlinAndroidPlugin.androidTargetHandler(this)
|
|
||||||
.getLibraryVariantNames()
|
|
||||||
|
|
||||||
val missingVariants =
|
val missingVariants =
|
||||||
publishLibraryVariants?.minus(variantNames).orEmpty()
|
publishLibraryVariants?.minus(variantNames).orEmpty()
|
||||||
@@ -90,7 +88,7 @@ open class KotlinAndroidTarget(
|
|||||||
override val kotlinComponents by lazy {
|
override val kotlinComponents by lazy {
|
||||||
checkPublishLibraryVariantsExist()
|
checkPublishLibraryVariantsExist()
|
||||||
|
|
||||||
KotlinAndroidPlugin.androidTargetHandler(this).doCreateComponents()
|
KotlinAndroidPlugin.androidTargetHandler().doCreateComponents()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun isVariantPublished(variant: BaseVariant): Boolean {
|
private fun isVariantPublished(variant: BaseVariant): Boolean {
|
||||||
|
|||||||
+1
-1
@@ -92,7 +92,7 @@ open class KotlinJsTargetPreset(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun createCompilationFactory(forTarget: KotlinJsTarget): KotlinJsCompilationFactory {
|
override fun createCompilationFactory(forTarget: KotlinJsTarget): KotlinJsCompilationFactory {
|
||||||
return KotlinJsCompilationFactory(project, forTarget, irPreset?.let { (forTarget as KotlinJsTarget).irTarget })
|
return KotlinJsCompilationFactory(project, forTarget, irPreset?.let { forTarget.irTarget })
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|||||||
+1
-2
@@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.gradle.targets.js.dsl
|
package org.jetbrains.kotlin.gradle.targets.js.dsl
|
||||||
|
|
||||||
@Experimental(level = Experimental.Level.WARNING)
|
@RequiresOptIn(level = RequiresOptIn.Level.WARNING)
|
||||||
// TODO: @RequiresOptIn(level = RequiresOptIn.Level.WARNING)
|
|
||||||
@Target(AnnotationTarget.FUNCTION)
|
@Target(AnnotationTarget.FUNCTION)
|
||||||
annotation class ExperimentalDceDsl
|
annotation class ExperimentalDceDsl
|
||||||
|
|||||||
+1
-2
@@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.gradle.targets.js.dsl
|
package org.jetbrains.kotlin.gradle.targets.js.dsl
|
||||||
|
|
||||||
@Experimental(level = Experimental.Level.WARNING)
|
@RequiresOptIn(level = RequiresOptIn.Level.WARNING)
|
||||||
// TODO: @RequiresOptIn(level = RequiresOptIn.Level.WARNING)
|
|
||||||
@Target(AnnotationTarget.FUNCTION)
|
@Target(AnnotationTarget.FUNCTION)
|
||||||
annotation class ExperimentalDistributionDsl
|
annotation class ExperimentalDistributionDsl
|
||||||
|
|||||||
+3
-3
@@ -82,12 +82,12 @@ constructor(
|
|||||||
private fun executableLegacyInternal(compilation: KotlinJsCompilation) = createBinaries(
|
private fun executableLegacyInternal(compilation: KotlinJsCompilation) = createBinaries(
|
||||||
compilation = compilation,
|
compilation = compilation,
|
||||||
jsBinaryType = KotlinJsBinaryType.EXECUTABLE,
|
jsBinaryType = KotlinJsBinaryType.EXECUTABLE,
|
||||||
create = { compilation, name, type ->
|
create = { jsCompilation, name, type ->
|
||||||
object : JsBinary {
|
object : JsBinary {
|
||||||
override val compilation: KotlinJsCompilation = compilation
|
override val compilation: KotlinJsCompilation = jsCompilation
|
||||||
override val name: String = name
|
override val name: String = name
|
||||||
override val mode: KotlinJsBinaryMode = type
|
override val mode: KotlinJsBinaryMode = type
|
||||||
override val distribution: Distribution = DefaultDistribution(compilation.target.project)
|
override val distribution: Distribution = DefaultDistribution(jsCompilation.target.project)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
+2
-4
@@ -10,7 +10,6 @@ import org.gradle.api.file.FileTree
|
|||||||
import org.gradle.api.file.RegularFileProperty
|
import org.gradle.api.file.RegularFileProperty
|
||||||
import org.gradle.api.model.ObjectFactory
|
import org.gradle.api.model.ObjectFactory
|
||||||
import org.gradle.api.tasks.*
|
import org.gradle.api.tasks.*
|
||||||
import org.gradle.api.tasks.incremental.IncrementalTaskInputs
|
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments
|
import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJsOptions
|
import org.jetbrains.kotlin.gradle.dsl.KotlinJsOptions
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJsOptionsImpl
|
import org.jetbrains.kotlin.gradle.dsl.KotlinJsOptionsImpl
|
||||||
@@ -50,9 +49,8 @@ open class KotlinJsIrLink @Inject constructor(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun skipCondition(inputs: IncrementalTaskInputs): Boolean {
|
override fun skipCondition(): Boolean =
|
||||||
return !inputs.isIncremental && !entryModule.exists()
|
!entryModule.exists()
|
||||||
}
|
|
||||||
|
|
||||||
override fun getDestinationDir(): File {
|
override fun getDestinationDir(): File {
|
||||||
return if (kotlinOptions.outputFile == null) {
|
return if (kotlinOptions.outputFile == null) {
|
||||||
|
|||||||
-2
@@ -196,8 +196,6 @@ abstract class KotlinJsIrSubTarget(
|
|||||||
protected open fun configureLibrary(compilation: KotlinJsIrCompilation) {
|
protected open fun configureLibrary(compilation: KotlinJsIrCompilation) {
|
||||||
val project = compilation.target.project
|
val project = compilation.target.project
|
||||||
|
|
||||||
val processResourcesTask = target.project.tasks.named(compilation.processResourcesTaskName)
|
|
||||||
|
|
||||||
val assembleTaskProvider = project.tasks.named(LifecycleBasePlugin.ASSEMBLE_TASK_NAME)
|
val assembleTaskProvider = project.tasks.named(LifecycleBasePlugin.ASSEMBLE_TASK_NAME)
|
||||||
|
|
||||||
val npmProject = compilation.npmProject
|
val npmProject = compilation.npmProject
|
||||||
|
|||||||
+3
@@ -58,15 +58,18 @@ open class NodeJsRootExtension(@Transient val rootProject: Project) : Configurat
|
|||||||
val nodeJsSetupTaskProvider: TaskProvider<out NodeJsSetupTask>
|
val nodeJsSetupTaskProvider: TaskProvider<out NodeJsSetupTask>
|
||||||
get() = rootProject.tasks.withType(NodeJsSetupTask::class.java).named(NodeJsSetupTask.NAME)
|
get() = rootProject.tasks.withType(NodeJsSetupTask::class.java).named(NodeJsSetupTask.NAME)
|
||||||
|
|
||||||
|
@Suppress("UNNECESSARY_SAFE_CALL") // TODO: investigate this warning; fixing it breaks integration tests.
|
||||||
val npmInstallTaskProvider: TaskProvider<out KotlinNpmInstallTask>?
|
val npmInstallTaskProvider: TaskProvider<out KotlinNpmInstallTask>?
|
||||||
get() = rootProject?.tasks?.withType(KotlinNpmInstallTask::class.java)?.named(KotlinNpmInstallTask.NAME)
|
get() = rootProject?.tasks?.withType(KotlinNpmInstallTask::class.java)?.named(KotlinNpmInstallTask.NAME)
|
||||||
|
|
||||||
val packageJsonUmbrellaTaskProvider: TaskProvider<Task>
|
val packageJsonUmbrellaTaskProvider: TaskProvider<Task>
|
||||||
get() = rootProject.tasks.named(PACKAGE_JSON_UMBRELLA_TASK_NAME)
|
get() = rootProject.tasks.named(PACKAGE_JSON_UMBRELLA_TASK_NAME)
|
||||||
|
|
||||||
|
@Suppress("UNNECESSARY_SAFE_CALL") // TODO: investigate this warning; fixing it breaks integration tests.
|
||||||
val rootPackageJsonTaskProvider: TaskProvider<RootPackageJsonTask>?
|
val rootPackageJsonTaskProvider: TaskProvider<RootPackageJsonTask>?
|
||||||
get() = rootProject?.tasks?.withType(RootPackageJsonTask::class.java)?.named(RootPackageJsonTask.NAME)
|
get() = rootProject?.tasks?.withType(RootPackageJsonTask::class.java)?.named(RootPackageJsonTask.NAME)
|
||||||
|
|
||||||
|
@Suppress("UNNECESSARY_SAFE_CALL") // TODO: investigate this warning; fixing it breaks integration tests.
|
||||||
val npmCachesSetupTaskProvider: TaskProvider<out KotlinNpmCachesSetup>?
|
val npmCachesSetupTaskProvider: TaskProvider<out KotlinNpmCachesSetup>?
|
||||||
get() = rootProject?.tasks?.withType(KotlinNpmCachesSetup::class.java)?.named(KotlinNpmCachesSetup.NAME)
|
get() = rootProject?.tasks?.withType(KotlinNpmCachesSetup::class.java)?.named(KotlinNpmCachesSetup.NAME)
|
||||||
|
|
||||||
|
|||||||
+4
-1
@@ -183,7 +183,7 @@ private abstract class NpmDependencyExtensionDelegate(
|
|||||||
val generateExternals = generateExternalsIfPossible(*args)
|
val generateExternals = generateExternalsIfPossible(*args)
|
||||||
|
|
||||||
return when (val arg1 = if (args.size > 1) args[1] else null) {
|
return when (val arg1 = if (args.size > 1) args[1] else null) {
|
||||||
null -> invoke(
|
null -> @Suppress("DEPRECATION") invoke(
|
||||||
name = name
|
name = name
|
||||||
)
|
)
|
||||||
is String -> invoke(
|
is String -> invoke(
|
||||||
@@ -249,6 +249,7 @@ private class DefaultNpmDependencyExtension(
|
|||||||
defaultGenerateExternals
|
defaultGenerateExternals
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
override fun invoke(name: String): NpmDependency =
|
override fun invoke(name: String): NpmDependency =
|
||||||
delegate.invoke(name)
|
delegate.invoke(name)
|
||||||
|
|
||||||
@@ -284,6 +285,7 @@ private class DefaultDevNpmDependencyExtension(
|
|||||||
null
|
null
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
override fun invoke(name: String): NpmDependency =
|
override fun invoke(name: String): NpmDependency =
|
||||||
delegate.invoke(name)
|
delegate.invoke(name)
|
||||||
|
|
||||||
@@ -398,6 +400,7 @@ private class DefaultPeerNpmDependencyExtension(
|
|||||||
npmDeclarationException(args)
|
npmDeclarationException(args)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
override fun invoke(name: String): NpmDependency =
|
override fun invoke(name: String): NpmDependency =
|
||||||
delegate.invoke(name)
|
delegate.invoke(name)
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -20,8 +20,8 @@ class YarnSimple : YarnBasics() {
|
|||||||
override fun resolveProject(resolvedNpmProject: KotlinCompilationNpmResolution) {
|
override fun resolveProject(resolvedNpmProject: KotlinCompilationNpmResolution) {
|
||||||
setup(resolvedNpmProject.project.rootProject)
|
setup(resolvedNpmProject.project.rootProject)
|
||||||
|
|
||||||
val project = resolvedNpmProject.project
|
// val project = resolvedNpmProject.project
|
||||||
|
//
|
||||||
// PackageJsonUpToDateCheck(resolvedNpmProject.npmProject).updateIfNeeded {
|
// PackageJsonUpToDateCheck(resolvedNpmProject.npmProject).updateIfNeeded {
|
||||||
// yarnExec(
|
// yarnExec(
|
||||||
// (project as ProjectInternal).services,
|
// (project as ProjectInternal).services,
|
||||||
|
|||||||
+1
@@ -611,6 +611,7 @@ internal fun getPublishedPlatformCompilations(project: Project): Map<KotlinUsage
|
|||||||
internal fun Project.filesWithUnpackedArchives(from: FileCollection, extensions: Set<String>): FileCollection =
|
internal fun Project.filesWithUnpackedArchives(from: FileCollection, extensions: Set<String>): FileCollection =
|
||||||
project.files(project.provider {
|
project.files(project.provider {
|
||||||
from.mapNotNull {
|
from.mapNotNull {
|
||||||
|
@Suppress("IMPLICIT_CAST_TO_ANY")
|
||||||
if (it.extension in extensions) {
|
if (it.extension in extensions) {
|
||||||
if (it.exists()) project.zipTree(it) else null
|
if (it.exists()) project.zipTree(it) else null
|
||||||
} else it
|
} else it
|
||||||
|
|||||||
+1
-1
@@ -348,7 +348,7 @@ open class KotlinNativeTargetConfigurator<T : KotlinNativeTarget> : AbstractKotl
|
|||||||
}
|
}
|
||||||
|
|
||||||
target.binaries.withType(AbstractNativeLibrary::class.java).all { framework ->
|
target.binaries.withType(AbstractNativeLibrary::class.java).all { framework ->
|
||||||
val exportConfiguration = project.configurations.maybeCreate(framework.exportConfigurationName).apply {
|
project.configurations.maybeCreate(framework.exportConfigurationName).apply {
|
||||||
isVisible = false
|
isVisible = false
|
||||||
isTransitive = false
|
isTransitive = false
|
||||||
isCanBeConsumed = false
|
isCanBeConsumed = false
|
||||||
|
|||||||
+3
-5
@@ -22,7 +22,6 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
|
|||||||
import org.jetbrains.kotlin.gradle.plugin.whenEvaluated
|
import org.jetbrains.kotlin.gradle.plugin.whenEvaluated
|
||||||
import org.jetbrains.kotlin.gradle.targets.native.tasks.*
|
import org.jetbrains.kotlin.gradle.targets.native.tasks.*
|
||||||
import org.jetbrains.kotlin.gradle.tasks.*
|
import org.jetbrains.kotlin.gradle.tasks.*
|
||||||
import org.jetbrains.kotlin.gradle.tasks.registerTask
|
|
||||||
import org.jetbrains.kotlin.gradle.utils.asValidTaskName
|
import org.jetbrains.kotlin.gradle.utils.asValidTaskName
|
||||||
import org.jetbrains.kotlin.gradle.utils.lowerCamelCaseName
|
import org.jetbrains.kotlin.gradle.utils.lowerCamelCaseName
|
||||||
import org.jetbrains.kotlin.konan.target.Family
|
import org.jetbrains.kotlin.konan.target.Family
|
||||||
@@ -373,15 +372,14 @@ open class KotlinCocoapodsPlugin : Plugin<Project> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cocoapodsExtension.pods.all { pod ->
|
cocoapodsExtension.pods.all { pod ->
|
||||||
val podSource = pod.source
|
val downloadPodTask = when (val podSource = pod.source) {
|
||||||
val downloadPodTask = when (podSource) {
|
|
||||||
is Git -> project.tasks.register(pod.toPodDownloadTaskName, PodDownloadGitTask::class.java) {
|
is Git -> project.tasks.register(pod.toPodDownloadTaskName, PodDownloadGitTask::class.java) {
|
||||||
it.podName = project.provider { pod.name.asValidTaskName() }
|
it.podName = project.provider { pod.name.asValidTaskName() }
|
||||||
it.podSource = project.provider { podSource as Git }
|
it.podSource = project.provider<Git> { podSource }
|
||||||
}
|
}
|
||||||
is Url -> project.tasks.register(pod.toPodDownloadTaskName, PodDownloadUrlTask::class.java) {
|
is Url -> project.tasks.register(pod.toPodDownloadTaskName, PodDownloadUrlTask::class.java) {
|
||||||
it.podName = project.provider { pod.name.asValidTaskName() }
|
it.podName = project.provider { pod.name.asValidTaskName() }
|
||||||
it.podSource = project.provider { podSource as Url }
|
it.podSource = project.provider<Url> { podSource }
|
||||||
}
|
}
|
||||||
else -> return@all
|
else -> return@all
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-10
@@ -54,12 +54,12 @@ fun parseKotlinNativeStackTrace(stackTrace: String): KotlinNativeStackTrace {
|
|||||||
stackTrace.lines().forEach {
|
stackTrace.lines().forEach {
|
||||||
val srcLine = it.trim()
|
val srcLine = it.trim()
|
||||||
|
|
||||||
var bin: String? = null
|
val bin: String?
|
||||||
var address: String? = null
|
val address: String?
|
||||||
var className: String? = null
|
val className: String?
|
||||||
var methodName: String? = null
|
val methodName: String?
|
||||||
var signature: String? = null
|
val signature: String?
|
||||||
var offset: Int = -1
|
val offset: Int
|
||||||
var fileName: String? = null
|
var fileName: String? = null
|
||||||
var lineNumber: Int = -1
|
var lineNumber: Int = -1
|
||||||
var columnNumber: Int = -1
|
var columnNumber: Int = -1
|
||||||
@@ -102,14 +102,13 @@ fun parseKotlinNativeStackTrace(stackTrace: String): KotlinNativeStackTrace {
|
|||||||
classAndMethod = classAndMethod.substringBeforeLast("(")
|
classAndMethod = classAndMethod.substringBeforeLast("(")
|
||||||
|
|
||||||
if ("." in classAndMethod) {
|
if ("." in classAndMethod) {
|
||||||
methodName = classAndMethod.substringAfterLast(".").trim()
|
methodName = classAndMethod.substringAfterLast(".").trim().takeUnless(String::isBlank)
|
||||||
className = classAndMethod.substringBeforeLast(".").trim()
|
className = classAndMethod.substringBeforeLast(".").trim()
|
||||||
} else {
|
} else {
|
||||||
methodName = classAndMethod.trim()
|
methodName = classAndMethod.trim().takeUnless(String::isBlank)
|
||||||
|
className = null
|
||||||
}
|
}
|
||||||
|
|
||||||
if (methodName.isBlank()) methodName = null
|
|
||||||
|
|
||||||
stack.add(
|
stack.add(
|
||||||
KotlinNativeStackTraceElement(
|
KotlinNativeStackTraceElement(
|
||||||
bin,
|
bin,
|
||||||
|
|||||||
+1
-1
@@ -103,7 +103,7 @@ open class PodspecTask : DefaultTask() {
|
|||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
}
|
}
|
||||||
|
|
||||||
val gradleCommand = "\$REPO_ROOT/${gradleWrapper!!.toRelativeString(project.projectDir)}"
|
val gradleCommand = "\$REPO_ROOT/${gradleWrapper.toRelativeString(project.projectDir)}"
|
||||||
val syncTask = "${project.path}:$SYNC_TASK_NAME"
|
val syncTask = "${project.path}:$SYNC_TASK_NAME"
|
||||||
|
|
||||||
val deploymentTargets = run {
|
val deploymentTargets = run {
|
||||||
|
|||||||
+11
-10
@@ -112,7 +112,7 @@ private fun FileCollection.filterOutPublishableInteropLibs(project: Project): Fi
|
|||||||
* for it (NO-SOURCE check). So we need to take this case into account
|
* for it (NO-SOURCE check). So we need to take this case into account
|
||||||
* and skip libraries that were not compiled. See also: GH-2617 (K/N repo).
|
* and skip libraries that were not compiled. See also: GH-2617 (K/N repo).
|
||||||
*/
|
*/
|
||||||
private fun Collection<File>.filterKlibsPassedToCompiler(project: Project) = filter {
|
private fun Collection<File>.filterKlibsPassedToCompiler(): List<File> = filter {
|
||||||
(it.extension == "klib" || it.isDirectory) && it.exists()
|
(it.extension == "klib" || it.isDirectory) && it.exists()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -277,6 +277,7 @@ abstract class AbstractKotlinNativeCompile<T : KotlinCommonToolOptions, K : Kotl
|
|||||||
@get:Input
|
@get:Input
|
||||||
@get:Optional
|
@get:Optional
|
||||||
internal val konanTargetsForManifest: String by project.provider {
|
internal val konanTargetsForManifest: String by project.provider {
|
||||||
|
@Suppress("CAST_NEVER_SUCCEEDS") // TODO: this warning looks very suspicious, as if the code never works as intended.
|
||||||
(compilation as? KotlinSharedNativeCompilation)
|
(compilation as? KotlinSharedNativeCompilation)
|
||||||
?.konanTargets
|
?.konanTargets
|
||||||
?.joinToString(separator = " ") { it.visibleName }
|
?.joinToString(separator = " ") { it.visibleName }
|
||||||
@@ -309,7 +310,7 @@ abstract class AbstractKotlinNativeCompile<T : KotlinCommonToolOptions, K : Kotl
|
|||||||
addArg("-o", outputFile.get().absolutePath)
|
addArg("-o", outputFile.get().absolutePath)
|
||||||
|
|
||||||
// Libraries.
|
// Libraries.
|
||||||
libraries.files.filterKlibsPassedToCompiler(project).forEach { library ->
|
libraries.files.filterKlibsPassedToCompiler().forEach { library ->
|
||||||
addArg("-l", library.absolutePath)
|
addArg("-l", library.absolutePath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -458,15 +459,15 @@ constructor(
|
|||||||
addArg("-module-name", moduleName)
|
addArg("-module-name", moduleName)
|
||||||
add("-Xshort-module-name=$shortModuleName")
|
add("-Xshort-module-name=$shortModuleName")
|
||||||
val friends = friendModule.files
|
val friends = friendModule.files
|
||||||
if (friends != null && friends.isNotEmpty()) {
|
if (friends.isNotEmpty()) {
|
||||||
addArg("-friend-modules", friends.map { it.absolutePath }.joinToString(File.pathSeparator))
|
addArg("-friend-modules", friends.joinToString(File.pathSeparator) { it.absolutePath })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun buildSourceArgs(): List<String> = mutableListOf<String>().apply {
|
override fun buildSourceArgs(): List<String> = mutableListOf<String>().apply {
|
||||||
addAll(getSource().map { it.absolutePath })
|
addAll(getSource().map { it.absolutePath })
|
||||||
if (!commonSourcesTree.isEmpty) {
|
if (!commonSourcesTree.isEmpty) {
|
||||||
add("-Xcommon-sources=${commonSourcesTree.map { it.absolutePath }.joinToString(separator = ",")}")
|
add("-Xcommon-sources=${commonSourcesTree.joinToString(separator = ",") { it.absolutePath }}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// endregion.
|
// endregion.
|
||||||
@@ -600,7 +601,7 @@ constructor(
|
|||||||
linkerOpts.forEach {
|
linkerOpts.forEach {
|
||||||
addArg("-linker-option", it)
|
addArg("-linker-option", it)
|
||||||
}
|
}
|
||||||
exportLibraries.files.filterKlibsPassedToCompiler(project).forEach {
|
exportLibraries.files.filterKlibsPassedToCompiler().forEach {
|
||||||
add("-Xexport-library=${it.absolutePath}")
|
add("-Xexport-library=${it.absolutePath}")
|
||||||
}
|
}
|
||||||
addKey("-Xstatic-framework", isStaticFramework)
|
addKey("-Xstatic-framework", isStaticFramework)
|
||||||
@@ -622,7 +623,7 @@ constructor(
|
|||||||
|
|
||||||
@get:Internal
|
@get:Internal
|
||||||
val apiFilesProvider = project.provider {
|
val apiFilesProvider = project.provider {
|
||||||
project.configurations.getByName(compilation.apiConfigurationName).files.filterKlibsPassedToCompiler(project)
|
project.configurations.getByName(compilation.apiConfigurationName).files.filterKlibsPassedToCompiler()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun validatedExportedLibraries() {
|
private fun validatedExportedLibraries() {
|
||||||
@@ -631,7 +632,7 @@ constructor(
|
|||||||
|
|
||||||
val failed = mutableSetOf<Dependency>()
|
val failed = mutableSetOf<Dependency>()
|
||||||
exportConfiguration.allDependencies.forEach {
|
exportConfiguration.allDependencies.forEach {
|
||||||
val dependencyFiles = exportConfiguration.files(it).filterKlibsPassedToCompiler(project)
|
val dependencyFiles = exportConfiguration.files(it).filterKlibsPassedToCompiler()
|
||||||
if (!apiFiles.containsAll(dependencyFiles)) {
|
if (!apiFiles.containsAll(dependencyFiles)) {
|
||||||
failed.add(it)
|
failed.add(it)
|
||||||
}
|
}
|
||||||
@@ -803,7 +804,7 @@ internal class CacheBuilder(val project: Project, val binary: NativeBinary, val
|
|||||||
getAllDependencies(dependency)
|
getAllDependencies(dependency)
|
||||||
.flatMap { it.moduleArtifacts }
|
.flatMap { it.moduleArtifacts }
|
||||||
.map { it.file }
|
.map { it.file }
|
||||||
.filterKlibsPassedToCompiler(project)
|
.filterKlibsPassedToCompiler()
|
||||||
.forEach {
|
.forEach {
|
||||||
args += "-l"
|
args += "-l"
|
||||||
args += it.absolutePath
|
args += it.absolutePath
|
||||||
@@ -1017,7 +1018,7 @@ open class CInteropProcess @Inject constructor(@get:Internal val settings: Defau
|
|||||||
addArg("-linker-option", it)
|
addArg("-linker-option", it)
|
||||||
}
|
}
|
||||||
|
|
||||||
libraries.files.filterKlibsPassedToCompiler(project).forEach { library ->
|
libraries.files.filterKlibsPassedToCompiler().forEach { library ->
|
||||||
addArg("-library", library.absolutePath)
|
addArg("-library", library.absolutePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-7
@@ -164,7 +164,6 @@ abstract class AbstractKotlinCompile<T : CommonCompilerArguments>() : AbstractKo
|
|||||||
cacheOnlyIfEnabledForKotlin()
|
cacheOnlyIfEnabledForKotlin()
|
||||||
}
|
}
|
||||||
|
|
||||||
@get:Internal
|
|
||||||
private val layout = project.layout
|
private val layout = project.layout
|
||||||
|
|
||||||
// avoid creating directory in getter: this can lead to failure in parallel build
|
// avoid creating directory in getter: this can lead to failure in parallel build
|
||||||
@@ -353,11 +352,9 @@ abstract class AbstractKotlinCompile<T : CommonCompilerArguments>() : AbstractKo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected open fun skipCondition(inputs: IncrementalTaskInputs): Boolean {
|
protected open fun skipCondition(): Boolean =
|
||||||
return !inputs.isIncremental && getSourceRoots().kotlinSourceFiles.isEmpty()
|
getSourceRoots().kotlinSourceFiles.isEmpty()
|
||||||
}
|
|
||||||
|
|
||||||
@get:Internal
|
|
||||||
private val projectDir = project.rootProject.projectDir
|
private val projectDir = project.rootProject.projectDir
|
||||||
|
|
||||||
private fun executeImpl(inputs: IncrementalTaskInputs) {
|
private fun executeImpl(inputs: IncrementalTaskInputs) {
|
||||||
@@ -369,7 +366,7 @@ abstract class AbstractKotlinCompile<T : CommonCompilerArguments>() : AbstractKo
|
|||||||
|
|
||||||
logger.kotlinDebug { "All kotlin sources: ${allKotlinSources.pathsAsStringRelativeTo(projectDir)}" }
|
logger.kotlinDebug { "All kotlin sources: ${allKotlinSources.pathsAsStringRelativeTo(projectDir)}" }
|
||||||
|
|
||||||
if (skipCondition(inputs)) {
|
if (!inputs.isIncremental && skipCondition()) {
|
||||||
// Skip running only if non-incremental run. Otherwise, we may need to do some cleanup.
|
// Skip running only if non-incremental run. Otherwise, we may need to do some cleanup.
|
||||||
logger.kotlinDebug { "No Kotlin files found, skipping Kotlin compiler task" }
|
logger.kotlinDebug { "No Kotlin files found, skipping Kotlin compiler task" }
|
||||||
return
|
return
|
||||||
@@ -453,7 +450,7 @@ class KotlinJvmCompilerArgumentsProvider
|
|||||||
compileClasspath = taskProvider.compileClasspath
|
compileClasspath = taskProvider.compileClasspath
|
||||||
destinationDir = taskProvider.destinationDir
|
destinationDir = taskProvider.destinationDir
|
||||||
kotlinOptions = listOfNotNull(
|
kotlinOptions = listOfNotNull(
|
||||||
taskProvider.parentKotlinOptionsImpl as KotlinJvmOptionsImpl?,
|
taskProvider.parentKotlinOptionsImpl,
|
||||||
taskProvider.kotlinOptions as KotlinJvmOptionsImpl
|
taskProvider.kotlinOptions as KotlinJvmOptionsImpl
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user