Skip to content

Commit

Permalink
[Gradle] Remove kotlin metadata compatibility flag
Browse files Browse the repository at this point in the history
^KT-61817
  • Loading branch information
antohaby authored and Space Team committed Feb 14, 2025
1 parent 61a93e6 commit c4a3d56
Show file tree
Hide file tree
Showing 15 changed files with 27 additions and 185 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ open class HierarchicalMppIT : KGPBaseTest() {
fun testPublishedModules(gradleVersion: GradleVersion, @TempDir tempDir: Path) {
val buildOptions = defaultBuildOptions.copy(logLevel = LogLevel.DEBUG)

publishThirdPartyLib(withGranularMetadata = true, gradleVersion = gradleVersion, localRepoDir = tempDir)
publishThirdPartyLib(gradleVersion = gradleVersion, localRepoDir = tempDir)

nativeProject(
"my-lib-foo".withPrefix,
Expand Down Expand Up @@ -85,7 +85,7 @@ open class HierarchicalMppIT : KGPBaseTest() {
@DisplayName("Check no sourceSets visible if no variant matched")
@BrokenOnMacosTest
fun testNoSourceSetsVisibleIfNoVariantMatched(gradleVersion: GradleVersion, @TempDir tempDir: Path) {
publishThirdPartyLib(withGranularMetadata = true, gradleVersion = gradleVersion, localRepoDir = tempDir)
publishThirdPartyLib(gradleVersion = gradleVersion, localRepoDir = tempDir)

nativeProject(
projectName = "my-lib-foo".withPrefix,
Expand Down Expand Up @@ -118,7 +118,7 @@ open class HierarchicalMppIT : KGPBaseTest() {
@DisplayName("Dependencies in tests should be correct with third-party library")
@BrokenOnMacosTest
fun testDependenciesInTests(gradleVersion: GradleVersion, @TempDir tempDir: Path) {
publishThirdPartyLib(withGranularMetadata = true, gradleVersion = gradleVersion, localRepoDir = tempDir) {
publishThirdPartyLib(gradleVersion = gradleVersion, localRepoDir = tempDir) {
kotlinSourcesDir("jvmMain").copyRecursively(kotlinSourcesDir("linuxX64Main"))
buildGradleKts.appendText("\nkotlin.linuxX64()")
}
Expand Down Expand Up @@ -207,7 +207,7 @@ open class HierarchicalMppIT : KGPBaseTest() {
@GradleTest
@DisplayName("Dependencies in project should be correct with third-party library")
fun testProjectDependencies(gradleVersion: GradleVersion, @TempDir tempDir: Path) {
publishThirdPartyLib(withGranularMetadata = true, gradleVersion = gradleVersion, localRepoDir = tempDir)
publishThirdPartyLib(gradleVersion = gradleVersion, localRepoDir = tempDir)

with(
nativeProject(
Expand All @@ -231,7 +231,7 @@ open class HierarchicalMppIT : KGPBaseTest() {
@BrokenOnMacosTest
fun testOnlyCompositeMetadataArtifactsTransformed(gradleVersion: GradleVersion, @TempDir tempDir: Path) {
val buildOptions = defaultBuildOptions.copy(logLevel = LogLevel.DEBUG)
publishThirdPartyLib(withGranularMetadata = true, gradleVersion = gradleVersion, localRepoDir = tempDir)
publishThirdPartyLib(gradleVersion = gradleVersion, localRepoDir = tempDir)

val regex = """artifact: '(.+)'""".toRegex()
fun BuildResult.transformedArtifacts() = output
Expand Down Expand Up @@ -267,7 +267,7 @@ open class HierarchicalMppIT : KGPBaseTest() {
build("publish") {
assertEquals(
setOf(
"my-lib-foo-metadata-1.0-all.jar",
"my-lib-foo-metadata-1.0.jar",
"third-party-lib-metadata-1.0.jar",
"kotlin-stdlib-${buildOptions.kotlinVersion}-all.jar",
),
Expand All @@ -285,8 +285,8 @@ open class HierarchicalMppIT : KGPBaseTest() {
testDependencyTransformations {
assertEquals(
setOf(
"my-lib-foo-metadata-1.0-all.jar",
"my-lib-bar-metadata-1.0-all.jar",
"my-lib-foo-metadata-1.0.jar",
"my-lib-bar-metadata-1.0.jar",
"third-party-lib-metadata-1.0.jar",
"kotlin-stdlib-${buildOptions.kotlinVersion}-all.jar",
"kotlin-test-${buildOptions.kotlinVersion}-all.jar",
Expand All @@ -303,7 +303,6 @@ open class HierarchicalMppIT : KGPBaseTest() {
@Suppress("DEPRECATION")
publishThirdPartyLib(
projectName = "hierarchical-mpp-with-js-published-modules/third-party-lib",
withGranularMetadata = true,
gradleVersion = gradleVersion,
localRepoDir = tempDir
)
Expand Down Expand Up @@ -412,7 +411,6 @@ open class HierarchicalMppIT : KGPBaseTest() {

private fun publishThirdPartyLib(
projectName: String = "third-party-lib".withPrefix,
withGranularMetadata: Boolean,
gradleVersion: GradleVersion,
localRepoDir: Path,
beforePublishing: TestProject.() -> Unit = { },
Expand All @@ -424,12 +422,6 @@ open class HierarchicalMppIT : KGPBaseTest() {
buildOptions = defaultBuildOptions.copy(jsOptions = BuildOptions.JsOptions())
).apply {
beforePublishing()

if (!withGranularMetadata) {
val gradleProperties = projectPath.toFile().resolve("gradle.properties")
gradleProperties.appendText("kotlin.internal.mpp.hierarchicalStructureByDefault=false${System.lineSeparator()}")
gradleProperties.appendText("kotlin.internal.suppressGradlePluginErrors=PreHMPPFlagsError${System.lineSeparator()}")
}
build("publish")
}

Expand All @@ -438,7 +430,7 @@ open class HierarchicalMppIT : KGPBaseTest() {

ZipFile(
localRepoDir.toFile().resolve(
"com/example/foo/my-lib-foo/1.0/my-lib-foo-1.0-all.jar"
"com/example/foo/my-lib-foo/1.0/my-lib-foo-1.0.jar"
)
).use { publishedMetadataJar ->
publishedMetadataJar.checkAllEntryNamesArePresent(
Expand Down Expand Up @@ -493,7 +485,7 @@ open class HierarchicalMppIT : KGPBaseTest() {

ZipFile(
localRepoDir.toFile().resolve(
"com/example/bar/my-lib-bar/1.0/my-lib-bar-1.0-all.jar"
"com/example/bar/my-lib-bar/1.0/my-lib-bar-1.0.jar"
)
).use { publishedMetadataJar ->
publishedMetadataJar.checkAllEntryNamesArePresent(
Expand Down Expand Up @@ -550,7 +542,7 @@ open class HierarchicalMppIT : KGPBaseTest() {
}

checkNamesOnCompileClasspath(
"$taskPrefix:compileKotlinMetadata",
"$taskPrefix:compileCommonMainKotlinMetadata",
shouldInclude = listOf(
"my-lib-foo" to "main"
),
Expand Down Expand Up @@ -591,7 +583,7 @@ open class HierarchicalMppIT : KGPBaseTest() {
assertTasksExecuted(expectedTasks(subprojectPrefix))

checkNamesOnCompileClasspath(
"$taskPrefix:compileKotlinMetadata",
"$taskPrefix:compileCommonMainKotlinMetadata",
shouldInclude = listOf(
"my-lib-bar" to "main",
"my-lib-foo" to "main"
Expand Down Expand Up @@ -746,7 +738,7 @@ open class HierarchicalMppIT : KGPBaseTest() {
@DisplayName("Compile only dependency processing for metadata compilations")
fun testCompileOnlyDependencyProcessingForMetadataCompilations(gradleVersion: GradleVersion, @TempDir tempDir: Path) =
with(nativeProject("hierarchical-mpp-project-dependency", gradleVersion, localRepoDir = tempDir)) {
publishThirdPartyLib(withGranularMetadata = true, gradleVersion = gradleVersion, localRepoDir = tempDir)
publishThirdPartyLib(gradleVersion = gradleVersion, localRepoDir = tempDir)

subProject("my-lib-foo").buildGradleKts
.appendText("\ndependencies { \"jvmAndJsMainCompileOnly\"(kotlin(\"test\")) }")
Expand All @@ -769,7 +761,6 @@ open class HierarchicalMppIT : KGPBaseTest() {
fun testHmppDependenciesInJsTests(gradleVersion: GradleVersion, @TempDir tempDir: Path) {

publishThirdPartyLib(
withGranularMetadata = true,
gradleVersion = gradleVersion,
localRepoDir = tempDir
)
Expand All @@ -788,7 +779,7 @@ open class HierarchicalMppIT : KGPBaseTest() {
@GradleTest
@DisplayName("Processing dependency declared in non root sourceSet")
fun testProcessingDependencyDeclaredInNonRootSourceSet(gradleVersion: GradleVersion, @TempDir tempDir: Path) {
publishThirdPartyLib(withGranularMetadata = true, gradleVersion = gradleVersion, localRepoDir = tempDir)
publishThirdPartyLib(gradleVersion = gradleVersion, localRepoDir = tempDir)

nativeProject(
"my-lib-foo".withPrefix,
Expand All @@ -813,7 +804,7 @@ open class HierarchicalMppIT : KGPBaseTest() {
@DisplayName("Check dependencies in non published sourceSets")
@BrokenOnMacosTest
fun testDependenciesInNonPublishedSourceSets(gradleVersion: GradleVersion, @TempDir tempDir: Path) {
publishThirdPartyLib(withGranularMetadata = true, gradleVersion = gradleVersion, localRepoDir = tempDir)
publishThirdPartyLib(gradleVersion = gradleVersion, localRepoDir = tempDir)

nativeProject(
"my-lib-foo".withPrefix,
Expand Down Expand Up @@ -1043,7 +1034,7 @@ open class HierarchicalMppIT : KGPBaseTest() {
@DisplayName("KT-44845: all external dependencies is unresolved in IDE with kotlin.mpp.enableGranularSourceSetsMetadata=true")
@BrokenOnMacosTest
fun testMixedScopesFilesExistKt44845(gradleVersion: GradleVersion, @TempDir tempDir: Path) {
publishThirdPartyLib(withGranularMetadata = true, gradleVersion = gradleVersion, localRepoDir = tempDir)
publishThirdPartyLib(gradleVersion = gradleVersion, localRepoDir = tempDir)

nativeProject(
"my-lib-foo".withPrefix,
Expand Down Expand Up @@ -1310,10 +1301,10 @@ open class HierarchicalMppIT : KGPBaseTest() {
@DisplayName("KT-65954 Metadata Compilation should not fail when test source set has higher version of a library")
fun kt65954MetadataCompilationShouldNotFail(gradleVersion: GradleVersion, @TempDir tempDir: Path) {
// publish version 1.0
publishThirdPartyLib(withGranularMetadata = true, gradleVersion = gradleVersion, localRepoDir = tempDir)
publishThirdPartyLib(gradleVersion = gradleVersion, localRepoDir = tempDir)

// publish version 2.0
publishThirdPartyLib(withGranularMetadata = true, gradleVersion = gradleVersion, localRepoDir = tempDir) {
publishThirdPartyLib(gradleVersion = gradleVersion, localRepoDir = tempDir) {
buildGradleKts.appendText("\nversion = \"2.0\"\n")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ class MppDiagnosticsIt : KGPBaseTest() {
private val deprecatedFlags: Map<String, String>
get() = mapOf(
"kotlin.mpp.enableGranularSourceSetsMetadata" to "true",
"kotlin.mpp.enableCompatibilityMetadataVariant" to "false",
"kotlin.internal.mpp.hierarchicalStructureByDefault" to "true",
"kotlin.mpp.hierarchicalStructureSupport" to "true",
"kotlin.native.enableDependencyPropagation" to "false",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
> Configure project :subprojectA
e: [PreHMPPFlagsError | ERROR] Deprecated Kotlin Multiplatform Properties
The following properties are obsolete and no longer supported:
kotlin.mpp.enableCompatibilityMetadataVariant, kotlin.mpp.hierarchicalStructureSupport
kotlin.mpp.hierarchicalStructureSupport
Please remove the deprecated properties from the project.
Read the details here: https://kotlinlang.org/docs/multiplatform-compatibility-guide.html#deprecate-hmpp-properties
#diagnostic-end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# Check that warnings from root project are reported
kotlin.mpp.enableCompatibilityMetadataVariant=true

# Check that warnings from root project are deduplicated with warnings from subprojects
# (using small trick -- 'true' state is default but still provokes warnings)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
kotlin.mpp.enableCompatibilityMetadataVariant=true
kotlin.internal.suppressGradlePluginErrors=PreHMPPFlagsError
kotlin.internal.suppressGradlePluginErrors=PreHMPPFlagsError

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import org.gradle.api.attributes.Usage
import org.jetbrains.kotlin.gradle.plugin.categoryByName
import org.jetbrains.kotlin.gradle.plugin.mpp.*
import org.jetbrains.kotlin.gradle.plugin.usageByName
import org.jetbrains.kotlin.gradle.targets.metadata.isCompatibilityMetadataVariantEnabled
import org.jetbrains.kotlin.gradle.targets.metadata.isKotlinGranularMetadataEnabled
import org.jetbrains.kotlin.gradle.targets.metadata.locateOrRegisterGenerateProjectStructureMetadataTask
import org.jetbrains.kotlin.gradle.targets.native.internal.includeCommonizedCInteropMetadata
Expand All @@ -25,9 +24,6 @@ internal val KotlinMetadataArtifact = KotlinTargetArtifact { target, apiElements

val metadataJarTask = target.createArtifactsTask { jar ->
jar.description = "Assembles a jar archive containing the metadata for all Kotlin source sets."
if (target.project.isCompatibilityMetadataVariantEnabled) {
jar.archiveClassifier.set("all")
}
}

/* Include 'KotlinProjectStructureMetadata' file */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames.KOTLI
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames.KOTLIN_MPP_ANDROID_SOURCE_SET_LAYOUT_VERSION
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames.KOTLIN_MPP_APPLY_DEFAULT_HIERARCHY_TEMPLATE
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames.KOTLIN_MPP_ENABLE_CINTEROP_COMMONIZATION
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames.KOTLIN_MPP_ENABLE_COMPATIBILITY_METADATA_VARIANT
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_ENABLE_INTRANSITIVE_METADATA_CONFIGURATION
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames.KOTLIN_MPP_ENABLE_OPTIMISTIC_NUMBER_COMMONIZATION
Expand Down Expand Up @@ -193,10 +192,6 @@ internal class PropertiesProvider private constructor(private val project: Proje
val mppHierarchicalStructureByDefault: Boolean
get() = booleanProperty(KOTLIN_MPP_HIERARCHICAL_STRUCTURE_BY_DEFAULT) ?: true

val enableCompatibilityMetadataVariant: Boolean
get() {
return (booleanProperty(KOTLIN_MPP_ENABLE_COMPATIBILITY_METADATA_VARIANT) ?: !mppHierarchicalStructureByDefault)
}

val enableKotlinToolingMetadataArtifact: Boolean
get() = booleanProperty("kotlin.mpp.enableKotlinToolingMetadataArtifact") ?: true
Expand Down Expand Up @@ -694,7 +689,6 @@ internal class PropertiesProvider private constructor(private val project: Proje
val KOTLIN_JS_STDLIB_DOM_API_INCLUDED = property("kotlin.js.stdlib.dom.api.included")
val KOTLIN_JS_YARN = property("kotlin.js.yarn")
val KOTLIN_MPP_ENABLE_GRANULAR_SOURCE_SETS_METADATA = property("kotlin.mpp.enableGranularSourceSetsMetadata")
val KOTLIN_MPP_ENABLE_COMPATIBILITY_METADATA_VARIANT = property("kotlin.mpp.enableCompatibilityMetadataVariant")
val KOTLIN_MPP_ENABLE_CINTEROP_COMMONIZATION = property("kotlin.mpp.enableCInteropCommonization")
val KOTLIN_MPP_HIERARCHICAL_STRUCTURE_SUPPORT = property("kotlin.mpp.hierarchicalStructureSupport")
val KOTLIN_MPP_ANDROID_SOURCE_SET_LAYOUT_VERSION = property("kotlin.mpp.androidSourceSetLayoutVersion")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ abstract class KotlinSoftwareComponent(
mutableSetOf<DefaultKotlinUsageContext>().apply {
val allMetadataJar = project.tasks.named(KotlinMetadataTargetConfigurator.ALL_METADATA_JAR_NAME)
val allMetadataArtifact = project.artifacts.add(Dependency.ARCHIVES_CONFIGURATION, allMetadataJar) { allMetadataArtifact ->
allMetadataArtifact.classifier = if (project.isCompatibilityMetadataVariantEnabled) "all" else ""
allMetadataArtifact.classifier = ""
}

this += DefaultKotlinUsageContext(
Expand All @@ -85,18 +85,6 @@ abstract class KotlinSoftwareComponent(
overrideConfigurationArtifacts = project.setProperty { listOf(allMetadataArtifact) }
)

if (project.isCompatibilityMetadataVariantEnabled) {
// Ensure that consumers who expect Kotlin 1.2.x metadata package can still get one:
// publish the old metadata artifact:
this += run {
DefaultKotlinUsageContext(
metadataTarget.compilations.getByName(MAIN_COMPILATION_NAME),
KotlinUsageContext.MavenScope.COMPILE,
/** this configuration is created by [KotlinMetadataTargetConfigurator.createCommonMainElementsConfiguration] */
COMMON_MAIN_ELEMENTS_CONFIGURATION_NAME
)
}
}

val sourcesElements = metadataTarget.sourcesElementsConfigurationName
if (metadataTarget.isSourcesPublishable) {
Expand Down
Loading

0 comments on commit c4a3d56

Please sign in to comment.