[Gradle] Implement ConfigureFrameworkExportSideEffect
KT-61634
This commit is contained in:
committed by
Space Team
parent
3aeca1956e
commit
8651d67aeb
+2
@@ -65,6 +65,7 @@ import org.jetbrains.kotlin.gradle.targets.KotlinTargetSideEffect
|
||||
import org.jetbrains.kotlin.gradle.targets.NativeForwardImplementationToApiElementsSideEffect
|
||||
import org.jetbrains.kotlin.gradle.targets.js.npm.AddNpmDependencyExtensionProjectSetupAction
|
||||
import org.jetbrains.kotlin.gradle.targets.metadata.KotlinMetadataTargetSetupAction
|
||||
import org.jetbrains.kotlin.gradle.targets.native.ConfigureFrameworkExportSideEffect
|
||||
import org.jetbrains.kotlin.gradle.targets.native.CreateFatFrameworksSetupAction
|
||||
import org.jetbrains.kotlin.gradle.targets.native.KotlinNativeConfigureBinariesSideEffect
|
||||
import org.jetbrains.kotlin.gradle.targets.native.internal.CInteropCommonizedCInteropApiElementsConfigurationsSetupAction
|
||||
@@ -115,6 +116,7 @@ internal fun Project.registerKotlinPluginExtensions() {
|
||||
register(project, ConfigureBuildSideEffect)
|
||||
register(project, KotlinNativeConfigureBinariesSideEffect)
|
||||
register(project, CreateDefaultTestRunSideEffect)
|
||||
register(project, ConfigureFrameworkExportSideEffect)
|
||||
}
|
||||
|
||||
KotlinCompilationSideEffect.extensionPoint.apply {
|
||||
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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.targets.native
|
||||
|
||||
import org.gradle.api.attributes.Category
|
||||
import org.gradle.api.attributes.Usage
|
||||
import org.jetbrains.kotlin.gradle.plugin.categoryByName
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.AbstractNativeLibrary
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinUsages
|
||||
import org.jetbrains.kotlin.gradle.plugin.usesPlatformOf
|
||||
import org.jetbrains.kotlin.gradle.targets.KotlinTargetSideEffect
|
||||
|
||||
internal val ConfigureFrameworkExportSideEffect = KotlinTargetSideEffect<KotlinNativeTarget> { target ->
|
||||
val project = target.project
|
||||
|
||||
target.compilations.all {
|
||||
// Allow resolving api configurations directly to be able to check that
|
||||
// all exported dependency are also added in the corresponding api configurations.
|
||||
// The check is performed during a link task execution.
|
||||
project.configurations.maybeCreate(it.apiConfigurationName).apply {
|
||||
isCanBeResolved = true
|
||||
usesPlatformOf(target)
|
||||
attributes.attribute(Usage.USAGE_ATTRIBUTE, KotlinUsages.consumerApiUsage(target))
|
||||
attributes.attribute(Category.CATEGORY_ATTRIBUTE, project.categoryByName(Category.LIBRARY))
|
||||
}
|
||||
}
|
||||
|
||||
target.binaries.withType(AbstractNativeLibrary::class.java).all { framework ->
|
||||
project.configurations.maybeCreate(framework.exportConfigurationName).apply {
|
||||
isVisible = false
|
||||
isTransitive = false
|
||||
isCanBeConsumed = false
|
||||
isCanBeResolved = true
|
||||
usesPlatformOf(target)
|
||||
attributes.attribute(Usage.USAGE_ATTRIBUTE, KotlinUsages.consumerApiUsage(target))
|
||||
attributes.attribute(Category.CATEGORY_ATTRIBUTE, project.categoryByName(Category.LIBRARY))
|
||||
description = "Dependenceis to be exported in framework ${framework.name} for target ${target.targetName}"
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
-37
@@ -9,17 +9,16 @@ package org.jetbrains.kotlin.gradle.plugin
|
||||
import org.gradle.api.NamedDomainObjectCollection
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.artifacts.Dependency
|
||||
import org.gradle.api.attributes.Category
|
||||
import org.gradle.api.attributes.Usage.USAGE_ATTRIBUTE
|
||||
import org.jetbrains.kotlin.gradle.artifacts.createKlibArtifact
|
||||
import org.jetbrains.kotlin.gradle.artifacts.klibOutputDirectory
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation.Companion.TEST_COMPILATION_NAME
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinPluginLifecycle.Stage.ReadyForExecution
|
||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.Companion.KOTLIN_NATIVE_IGNORE_INCORRECT_DEPENDENCIES
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.*
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.apple.registerEmbedAndSignAppleFrameworkTask
|
||||
import org.jetbrains.kotlin.gradle.artifacts.createKlibArtifact
|
||||
import org.jetbrains.kotlin.gradle.artifacts.klibOutputDirectory
|
||||
import org.jetbrains.kotlin.gradle.targets.native.internal.*
|
||||
import org.jetbrains.kotlin.gradle.tasks.*
|
||||
import org.jetbrains.kotlin.gradle.tasks.CInteropProcess
|
||||
import org.jetbrains.kotlin.gradle.tasks.registerTask
|
||||
import org.jetbrains.kotlin.gradle.utils.newInstance
|
||||
|
||||
open class KotlinNativeTargetConfigurator<T : KotlinNativeTarget> : AbstractKotlinTargetConfigurator<T>(
|
||||
@@ -96,7 +95,6 @@ open class KotlinNativeTargetConfigurator<T : KotlinNativeTarget> : AbstractKotl
|
||||
|
||||
// region Configuration.
|
||||
override fun configurePlatformSpecificModel(target: T) {
|
||||
configureFrameworkExport(target)
|
||||
configureCInterops(target)
|
||||
|
||||
if (target.konanTarget.family.isAppleFamily) {
|
||||
@@ -118,37 +116,6 @@ open class KotlinNativeTargetConfigurator<T : KotlinNativeTarget> : AbstractKotl
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
fun configureFrameworkExport(target: KotlinNativeTarget) {
|
||||
val project = target.project
|
||||
|
||||
target.compilations.all {
|
||||
// Allow resolving api configurations directly to be able to check that
|
||||
// all exported dependency are also added in the corresponding api configurations.
|
||||
// The check is performed during a link task execution.
|
||||
project.configurations.maybeCreate(it.apiConfigurationName).apply {
|
||||
isCanBeResolved = true
|
||||
usesPlatformOf(target)
|
||||
attributes.attribute(USAGE_ATTRIBUTE, KotlinUsages.consumerApiUsage(target))
|
||||
attributes.attribute(Category.CATEGORY_ATTRIBUTE, project.categoryByName(Category.LIBRARY))
|
||||
}
|
||||
}
|
||||
|
||||
target.binaries.withType(AbstractNativeLibrary::class.java).all { framework ->
|
||||
project.configurations.maybeCreate(framework.exportConfigurationName).apply {
|
||||
isVisible = false
|
||||
isTransitive = false
|
||||
isCanBeConsumed = false
|
||||
isCanBeResolved = true
|
||||
usesPlatformOf(target)
|
||||
attributes.attribute(USAGE_ATTRIBUTE, KotlinUsages.consumerApiUsage(target))
|
||||
attributes.attribute(Category.CATEGORY_ATTRIBUTE, project.categoryByName(Category.LIBRARY))
|
||||
description = "Dependenceis to be exported in framework ${framework.name} for target ${target.targetName}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun registerEmbedAndSignAppleFrameworkTasks(target: KotlinNativeTarget) {
|
||||
val project = target.project
|
||||
target.binaries.withType(Framework::class.java).all { framework ->
|
||||
|
||||
Reference in New Issue
Block a user