Skip to content

Commit

Permalink
[Gradle] Add archivesTaskOutputAsFriendModule flag
Browse files Browse the repository at this point in the history
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
  • Loading branch information
antohaby authored and qodana-bot committed Jul 8, 2024
1 parent ae44265 commit 1b0ab7d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion libraries/stdlib/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
kotlin.internal.suppressGradlePluginErrors=PreHMPPFlagsError
kotlin.mpp.enableCompatibilityMetadataVariant=true
kotlin.internal.mpp.createDefaultMultiplatformPublications=false
kotlin.internal.mpp.createDefaultMultiplatformPublications=false
kotlin.internal.archivesTaskOutputAsFriendModule=false
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,9 @@ internal class PropertiesProvider private constructor(private val project: Proje
val enableFusMetricsCollection: Boolean
get() = booleanProperty(PropertyNames.KOTLIN_COLLECT_FUS_METRICS_ENABLED) ?: true

val archivesTaskOutputAsFriendModule: Boolean
get() = booleanProperty(PropertyNames.KOTLIN_ARCHIVES_TASK_OUTPUT_AS_FRIEND_ENABLED) ?: true

/**
* Retrieves a comma-separated list of browsers to use when running karma tests for [target]
* @see KOTLIN_JS_KARMA_BROWSERS
Expand Down Expand Up @@ -725,6 +728,7 @@ internal class PropertiesProvider private constructor(private val project: Proje
property("$KOTLIN_INTERNAL_NAMESPACE.incremental.enableUnsafeOptimizationsForMultiplatform")
val KOTLIN_KLIBS_KT64115_WORKAROUND_ENABLED = property("$KOTLIN_INTERNAL_NAMESPACE.klibs.enableWorkaroundForKT64115")
val KOTLIN_COLLECT_FUS_METRICS_ENABLED = property("$KOTLIN_INTERNAL_NAMESPACE.collectFUSMetrics")
val KOTLIN_ARCHIVES_TASK_OUTPUT_AS_FRIEND_ENABLED = property("$KOTLIN_INTERNAL_NAMESPACE.archivesTaskOutputAsFriendModule")
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package org.jetbrains.kotlin.gradle.plugin.mpp.compilationImpl
import org.gradle.api.file.FileCollection
import org.gradle.api.tasks.TaskProvider
import org.gradle.api.tasks.bundling.AbstractArchiveTask
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.Companion.kotlinPropertiesProvider
import org.jetbrains.kotlin.gradle.plugin.mpp.*
import org.jetbrains.kotlin.gradle.plugin.sources.getVisibleSourceSetsFromAssociateCompilations
import org.jetbrains.kotlin.gradle.tasks.KotlinCompileTool
Expand Down Expand Up @@ -61,6 +62,8 @@ internal class DefaultKotlinCompilationFriendPathsResolver(

object DefaultFriendArtifactResolver : FriendArtifactResolver {
override fun resolveFriendArtifacts(compilation: InternalKotlinCompilation<*>): FileCollection {
if (!compilation.project.kotlinPropertiesProvider.archivesTaskOutputAsFriendModule) return compilation.project.files()

return with(compilation.project) {
val friendArtifactsTaskProvider = resolveFriendArtifactsTask(compilation) ?: return files()
filesProvider { friendArtifactsTaskProvider.flatMap { it.archiveFile } }
Expand Down

0 comments on commit 1b0ab7d

Please sign in to comment.