[Gradle] Dissolve plugin.mpp.pm20 package
KT-61463
This commit is contained in:
committed by
Space Team
parent
282d2f4454
commit
c889c2f217
+1
-3
@@ -6,16 +6,14 @@
|
||||
package org.jetbrains.kotlin.gradle.plugin.ide
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.artifacts.component.BuildIdentifier
|
||||
import org.gradle.api.artifacts.component.ModuleComponentIdentifier
|
||||
import org.gradle.api.artifacts.component.ProjectComponentIdentifier
|
||||
import org.gradle.api.attributes.AttributeContainer
|
||||
import org.gradle.api.capabilities.Capability
|
||||
import org.gradle.util.GradleVersion
|
||||
import org.jetbrains.kotlin.gradle.idea.tcs.*
|
||||
import org.jetbrains.kotlin.gradle.idea.tcs.extras.KlibExtra
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.util.currentBuildId
|
||||
import org.jetbrains.kotlin.gradle.utils.currentBuildId
|
||||
import org.jetbrains.kotlin.gradle.utils.buildNameCompat
|
||||
import org.jetbrains.kotlin.gradle.utils.buildPathCompat
|
||||
import org.jetbrains.kotlin.library.*
|
||||
|
||||
-1
@@ -17,7 +17,6 @@ import org.jetbrains.kotlin.gradle.dsl.kotlinExtensionOrNull
|
||||
import org.jetbrains.kotlin.gradle.dsl.multiplatformExtension
|
||||
import org.jetbrains.kotlin.gradle.plugin.*
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.MetadataDependencyResolution.ChooseVisibleSourceSets.MetadataProvider.ArtifactMetadataProvider
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.util.currentBuildId
|
||||
import org.jetbrains.kotlin.gradle.plugin.sources.internal
|
||||
import org.jetbrains.kotlin.gradle.utils.*
|
||||
import java.util.*
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ import org.gradle.api.tasks.Input
|
||||
import org.gradle.api.tasks.Internal
|
||||
import org.gradle.api.tasks.Nested
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.util.currentBuildId
|
||||
import org.jetbrains.kotlin.gradle.utils.currentBuildId
|
||||
import org.jetbrains.kotlin.gradle.plugin.sources.KotlinDependencyScope
|
||||
import org.jetbrains.kotlin.gradle.plugin.sources.sourceSetDependencyConfigurationByScope
|
||||
import org.jetbrains.kotlin.gradle.targets.metadata.dependsOnClosureWithInterCompilationDependencies
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ import org.gradle.api.internal.project.ProjectInternal
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinPluginLifecycle
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinTargetComponent
|
||||
import org.jetbrains.kotlin.gradle.plugin.launchInStage
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.util.copyAttributes
|
||||
import org.jetbrains.kotlin.gradle.utils.copyAttributes
|
||||
import org.jetbrains.kotlin.tooling.core.UnsafeApi
|
||||
|
||||
internal fun KotlinTargetSoftwareComponent(
|
||||
|
||||
+6
-68
@@ -8,18 +8,13 @@ package org.jetbrains.kotlin.gradle.plugin.mpp
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.artifacts.Dependency
|
||||
import org.gradle.api.artifacts.ProjectDependency
|
||||
import org.gradle.api.artifacts.component.*
|
||||
import org.gradle.api.artifacts.component.ComponentIdentifier
|
||||
import org.gradle.api.artifacts.component.ModuleComponentIdentifier
|
||||
import org.gradle.api.artifacts.component.ProjectComponentIdentifier
|
||||
import org.gradle.api.artifacts.result.ResolvedComponentResult
|
||||
import org.gradle.api.publish.maven.MavenPublication
|
||||
import org.jetbrains.kotlin.gradle.dsl.*
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.PublishedModuleCoordinatesProvider
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.util.currentBuildId
|
||||
import org.jetbrains.kotlin.gradle.utils.buildPathCompat
|
||||
import org.jetbrains.kotlin.gradle.dsl.multiplatformExtension
|
||||
import org.jetbrains.kotlin.gradle.dsl.multiplatformExtensionOrNull
|
||||
import org.jetbrains.kotlin.gradle.utils.currentBuild
|
||||
import org.jetbrains.kotlin.gradle.utils.getValue
|
||||
import org.jetbrains.kotlin.project.model.KpmLocalModuleIdentifier
|
||||
import org.jetbrains.kotlin.project.model.KpmMavenModuleIdentifier
|
||||
import org.jetbrains.kotlin.project.model.KpmModuleIdentifier
|
||||
|
||||
internal object ModuleIds {
|
||||
fun fromDependency(dependency: Dependency): ModuleDependencyIdentifier = when (dependency) {
|
||||
@@ -27,15 +22,6 @@ internal object ModuleIds {
|
||||
else -> ModuleDependencyIdentifier(dependency.group, dependency.name)
|
||||
}
|
||||
|
||||
fun fromComponentSelector(
|
||||
thisProject: Project,
|
||||
componentSelector: ComponentSelector
|
||||
): ModuleDependencyIdentifier = when (componentSelector) {
|
||||
is ProjectComponentSelector -> idOfRootModuleByProjectPath(thisProject, componentSelector.projectPath)
|
||||
is ModuleComponentSelector -> ModuleDependencyIdentifier(componentSelector.group, componentSelector.module)
|
||||
else -> idFromName(componentSelector.displayName)
|
||||
}
|
||||
|
||||
private fun fromComponentId(
|
||||
thisProject: Project,
|
||||
componentIdentifier: ComponentIdentifier
|
||||
@@ -68,52 +54,4 @@ internal object ModuleIds {
|
||||
|
||||
private fun idOfRootModuleByProjectPath(thisProject: Project, projectPath: String): ModuleDependencyIdentifier =
|
||||
idOfRootModule(thisProject.project(projectPath))
|
||||
|
||||
// FIXME use capabilities to point to auxiliary modules
|
||||
fun lossyFromModuleIdentifier(thisProject: Project, moduleIdentifier: KpmModuleIdentifier): ModuleDependencyIdentifier {
|
||||
when (moduleIdentifier) {
|
||||
is KpmLocalModuleIdentifier -> {
|
||||
check(moduleIdentifier.buildId == thisProject.currentBuildId().buildPathCompat)
|
||||
val dependencyProject = thisProject.project(moduleIdentifier.projectId)
|
||||
val topLevelExtension = dependencyProject.topLevelExtension
|
||||
val getRootPublication: () -> MavenPublication? = when {
|
||||
topLevelExtension is KotlinMultiplatformExtension -> {
|
||||
{ topLevelExtension.rootSoftwareComponent.publicationDelegate }
|
||||
}
|
||||
else -> error("unexpected top-level extension $topLevelExtension")
|
||||
}
|
||||
val coordinatesProvider = MavenPublicationCoordinatesProvider(
|
||||
dependencyProject,
|
||||
getRootPublication,
|
||||
defaultModuleSuffix = null,
|
||||
capabilities = emptyList()
|
||||
)
|
||||
return ChangingModuleDependencyIdentifier({ coordinatesProvider.group }, { coordinatesProvider.name })
|
||||
}
|
||||
is KpmMavenModuleIdentifier -> {
|
||||
return ModuleDependencyIdentifier(moduleIdentifier.group, moduleIdentifier.name)
|
||||
}
|
||||
else -> error("unexpected module identifier $moduleIdentifier")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
open class MavenPublicationCoordinatesProvider(
|
||||
project: Project,
|
||||
val getPublication: () -> MavenPublication?,
|
||||
defaultModuleSuffix: String?,
|
||||
override val capabilities: Iterable<String> = emptyList()
|
||||
) : PublishedModuleCoordinatesProvider {
|
||||
|
||||
override val group: String by project.provider {
|
||||
getPublication()?.groupId ?: project.group.toString()
|
||||
}
|
||||
|
||||
override val name: String by project.provider {
|
||||
getPublication()?.artifactId ?: project.name.plus(defaultModuleSuffix?.let { "-$it" }.orEmpty())
|
||||
}
|
||||
|
||||
override val version: String by project.provider {
|
||||
getPublication()?.version ?: project.version.toString()
|
||||
}
|
||||
}
|
||||
}
|
||||
-2
@@ -5,7 +5,6 @@
|
||||
|
||||
package org.jetbrains.kotlin.gradle.plugin.mpp
|
||||
|
||||
import org.jetbrains.kotlin.project.model.KpmModuleIdentifier
|
||||
import java.io.File
|
||||
import java.io.InputStream
|
||||
import java.util.zip.ZipFile
|
||||
@@ -18,7 +17,6 @@ sealed class MppDependencyProjectStructureMetadataExtractor {
|
||||
}
|
||||
|
||||
internal class ProjectMppDependencyProjectStructureMetadataExtractor(
|
||||
val moduleIdentifier: KpmModuleIdentifier,
|
||||
val projectPath: String,
|
||||
private val projectStructureMetadataProvider: () -> KotlinProjectStructureMetadata?,
|
||||
) : MppDependencyProjectStructureMetadataExtractor() {
|
||||
|
||||
-2
@@ -10,7 +10,6 @@ import org.gradle.api.artifacts.component.ProjectComponentIdentifier
|
||||
import org.gradle.api.artifacts.result.ResolvedArtifactResult
|
||||
import org.jetbrains.kotlin.gradle.dsl.multiplatformExtensionOrNull
|
||||
import org.jetbrains.kotlin.gradle.plugin.extraProperties
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.toSingleKpmModuleIdentifier
|
||||
import org.jetbrains.kotlin.gradle.utils.*
|
||||
import org.jetbrains.kotlin.gradle.utils.CurrentBuildIdentifier
|
||||
import org.jetbrains.kotlin.gradle.utils.buildNameCompat
|
||||
@@ -42,7 +41,6 @@ private constructor(
|
||||
?: error("Project structure metadata not found for project '${moduleId.projectPath}'")
|
||||
|
||||
ProjectMppDependencyProjectStructureMetadataExtractor(
|
||||
moduleIdentifier = metadataArtifact.variant.toSingleKpmModuleIdentifier(),
|
||||
projectPath = moduleId.projectPath,
|
||||
projectStructureMetadataProvider = projectStructureMetadataProvider::value
|
||||
)
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ package org.jetbrains.kotlin.gradle.plugin.mpp
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinPluginLifecycle.Stage.AfterEvaluateBuildscript
|
||||
import org.jetbrains.kotlin.gradle.plugin.launchInStage
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.util.copyAttributes
|
||||
import org.jetbrains.kotlin.gradle.utils.copyAttributes
|
||||
|
||||
|
||||
/**
|
||||
|
||||
-1
@@ -13,7 +13,6 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinWithJavaTarget
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.compilationImpl.DefaultKotlinCompilationConfigurationsContainer
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.compilationImpl.KotlinCompilationConfigurationsContainer
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.javaSourceSets
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.util.copyAttributes
|
||||
import org.jetbrains.kotlin.gradle.plugin.sources.METADATA_CONFIGURATION_NAME_SUFFIX
|
||||
import org.jetbrains.kotlin.gradle.targets.js.KotlinJsTarget
|
||||
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrTarget
|
||||
|
||||
+1
-2
@@ -13,11 +13,10 @@ import org.jetbrains.kotlin.gradle.internal.KAPT_GENERATE_STUBS_PREFIX
|
||||
import org.jetbrains.kotlin.gradle.internal.getKaptTaskName
|
||||
import org.jetbrains.kotlin.gradle.plugin.HasCompilerOptions
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.util.archivesName
|
||||
import org.jetbrains.kotlin.gradle.utils.archivesName
|
||||
import org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile
|
||||
import org.jetbrains.kotlin.gradle.utils.fileExtensionCasePermutations
|
||||
import org.jetbrains.kotlin.gradle.utils.lowerCamelCaseName
|
||||
import org.jetbrains.kotlin.tooling.core.closure
|
||||
import java.util.concurrent.Callable
|
||||
|
||||
internal fun KotlinCompilation<*>.isMain(): Boolean =
|
||||
|
||||
-79
@@ -1,79 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2020 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.mpp.pm20
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.artifacts.Configuration
|
||||
import org.gradle.api.artifacts.component.*
|
||||
import org.gradle.api.artifacts.result.ResolvedComponentResult
|
||||
import org.gradle.api.artifacts.result.ResolvedVariantResult
|
||||
import org.gradle.api.capabilities.Capability
|
||||
import org.gradle.util.GradleVersion
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinProjectStructureMetadata
|
||||
import org.jetbrains.kotlin.gradle.utils.buildPathCompat
|
||||
import org.jetbrains.kotlin.project.model.*
|
||||
|
||||
|
||||
|
||||
private fun ModuleComponentIdentifier.toSingleKpmModuleIdentifier(classifier: String? = null): KpmMavenModuleIdentifier =
|
||||
KpmMavenModuleIdentifier(moduleIdentifier.group, moduleIdentifier.name, classifier)
|
||||
|
||||
internal fun ComponentIdentifier.matchesModule(module: KpmModule): Boolean =
|
||||
matchesModuleIdentifier(module.moduleIdentifier)
|
||||
|
||||
internal fun ResolvedComponentResult.toKpmModuleIdentifiers(): List<KpmModuleIdentifier> {
|
||||
val classifiers = moduleClassifiersFromCapabilities(variants.flatMap { it.capabilities })
|
||||
return classifiers.map { moduleClassifier -> toKpmModuleIdentifier(moduleClassifier) }
|
||||
}
|
||||
|
||||
internal fun ResolvedVariantResult.toKpmModuleIdentifiers(): List<KpmModuleIdentifier> {
|
||||
val classifiers = moduleClassifiersFromCapabilities(capabilities)
|
||||
return classifiers.map { moduleClassifier -> toKpmModuleIdentifier(moduleClassifier) }
|
||||
}
|
||||
|
||||
// FIXME this mapping doesn't have enough information to choose auxiliary modules
|
||||
internal fun ResolvedComponentResult.toSingleKpmModuleIdentifier(): KpmModuleIdentifier {
|
||||
val classifiers = moduleClassifiersFromCapabilities(variants.flatMap { it.capabilities })
|
||||
val moduleClassifier = classifiers.single() // FIXME handle multiple capabilities
|
||||
return toKpmModuleIdentifier(moduleClassifier)
|
||||
}
|
||||
|
||||
internal fun ResolvedVariantResult.toSingleKpmModuleIdentifier(): KpmModuleIdentifier = toKpmModuleIdentifiers().singleOrNull()
|
||||
?: error("Unexpected amount of KPM Identifiers from '$this'. Only single Module Identifier was expected")
|
||||
|
||||
private fun ResolvedComponentResult.toKpmModuleIdentifier(moduleClassifier: String?): KpmModuleIdentifier {
|
||||
return when (val id = id) {
|
||||
is ProjectComponentIdentifier -> KpmLocalModuleIdentifier(id.build.buildPathCompat, id.projectPath, moduleClassifier)
|
||||
is ModuleComponentIdentifier -> id.toSingleKpmModuleIdentifier()
|
||||
else -> KpmMavenModuleIdentifier(moduleVersion?.group.orEmpty(), moduleVersion?.name.orEmpty(), moduleClassifier)
|
||||
}
|
||||
}
|
||||
|
||||
private fun ResolvedVariantResult.toKpmModuleIdentifier(moduleClassifier: String?): KpmModuleIdentifier {
|
||||
return when (val id = owner) {
|
||||
is ProjectComponentIdentifier -> KpmLocalModuleIdentifier(id.build.buildPathCompat, id.projectPath, moduleClassifier)
|
||||
is ModuleComponentIdentifier -> id.toSingleKpmModuleIdentifier()
|
||||
else -> error("Unexpected component identifier '$id' of type ${id.javaClass}")
|
||||
}
|
||||
}
|
||||
|
||||
internal fun moduleClassifiersFromCapabilities(capabilities: Iterable<Capability>): Iterable<String?> {
|
||||
val classifierCapabilities = capabilities.filter { it.name.contains("..") }
|
||||
return if (classifierCapabilities.none()) listOf(null) else classifierCapabilities.map { it.name.substringAfterLast("..") /*FIXME invent a more stable scheme*/ }
|
||||
}
|
||||
|
||||
internal fun ComponentIdentifier.matchesModuleIdentifier(id: KpmModuleIdentifier): Boolean =
|
||||
when (id) {
|
||||
is KpmLocalModuleIdentifier -> {
|
||||
val projectId = this as? ProjectComponentIdentifier
|
||||
projectId?.build?.buildPathCompat == id.buildId && projectId.projectPath == id.projectId
|
||||
}
|
||||
is KpmMavenModuleIdentifier -> {
|
||||
val componentId = this as? ModuleComponentIdentifier
|
||||
componentId?.toSingleKpmModuleIdentifier() == id
|
||||
}
|
||||
else -> false
|
||||
}
|
||||
-13
@@ -1,13 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.gradle.plugin.mpp.pm20
|
||||
|
||||
interface PublishedModuleCoordinatesProvider {
|
||||
val group: String
|
||||
val name: String
|
||||
val version: String
|
||||
val capabilities: Iterable<String>
|
||||
}
|
||||
-104
@@ -1,104 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.gradle.plugin.mpp.pm20.util
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.artifacts.Configuration
|
||||
import org.gradle.api.artifacts.DependencySet
|
||||
import org.gradle.api.artifacts.PublishArtifactSet
|
||||
import org.gradle.api.attributes.Attribute
|
||||
import org.gradle.api.attributes.AttributeContainer
|
||||
import org.gradle.api.capabilities.Capability
|
||||
import org.jetbrains.kotlin.gradle.plugin.ProjectLocalConfigurations
|
||||
|
||||
internal fun copyConfigurationForPublishing(
|
||||
project: Project,
|
||||
newName: String,
|
||||
configuration: Configuration,
|
||||
overrideDependencies: (DependencySet.() -> Unit)? = null,
|
||||
overrideArtifacts: (Configuration.(PublishArtifactSet) -> Unit)? = null,
|
||||
overrideAttributes: (Configuration.(AttributeContainer) -> Unit)? = {
|
||||
copyAttributes(it, attributes, it.keySet().minus(ProjectLocalConfigurations.ATTRIBUTE))
|
||||
},
|
||||
overrideCapabilities: (Configuration.(Collection<Capability>) -> Unit)? = null,
|
||||
configureAction: Configuration.() -> Unit = { }
|
||||
) = copyConfiguration(
|
||||
project,
|
||||
newName,
|
||||
configuration,
|
||||
overrideDependencies,
|
||||
overrideArtifacts,
|
||||
overrideAttributes,
|
||||
overrideCapabilities,
|
||||
configureAction = {
|
||||
isCanBeConsumed = false
|
||||
isCanBeResolved = false
|
||||
configureAction()
|
||||
}
|
||||
)
|
||||
|
||||
internal fun copyConfiguration(
|
||||
project: Project,
|
||||
newName: String,
|
||||
configuration: Configuration,
|
||||
overrideDependencies: (DependencySet.() -> Unit)? = null,
|
||||
overrideArtifacts: (Configuration.(PublishArtifactSet) -> Unit)? = null,
|
||||
overrideAttributes: (Configuration.(AttributeContainer) -> Unit)? = null,
|
||||
overrideCapabilities: (Configuration.(Collection<Capability>) -> Unit)? = null,
|
||||
configureAction: Configuration.() -> Unit = { }
|
||||
): Configuration =
|
||||
project.configurations.create(newName).apply {
|
||||
isCanBeConsumed = configuration.isCanBeConsumed
|
||||
isCanBeResolved = configuration.isCanBeResolved
|
||||
|
||||
// dependencies:
|
||||
if (overrideDependencies != null) {
|
||||
withDependencies { dependencySet ->
|
||||
overrideDependencies(dependencySet)
|
||||
}
|
||||
} else {
|
||||
dependencies.addAllLater(project.listProperty { configuration.allDependencies })
|
||||
}
|
||||
|
||||
// artifacts:
|
||||
if (overrideArtifacts != null) {
|
||||
overrideArtifacts(this, artifacts)
|
||||
} else {
|
||||
artifacts.addAllLater(project.listProperty { configuration.allArtifacts })
|
||||
}
|
||||
|
||||
// attributes
|
||||
if (overrideAttributes != null) {
|
||||
overrideAttributes(this, attributes)
|
||||
} else {
|
||||
copyAttributes(configuration.attributes, attributes)
|
||||
}
|
||||
|
||||
// capabilities
|
||||
if (overrideCapabilities != null) {
|
||||
overrideCapabilities(this, configuration.outgoing.capabilities)
|
||||
} else {
|
||||
configuration.outgoing.capabilities.forEach(outgoing::capability)
|
||||
}
|
||||
|
||||
configureAction(this)
|
||||
}
|
||||
|
||||
internal fun copyAttributes(from: AttributeContainer, to: AttributeContainer, keys: Iterable<Attribute<*>> = from.keySet()) {
|
||||
// capture type argument T
|
||||
fun <T : Any> copyOneAttribute(from: AttributeContainer, to: AttributeContainer, key: Attribute<T>) {
|
||||
val value = checkNotNull(from.getAttribute(key))
|
||||
to.attribute(key, value)
|
||||
}
|
||||
for (key in keys) {
|
||||
copyOneAttribute(from, to, key)
|
||||
}
|
||||
}
|
||||
|
||||
internal inline fun <reified T> Project.listProperty(noinline itemsProvider: () -> Iterable<T>) =
|
||||
objects.listProperty(T::class.java).apply { set(provider(itemsProvider)) }
|
||||
|
||||
|
||||
+2
-2
@@ -13,16 +13,16 @@ import org.gradle.api.provider.Provider
|
||||
import org.jetbrains.kotlin.gradle.dsl.kotlinExtension
|
||||
import org.jetbrains.kotlin.gradle.dsl.multiplatformExtension
|
||||
import org.jetbrains.kotlin.gradle.plugin.categoryByName
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.util.copyAttributes
|
||||
import org.jetbrains.kotlin.gradle.plugin.sources.*
|
||||
import org.jetbrains.kotlin.gradle.plugin.sources.InternalKotlinSourceSet
|
||||
import org.jetbrains.kotlin.gradle.plugin.sources.disambiguateName
|
||||
import org.jetbrains.kotlin.gradle.utils.markResolvable
|
||||
import org.jetbrains.kotlin.gradle.plugin.usageByName
|
||||
import org.jetbrains.kotlin.gradle.plugin.usesPlatformOf
|
||||
import org.jetbrains.kotlin.gradle.utils.*
|
||||
import org.jetbrains.kotlin.gradle.utils.getOrCreate
|
||||
import org.jetbrains.kotlin.gradle.utils.listProperty
|
||||
import org.jetbrains.kotlin.gradle.utils.lowerCamelCaseName
|
||||
import org.jetbrains.kotlin.gradle.utils.markResolvable
|
||||
import org.jetbrains.kotlin.tooling.core.extrasLazyProperty
|
||||
|
||||
/**
|
||||
|
||||
-1
@@ -15,7 +15,6 @@ import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompilerOptions
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompilerOptionsDefault
|
||||
import org.jetbrains.kotlin.gradle.plugin.*
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.util.copyAttributes
|
||||
import org.jetbrains.kotlin.gradle.tasks.DefaultKotlinJavaToolchain
|
||||
import org.jetbrains.kotlin.gradle.utils.*
|
||||
import org.jetbrains.kotlin.gradle.utils.dashSeparatedName
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ import org.gradle.language.base.plugins.LifecycleBasePlugin
|
||||
import org.jetbrains.kotlin.gradle.dsl.JsModuleKind
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJsDce
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.util.archivesName
|
||||
import org.jetbrains.kotlin.gradle.utils.archivesName
|
||||
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalDceDsl
|
||||
import org.jetbrains.kotlin.gradle.targets.js.dsl.KotlinJsBinaryMode
|
||||
import org.jetbrains.kotlin.gradle.targets.js.dsl.KotlinJsBrowserDsl
|
||||
|
||||
+1
-1
@@ -14,12 +14,12 @@ import org.jetbrains.kotlin.gradle.dsl.JsSourceMapEmbedMode
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJsCompilerOptions
|
||||
import org.jetbrains.kotlin.gradle.plugin.*
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinUsages
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.util.libsDirectory
|
||||
import org.jetbrains.kotlin.gradle.targets.js.KotlinJsReportAggregatingTestRun
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinTasksProvider
|
||||
import org.jetbrains.kotlin.gradle.testing.internal.kotlinTestRegistry
|
||||
import org.jetbrains.kotlin.gradle.testing.testTaskName
|
||||
import org.jetbrains.kotlin.gradle.utils.decamelize
|
||||
import org.jetbrains.kotlin.gradle.utils.libsDirectory
|
||||
|
||||
open class KotlinJsIrTargetConfigurator :
|
||||
KotlinOnlyTargetConfigurator<KotlinJsIrCompilation, KotlinJsIrTarget>(true),
|
||||
|
||||
+1
-2
@@ -8,8 +8,7 @@ package org.jetbrains.kotlin.gradle.targets.js.subtargets
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.file.DirectoryProperty
|
||||
import org.gradle.api.provider.Property
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.util.distsDirectory
|
||||
import org.jetbrains.kotlin.gradle.utils.distsDirectory
|
||||
import org.jetbrains.kotlin.gradle.targets.js.dsl.Distribution
|
||||
import org.jetbrains.kotlin.gradle.targets.js.dsl.Distribution.Companion.DIST
|
||||
import org.jetbrains.kotlin.gradle.utils.property
|
||||
|
||||
+2
-2
@@ -17,8 +17,8 @@ import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJsCompilation
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.isMain
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.isTest
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.util.archivesName
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.util.distsDirectory
|
||||
import org.jetbrains.kotlin.gradle.utils.archivesName
|
||||
import org.jetbrains.kotlin.gradle.utils.distsDirectory
|
||||
import org.jetbrains.kotlin.gradle.targets.js.KotlinJsTarget
|
||||
import org.jetbrains.kotlin.gradle.targets.js.dsl.*
|
||||
import org.jetbrains.kotlin.gradle.targets.js.ir.executeTaskBaseName
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ import org.gradle.work.NormalizeLineEndings
|
||||
import org.jetbrains.kotlin.build.report.metrics.*
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJsCompilation
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.util.archivesName
|
||||
import org.jetbrains.kotlin.gradle.utils.archivesName
|
||||
import org.jetbrains.kotlin.gradle.report.UsesBuildMetricsService
|
||||
import org.jetbrains.kotlin.gradle.targets.js.RequiredKotlinJsDependency
|
||||
import org.jetbrains.kotlin.gradle.targets.js.dsl.KotlinWebpackRulesContainer
|
||||
|
||||
-1
@@ -32,7 +32,6 @@ import org.jetbrains.kotlin.gradle.plugin.internal.JavaSourceSetsAccessor
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJvmCompilation
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinOnlyTarget
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.internal
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.util.copyAttributes
|
||||
import org.jetbrains.kotlin.gradle.targets.jvm.tasks.KotlinJvmRunDsl
|
||||
import org.jetbrains.kotlin.gradle.targets.jvm.tasks.KotlinJvmRunDslImpl
|
||||
import org.jetbrains.kotlin.gradle.targets.jvm.tasks.registerMainRunTask
|
||||
|
||||
+1
-1
@@ -32,7 +32,6 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.*
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.apple.XcodeVersionTask
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.apple.registerEmbedAndSignAppleFrameworkTask
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.apple.version
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.util.copyAttributes
|
||||
import org.jetbrains.kotlin.gradle.targets.metadata.isKotlinGranularMetadataEnabled
|
||||
import org.jetbrains.kotlin.gradle.targets.native.*
|
||||
import org.jetbrains.kotlin.gradle.targets.native.internal.*
|
||||
@@ -44,6 +43,7 @@ import org.jetbrains.kotlin.gradle.testing.internal.configureConventions
|
||||
import org.jetbrains.kotlin.gradle.testing.internal.kotlinTestRegistry
|
||||
import org.jetbrains.kotlin.gradle.testing.testTaskName
|
||||
import org.jetbrains.kotlin.gradle.utils.XcodeUtils
|
||||
import org.jetbrains.kotlin.gradle.utils.copyAttributes
|
||||
import org.jetbrains.kotlin.gradle.utils.named
|
||||
import org.jetbrains.kotlin.gradle.utils.newInstance
|
||||
import org.jetbrains.kotlin.konan.target.HostManager
|
||||
|
||||
+1
-1
@@ -18,9 +18,9 @@ import org.jetbrains.kotlin.gradle.plugin.launchInStage
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.Framework
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.util.copyAttributes
|
||||
import org.jetbrains.kotlin.gradle.tasks.FatFrameworkTask
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinNativeLink
|
||||
import org.jetbrains.kotlin.gradle.utils.copyAttributes
|
||||
import org.jetbrains.kotlin.gradle.utils.getOrCreate
|
||||
import org.jetbrains.kotlin.gradle.utils.lowerCamelCaseName
|
||||
import org.jetbrains.kotlin.gradle.utils.markConsumable
|
||||
|
||||
+1
-1
@@ -17,10 +17,10 @@ import org.jetbrains.kotlin.gradle.plugin.categoryByName
|
||||
import org.jetbrains.kotlin.gradle.plugin.internal.artifactTypeAttribute
|
||||
import org.jetbrains.kotlin.gradle.plugin.launchInStage
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.*
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.util.copyAttributes
|
||||
import org.jetbrains.kotlin.gradle.plugin.usesPlatformOf
|
||||
import org.jetbrains.kotlin.gradle.targets.native.internal.CInteropKlibLibraryElements.cinteropKlibLibraryElements
|
||||
import org.jetbrains.kotlin.gradle.tasks.CInteropProcess
|
||||
import org.jetbrains.kotlin.gradle.utils.copyAttributes
|
||||
import org.jetbrains.kotlin.gradle.utils.markResolvable
|
||||
|
||||
internal fun createCInteropApiElementsKlibArtifact(
|
||||
|
||||
+4
-1
@@ -9,9 +9,12 @@ import org.gradle.api.Project
|
||||
import org.gradle.api.artifacts.component.BuildIdentifier
|
||||
import org.gradle.api.artifacts.component.ComponentIdentifier
|
||||
import org.gradle.api.artifacts.result.ResolvedComponentResult
|
||||
import org.gradle.api.internal.project.ProjectInternal
|
||||
import org.gradle.internal.build.BuildState
|
||||
import org.jetbrains.kotlin.gradle.plugin.extraProperties
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.util.currentBuildId
|
||||
|
||||
internal fun Project.currentBuildId(): BuildIdentifier =
|
||||
(project as ProjectInternal).services.get(BuildState::class.java).buildIdentifier
|
||||
|
||||
internal val Project.currentBuild: CurrentBuildIdentifier
|
||||
get() = extraProperties.getOrPut("org.jetbrains.kotlin.gradle.utils.currentBuild") { CurrentBuildIdentifierImpl(this.currentBuildId()) }
|
||||
|
||||
+14
-1
@@ -19,4 +19,17 @@ internal fun AttributeContainer.toMap(): Map<Attribute<*>, Any?> {
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
internal fun copyAttributes(from: AttributeContainer, to: AttributeContainer, keys: Iterable<Attribute<*>> = from.keySet()) {
|
||||
// capture type argument T
|
||||
fun <T : Any> copyOneAttribute(from: AttributeContainer, to: AttributeContainer, key: Attribute<T>) {
|
||||
val value = checkNotNull(from.getAttribute(key))
|
||||
to.attribute(key, value)
|
||||
}
|
||||
for (key in keys) {
|
||||
copyOneAttribute(from, to, key)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+15
-32
@@ -1,57 +1,40 @@
|
||||
/*
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.gradle.plugin.mpp.pm20.util
|
||||
package org.jetbrains.kotlin.gradle.utils
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.artifacts.component.BuildIdentifier
|
||||
import org.gradle.api.internal.project.ProjectInternal
|
||||
import org.gradle.internal.build.BuildState
|
||||
import org.jetbrains.kotlin.gradle.InternalKotlinGradlePluginApi
|
||||
import org.jetbrains.kotlin.gradle.plugin.internal.BasePluginConfiguration
|
||||
import org.jetbrains.kotlin.gradle.plugin.variantImplementationFactory
|
||||
import org.jetbrains.kotlin.gradle.utils.buildPathCompat
|
||||
import org.jetbrains.kotlin.project.model.KpmModule
|
||||
import org.jetbrains.kotlin.project.model.KpmLocalModuleIdentifier
|
||||
|
||||
fun KpmModule.representsProject(project: Project): Boolean =
|
||||
moduleIdentifier.let {
|
||||
it is KpmLocalModuleIdentifier &&
|
||||
it.buildId == project.currentBuildId().buildPathCompat &&
|
||||
it.projectId == project.path
|
||||
}
|
||||
|
||||
@InternalKotlinGradlePluginApi
|
||||
fun Project.currentBuildId(): BuildIdentifier =
|
||||
(project as ProjectInternal).services.get(BuildState::class.java).buildIdentifier
|
||||
|
||||
|
||||
/**
|
||||
* The base name to use for archive files.
|
||||
*/
|
||||
val Project.archivesName
|
||||
internal val Project.archivesName
|
||||
get() = variantImplementationFactory<BasePluginConfiguration.BasePluginConfigurationVariantFactory>()
|
||||
.getInstance(this)
|
||||
.archivesName
|
||||
|
||||
/**
|
||||
* Returns the directory to generate TAR and ZIP archives into.
|
||||
*
|
||||
* @return The directory. Never returns null.
|
||||
*/
|
||||
val Project.distsDirectory
|
||||
get() = variantImplementationFactory<BasePluginConfiguration.BasePluginConfigurationVariantFactory>()
|
||||
.getInstance(this)
|
||||
.distsDirectory
|
||||
|
||||
/**
|
||||
* Returns the directory to generate JAR archives into.
|
||||
*
|
||||
* @return The directory. Never returns null.
|
||||
*/
|
||||
val Project.libsDirectory
|
||||
internal val Project.libsDirectory
|
||||
get() = variantImplementationFactory<BasePluginConfiguration.BasePluginConfigurationVariantFactory>()
|
||||
.getInstance(this)
|
||||
.libsDirectory
|
||||
|
||||
|
||||
/**
|
||||
* Returns the directory to generate TAR and ZIP archives into.
|
||||
*
|
||||
* @return The directory. Never returns null.
|
||||
*/
|
||||
internal val Project.distsDirectory
|
||||
get() = variantImplementationFactory<BasePluginConfiguration.BasePluginConfigurationVariantFactory>()
|
||||
.getInstance(this)
|
||||
.distsDirectory
|
||||
+1
-5
@@ -119,10 +119,6 @@ internal fun <T : Task> T.outputFilesProvider(provider: T.() -> Any): Configurab
|
||||
return project.filesProvider(this) { provider() }
|
||||
}
|
||||
|
||||
internal fun <T : Task> T.outputFilesProvider(lazy: Lazy<Any>): ConfigurableFileCollection {
|
||||
return project.filesProvider(this) { lazy.value }
|
||||
}
|
||||
|
||||
internal inline fun <reified T> Project.listProperty(noinline itemsProvider: () -> Iterable<T>): ListProperty<T> =
|
||||
objects.listProperty(T::class.java).apply { set(provider(itemsProvider)) }
|
||||
|
||||
@@ -165,4 +161,4 @@ private abstract class AdhocValueSource<T> : ValueSource<T, AdhocValueSource.Par
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return parameters.producingLambda.get().invoke() as T
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user