Skip to content

Commit 1b0ab7d

Browse files
antohabySpace Team
authored and
Space Team
committed
[Gradle] Add archivesTaskOutputAsFriendModule flag
This flag should disable redundant logic in Friends Artifacts Reolver that adds Kotlin Target's archive file as a friend path to associated compialtions. It should be enough to just use compiler outputs. But this change requires proper migration. Enable this flag for kotlin-stdlib as it's associated compilations contribute to archives task. This should break cyclic dependency. ^KT-58280
1 parent ae44265 commit 1b0ab7d

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

libraries/stdlib/gradle.properties

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
kotlin.internal.suppressGradlePluginErrors=PreHMPPFlagsError
22
kotlin.mpp.enableCompatibilityMetadataVariant=true
3-
kotlin.internal.mpp.createDefaultMultiplatformPublications=false
3+
kotlin.internal.mpp.createDefaultMultiplatformPublications=false
4+
kotlin.internal.archivesTaskOutputAsFriendModule=false

libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/PropertiesProvider.kt

+4
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,9 @@ internal class PropertiesProvider private constructor(private val project: Proje
601601
val enableFusMetricsCollection: Boolean
602602
get() = booleanProperty(PropertyNames.KOTLIN_COLLECT_FUS_METRICS_ENABLED) ?: true
603603

604+
val archivesTaskOutputAsFriendModule: Boolean
605+
get() = booleanProperty(PropertyNames.KOTLIN_ARCHIVES_TASK_OUTPUT_AS_FRIEND_ENABLED) ?: true
606+
604607
/**
605608
* Retrieves a comma-separated list of browsers to use when running karma tests for [target]
606609
* @see KOTLIN_JS_KARMA_BROWSERS
@@ -725,6 +728,7 @@ internal class PropertiesProvider private constructor(private val project: Proje
725728
property("$KOTLIN_INTERNAL_NAMESPACE.incremental.enableUnsafeOptimizationsForMultiplatform")
726729
val KOTLIN_KLIBS_KT64115_WORKAROUND_ENABLED = property("$KOTLIN_INTERNAL_NAMESPACE.klibs.enableWorkaroundForKT64115")
727730
val KOTLIN_COLLECT_FUS_METRICS_ENABLED = property("$KOTLIN_INTERNAL_NAMESPACE.collectFUSMetrics")
731+
val KOTLIN_ARCHIVES_TASK_OUTPUT_AS_FRIEND_ENABLED = property("$KOTLIN_INTERNAL_NAMESPACE.archivesTaskOutputAsFriendModule")
728732
}
729733

730734
companion object {

libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/compilationImpl/KotlinCompilationFriendPathsResolver.kt

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.gradle.plugin.mpp.compilationImpl
88
import org.gradle.api.file.FileCollection
99
import org.gradle.api.tasks.TaskProvider
1010
import org.gradle.api.tasks.bundling.AbstractArchiveTask
11+
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.Companion.kotlinPropertiesProvider
1112
import org.jetbrains.kotlin.gradle.plugin.mpp.*
1213
import org.jetbrains.kotlin.gradle.plugin.sources.getVisibleSourceSetsFromAssociateCompilations
1314
import org.jetbrains.kotlin.gradle.tasks.KotlinCompileTool
@@ -61,6 +62,8 @@ internal class DefaultKotlinCompilationFriendPathsResolver(
6162

6263
object DefaultFriendArtifactResolver : FriendArtifactResolver {
6364
override fun resolveFriendArtifacts(compilation: InternalKotlinCompilation<*>): FileCollection {
65+
if (!compilation.project.kotlinPropertiesProvider.archivesTaskOutputAsFriendModule) return compilation.project.files()
66+
6467
return with(compilation.project) {
6568
val friendArtifactsTaskProvider = resolveFriendArtifactsTask(compilation) ?: return files()
6669
filesProvider { friendArtifactsTaskProvider.flatMap { it.archiveFile } }

0 commit comments

Comments
 (0)