Remove dependency order workaround for kotlinx-serialization plugin
Current workaround is not working with platform (bom) and since 1.8.0 release kotlinx-serialization was migrated to IR which removed need for workaround. ^KT-54691 In Progress
This commit is contained in:
committed by
Space Team
parent
b9aac83135
commit
8ec90e2bf2
-30
@@ -196,36 +196,6 @@ class SubpuginsIT : KGPBaseTest() {
|
||||
}
|
||||
}
|
||||
|
||||
@DisplayName("KT-47921: serialization plugin passed first to the compiler")
|
||||
@GradleTest
|
||||
fun testSerializationPluginOrderedFirst(gradleVersion: GradleVersion) {
|
||||
project("allOpenSimple", gradleVersion) {
|
||||
// Ensure that there are also allopen, noarg, and serialization plugins applied:
|
||||
buildGradle.modify {
|
||||
"""
|
||||
|plugins {
|
||||
| id "org.jetbrains.kotlin.plugin.noarg"
|
||||
| id "org.jetbrains.kotlin.plugin.serialization"
|
||||
|${it.substringAfter("plugins {")}
|
||||
""".trimMargin()
|
||||
}
|
||||
|
||||
build(
|
||||
"compileKotlin",
|
||||
buildOptions = defaultBuildOptions.copy(logLevel = LogLevel.DEBUG)
|
||||
) {
|
||||
val xPlugin = output
|
||||
.split(" ")
|
||||
.single { it.startsWith("-Xplugin") }
|
||||
.substringAfter("-Xplugin")
|
||||
.split(",")
|
||||
assertTrue(xPlugin.first().contains("serialization")) {
|
||||
"Expected serialization plugin to go first; actual order: $xPlugin"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@DisplayName("KT-51378: Using 'kotlin-dsl' with latest plugin version in buildSrc module")
|
||||
@GradleTestVersions(
|
||||
minVersion = TestVersions.Gradle.G_6_8 // Gradle usage of sam-with-receivers subplugin was added in this version
|
||||
|
||||
-35
@@ -1,35 +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.internal
|
||||
|
||||
import org.gradle.api.artifacts.Configuration
|
||||
import org.gradle.api.artifacts.Dependency
|
||||
import org.gradle.api.artifacts.ModuleDependency
|
||||
|
||||
/**
|
||||
* Reorder the compiler plugin dependencies in this [Configuration] so that dependencies on the
|
||||
* modules under [prioritizedPluginArtifactCoordinates] appear first.
|
||||
*
|
||||
* In particular, the serialization plugin needs to appear first on the -Xplugin classpath in order to avoid conflicts with other compiler
|
||||
* plugins producing unexpected IR.
|
||||
*
|
||||
* KT-47921
|
||||
*/
|
||||
internal fun Configuration.reorderPluginClasspathDependencies() {
|
||||
withDependencies { dependencySet ->
|
||||
val orderedDependencies = dependencySet.toList().partition(Dependency::isPrioritized).toList().flatten()
|
||||
dependencySet.clear()
|
||||
dependencySet.addAll(orderedDependencies)
|
||||
}
|
||||
}
|
||||
|
||||
private val Dependency.isPrioritized: Boolean
|
||||
get() = this is ModuleDependency && (group to name) in prioritizedPluginArtifactCoordinates
|
||||
|
||||
private val prioritizedPluginArtifactCoordinates = setOf(
|
||||
"org.jetbrains.kotlin" to "kotlin-serialization",
|
||||
"org.jetbrains.kotlin" to "kotlin-serialization-unshaded"
|
||||
)
|
||||
-2
@@ -7,7 +7,6 @@ package org.jetbrains.kotlin.gradle.plugin.mpp.compilationImpl.factory
|
||||
|
||||
import org.gradle.api.attributes.Category
|
||||
import org.gradle.api.attributes.Usage
|
||||
import org.jetbrains.kotlin.gradle.internal.reorderPluginClasspathDependencies
|
||||
import org.jetbrains.kotlin.gradle.plugin.*
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinUsages
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinWithJavaTarget
|
||||
@@ -227,7 +226,6 @@ private fun KotlinCompilationDependencyConfigurationsContainer(
|
||||
isVisible = false
|
||||
isCanBeConsumed = false
|
||||
description = "Kotlin compiler plugins for $compilation"
|
||||
reorderPluginClasspathDependencies()
|
||||
}
|
||||
|
||||
return DefaultKotlinCompilationConfigurationsContainer(
|
||||
|
||||
-2
@@ -7,7 +7,6 @@ package org.jetbrains.kotlin.gradle.plugin.mpp.pm20
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.provider.Provider
|
||||
import org.jetbrains.kotlin.gradle.internal.reorderPluginClasspathDependencies
|
||||
import org.jetbrains.kotlin.gradle.plugin.FilesSubpluginOption
|
||||
import org.jetbrains.kotlin.gradle.plugin.SubpluginOption
|
||||
import org.jetbrains.kotlin.gradle.tasks.CompilerPluginOptions
|
||||
@@ -94,7 +93,6 @@ private class CompilerPluginOptionsBuilder(
|
||||
isCanBeConsumed = false
|
||||
isCanBeResolved = true
|
||||
isVisible = false
|
||||
reorderPluginClasspathDependencies()
|
||||
addGradlePluginMetadataAttributes(project)
|
||||
}
|
||||
artifacts.forEach { project.dependencies.add(configurationName, it) }
|
||||
|
||||
Reference in New Issue
Block a user