[MPP] Only enable cinterop metadata transformation when cinterop commonization is enabled
Both library author and consumer need to enable cinterop commonization in order to support libraries with commonized cinterops in their API surface.
This commit is contained in:
committed by
Space
parent
4d5446a174
commit
2e1fc15a9a
+3
-1
@@ -13,6 +13,7 @@ import org.jetbrains.kotlin.gradle.dsl.NativeCacheKind
|
||||
import org.jetbrains.kotlin.gradle.internal.testing.TCServiceMessageOutputStreamHandler.Companion.IGNORE_TCSM_OVERFLOW
|
||||
import org.jetbrains.kotlin.gradle.plugin.Kotlin2JsPlugin.Companion.NOWARN_2JS_FLAG
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType.Companion.jsCompilerProperty
|
||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames.KOTLIN_MPP_ENABLE_CINTEROP_COMMONIZATION
|
||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames.KOTLIN_MPP_ENABLE_GRANULAR_SOURCE_SETS_METADATA
|
||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames.KOTLIN_MPP_HIERARCHICAL_STRUCTURE_BY_DEFAULT
|
||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames.KOTLIN_MPP_HIERARCHICAL_STRUCTURE_SUPPORT
|
||||
@@ -284,7 +285,7 @@ internal class PropertiesProvider private constructor(private val project: Proje
|
||||
* Enables experimental commonization of user defined c-interop libraries.
|
||||
*/
|
||||
val enableCInteropCommonization: Boolean
|
||||
get() = booleanProperty("kotlin.mpp.enableCInteropCommonization") ?: false
|
||||
get() = booleanProperty(KOTLIN_MPP_ENABLE_CINTEROP_COMMONIZATION) ?: false
|
||||
|
||||
|
||||
val commonizerLogLevel: String?
|
||||
@@ -429,6 +430,7 @@ internal class PropertiesProvider private constructor(private val project: Proje
|
||||
|
||||
object PropertyNames {
|
||||
const val KOTLIN_MPP_ENABLE_GRANULAR_SOURCE_SETS_METADATA = "kotlin.mpp.enableGranularSourceSetsMetadata"
|
||||
const val KOTLIN_MPP_ENABLE_CINTEROP_COMMONIZATION = "kotlin.mpp.enableCInteropCommonization"
|
||||
const val KOTLIN_MPP_HIERARCHICAL_STRUCTURE_BY_DEFAULT = "kotlin.internal.mpp.hierarchicalStructureByDefault"
|
||||
const val KOTLIN_MPP_HIERARCHICAL_STRUCTURE_SUPPORT = "kotlin.mpp.hierarchicalStructureSupport"
|
||||
const val KOTLIN_NATIVE_DEPENDENCY_PROPAGATION = "kotlin.native.enableDependencyPropagation"
|
||||
|
||||
+2
-1
@@ -31,6 +31,7 @@ internal fun Project.createCInteropMetadataDependencyClasspathForIde(sourceSet:
|
||||
internal fun Project.createCInteropMetadataDependencyClasspath(sourceSet: DefaultKotlinSourceSet, forIde: Boolean): FileCollection {
|
||||
val dependencyTransformationTask = if (forIde) locateOrRegisterCInteropMetadataDependencyTransformationTaskForIde(sourceSet)
|
||||
else locateOrRegisterCInteropMetadataDependencyTransformationTask(sourceSet)
|
||||
if (dependencyTransformationTask == null) return project.files()
|
||||
|
||||
/*
|
||||
The classpath will be assembled by three independent parts
|
||||
@@ -98,4 +99,4 @@ internal val ChooseVisibleSourceSets.visibleSourceSetsProvidingCInterops: Set<St
|
||||
.toSet()
|
||||
|
||||
return allVisibleSourceSetNames.filter { it !in dependsOnSourceSets }.toSet()
|
||||
}
|
||||
}
|
||||
|
||||
+7
-2
@@ -12,6 +12,7 @@ import org.gradle.api.artifacts.component.ProjectComponentIdentifier
|
||||
import org.gradle.api.file.FileCollection
|
||||
import org.gradle.api.tasks.*
|
||||
import org.jetbrains.kotlin.commonizer.SharedCommonizerTarget
|
||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.Companion.kotlinPropertiesProvider
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.MetadataDependencyResolution.ChooseVisibleSourceSets
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.MetadataDependencyResolution.ChooseVisibleSourceSets.MetadataProvider.JarMetadataProvider
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.MetadataDependencyResolution.ChooseVisibleSourceSets.MetadataProvider.ProjectMetadataProvider
|
||||
@@ -31,7 +32,9 @@ import javax.inject.Inject
|
||||
|
||||
internal fun Project.locateOrRegisterCInteropMetadataDependencyTransformationTask(
|
||||
sourceSet: DefaultKotlinSourceSet,
|
||||
): TaskProvider<CInteropMetadataDependencyTransformationTask> {
|
||||
): TaskProvider<CInteropMetadataDependencyTransformationTask>? {
|
||||
if (!kotlinPropertiesProvider.enableCInteropCommonization) return null
|
||||
|
||||
return locateOrRegisterTask(
|
||||
lowerCamelCaseName("transform", sourceSet.name, "CInteropDependenciesMetadata"),
|
||||
args = listOf(
|
||||
@@ -45,7 +48,9 @@ internal fun Project.locateOrRegisterCInteropMetadataDependencyTransformationTas
|
||||
|
||||
internal fun Project.locateOrRegisterCInteropMetadataDependencyTransformationTaskForIde(
|
||||
sourceSet: DefaultKotlinSourceSet,
|
||||
): TaskProvider<CInteropMetadataDependencyTransformationTask> {
|
||||
): TaskProvider<CInteropMetadataDependencyTransformationTask>? {
|
||||
if (!kotlinPropertiesProvider.enableCInteropCommonization) return null
|
||||
|
||||
return locateOrRegisterTask(
|
||||
lowerCamelCaseName("transform", sourceSet.name, "CInteropDependenciesMetadataForIde"),
|
||||
invokeWhenRegistered = { commonizeTask.dependsOn(this) },
|
||||
|
||||
Reference in New Issue
Block a user