[mpp] Minor: drop obsolete reporting of HMPP flags
Now any usages of HMPP-flags are deprecated and reported in deprecationDiagnostics.kt, which can sometimes lead to duplicated reports
This commit is contained in:
committed by
Space Team
parent
31eb012b6b
commit
e22a9b7108
-142
@@ -1,142 +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
|
|
||||||
|
|
||||||
import org.jetbrains.kotlin.gradle.util.modify
|
|
||||||
import org.junit.Test
|
|
||||||
import org.junit.runner.RunWith
|
|
||||||
import org.junit.runners.Parameterized
|
|
||||||
|
|
||||||
@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN")
|
|
||||||
@RunWith(Parameterized::class)
|
|
||||||
internal class MppFlagsMigrationIT : BaseGradleIT() {
|
|
||||||
internal data class TestCase(
|
|
||||||
var hierarchiesByDefault: Boolean? = null,
|
|
||||||
var hierarchiesSupportFlag: Boolean? = null,
|
|
||||||
var granularMetadataFlag: Boolean? = null,
|
|
||||||
var dependencyPropagationFlag: Boolean? = null,
|
|
||||||
var expectedToPass: Boolean = true,
|
|
||||||
var expectedPhraseInOutput: String? = null,
|
|
||||||
var notExpectedPhraseInOutput: String? = null,
|
|
||||||
) {
|
|
||||||
constructor(configure: TestCase.() -> Unit) : this() {
|
|
||||||
configure()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Parameterized.Parameter(0)
|
|
||||||
lateinit var testCase: TestCase
|
|
||||||
|
|
||||||
@Parameterized.Parameter(1)
|
|
||||||
lateinit var testProjectName: String
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
@OptIn(ExperimentalStdlibApi::class)
|
|
||||||
private val testCases = buildList {
|
|
||||||
add(TestCase {
|
|
||||||
granularMetadataFlag = null
|
|
||||||
dependencyPropagationFlag = null
|
|
||||||
expectedToPass = true
|
|
||||||
notExpectedPhraseInOutput = "It is safe to remove the property."
|
|
||||||
})
|
|
||||||
add(TestCase {
|
|
||||||
granularMetadataFlag = true
|
|
||||||
expectedToPass = true
|
|
||||||
expectedPhraseInOutput = "It is safe to remove the property."
|
|
||||||
})
|
|
||||||
add(TestCase {
|
|
||||||
granularMetadataFlag = false
|
|
||||||
expectedToPass = false
|
|
||||||
expectedPhraseInOutput = "Multiplatform Hierarchical Structures support is now enabled by default"
|
|
||||||
})
|
|
||||||
add(TestCase {
|
|
||||||
dependencyPropagationFlag = false
|
|
||||||
expectedToPass = true
|
|
||||||
expectedPhraseInOutput = "It is safe to remove the property"
|
|
||||||
})
|
|
||||||
add(TestCase {
|
|
||||||
dependencyPropagationFlag = true
|
|
||||||
expectedToPass = false
|
|
||||||
expectedPhraseInOutput = "Kotlin/Native dependencies commonization is now enabled by default"
|
|
||||||
})
|
|
||||||
add(TestCase {
|
|
||||||
hierarchiesSupportFlag = false
|
|
||||||
granularMetadataFlag = true
|
|
||||||
expectedToPass = false
|
|
||||||
expectedPhraseInOutput = "Conflicting properties"
|
|
||||||
})
|
|
||||||
add(TestCase {
|
|
||||||
hierarchiesSupportFlag = false
|
|
||||||
granularMetadataFlag = false
|
|
||||||
expectedToPass = true
|
|
||||||
expectedPhraseInOutput = "is redundant"
|
|
||||||
})
|
|
||||||
add(TestCase {
|
|
||||||
hierarchiesSupportFlag = false
|
|
||||||
dependencyPropagationFlag = false
|
|
||||||
expectedToPass = false
|
|
||||||
expectedPhraseInOutput = "Conflicting properties"
|
|
||||||
})
|
|
||||||
add(TestCase {
|
|
||||||
hierarchiesByDefault = false
|
|
||||||
hierarchiesSupportFlag = false
|
|
||||||
expectedToPass = false
|
|
||||||
expectedPhraseInOutput = "not yet supported"
|
|
||||||
})
|
|
||||||
add(TestCase {
|
|
||||||
hierarchiesSupportFlag = true
|
|
||||||
expectedToPass = true
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
private val projectsToTest = listOf(
|
|
||||||
"new-mpp-published",
|
|
||||||
"hierarchical-mpp-project-dependency"
|
|
||||||
)
|
|
||||||
|
|
||||||
@Parameterized.Parameters(name = "{1}: {0}")
|
|
||||||
@JvmStatic
|
|
||||||
fun testCases() = testCases
|
|
||||||
.flatMap { testCase -> projectsToTest.map { arrayOf(testCase, it) } }
|
|
||||||
}
|
|
||||||
|
|
||||||
val testProject by lazy {
|
|
||||||
Project(testProjectName).apply {
|
|
||||||
setupWorkingDir()
|
|
||||||
gradleBuildScript().modify(::transformBuildScriptWithPluginsDsl)
|
|
||||||
gradleProperties().delete()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@OptIn(ExperimentalStdlibApi::class)
|
|
||||||
@Test
|
|
||||||
fun doTest() {
|
|
||||||
val args = buildList {
|
|
||||||
with(testCase) {
|
|
||||||
if (hierarchiesByDefault == false)
|
|
||||||
add("-Pkotlin.internal.mpp.hierarchicalStructureByDefault=false")
|
|
||||||
if (hierarchiesSupportFlag != null)
|
|
||||||
add("-Pkotlin.mpp.hierarchicalStructureSupport=$hierarchiesSupportFlag")
|
|
||||||
if (granularMetadataFlag != null)
|
|
||||||
add("-Pkotlin.mpp.enableGranularSourceSetsMetadata=$granularMetadataFlag")
|
|
||||||
if (dependencyPropagationFlag != null) {
|
|
||||||
add("-Pkotlin.native.enableDependencyPropagation=$dependencyPropagationFlag")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// just run the configuration phase:
|
|
||||||
testProject.build(*args.toTypedArray()) {
|
|
||||||
if (testCase.expectedToPass)
|
|
||||||
assertSuccessful()
|
|
||||||
else
|
|
||||||
assertFailed()
|
|
||||||
|
|
||||||
testCase.expectedPhraseInOutput?.let { assertContains(it, ignoreCase = true) }
|
|
||||||
testCase.notExpectedPhraseInOutput?.let { assertNotContains(it) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-100
@@ -5,12 +5,10 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.gradle.plugin.mpp.internal
|
package org.jetbrains.kotlin.gradle.plugin.mpp.internal
|
||||||
|
|
||||||
import org.gradle.api.GradleException
|
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider
|
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider
|
||||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames
|
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames
|
||||||
import org.jetbrains.kotlin.gradle.utils.SingleActionPerProject
|
import org.jetbrains.kotlin.gradle.utils.SingleActionPerProject
|
||||||
import org.jetbrains.kotlin.gradle.utils.SingleWarningPerBuild
|
|
||||||
import org.jetbrains.kotlin.gradle.utils.getOrPut
|
import org.jetbrains.kotlin.gradle.utils.getOrPut
|
||||||
|
|
||||||
internal fun handleHierarchicalStructureFlagsMigration(project: Project) {
|
internal fun handleHierarchicalStructureFlagsMigration(project: Project) {
|
||||||
@@ -26,8 +24,6 @@ internal fun handleHierarchicalStructureFlagsMigration(project: Project) {
|
|||||||
|
|
||||||
private fun doHandleHierarchicalStructureFlagsMigration(project: Project) {
|
private fun doHandleHierarchicalStructureFlagsMigration(project: Project) {
|
||||||
with(PropertiesProvider(project)) {
|
with(PropertiesProvider(project)) {
|
||||||
checkHmppFeatureFlagsForConsistency(project)
|
|
||||||
|
|
||||||
if (hierarchicalStructureSupport) {
|
if (hierarchicalStructureSupport) {
|
||||||
if (project === project.rootProject)
|
if (project === project.rootProject)
|
||||||
project.extensions.extraProperties.getOrPut(PropertyNames.KOTLIN_MPP_ENABLE_GRANULAR_SOURCE_SETS_METADATA) { "true" }
|
project.extensions.extraProperties.getOrPut(PropertyNames.KOTLIN_MPP_ENABLE_GRANULAR_SOURCE_SETS_METADATA) { "true" }
|
||||||
@@ -36,99 +32,3 @@ private fun doHandleHierarchicalStructureFlagsMigration(project: Project) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun PropertiesProvider.checkHmppFeatureFlagsForConsistency(project: Project) {
|
|
||||||
if (mppHierarchicalStructureByDefault) {
|
|
||||||
if (hierarchicalStructureSupport) {
|
|
||||||
if (project === project.rootProject) {
|
|
||||||
when (enableGranularSourceSetsMetadata) {
|
|
||||||
true -> if (!mpp13XFlagsSetByPlugin) warnGranularMetadataTrueHasNoEffect(project)
|
|
||||||
false -> errorGranularMetadataFalseUnsupported()
|
|
||||||
null -> Unit
|
|
||||||
}
|
|
||||||
}
|
|
||||||
when (nativeDependencyPropagation) {
|
|
||||||
false -> if (!mpp13XFlagsSetByPlugin) warningDependencyPropagationFalseHasNoEffect(project)
|
|
||||||
true -> errorDependencyPropagationTrueUnsupported()
|
|
||||||
null -> Unit
|
|
||||||
}
|
|
||||||
} else { // hierarchicalStructureSupport is false
|
|
||||||
if (project === project.rootProject) {
|
|
||||||
when (enableGranularSourceSetsMetadata) {
|
|
||||||
true -> errorGranularMetadataTrueConflictsWithNewFlag()
|
|
||||||
false -> warningGranularMetadataFalseRedundantWithNewFlag(project)
|
|
||||||
null -> Unit
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!mpp13XFlagsSetByPlugin && nativeDependencyPropagation == false)
|
|
||||||
errorDependencyPropagationFalseConflictsWithNewFlag()
|
|
||||||
}
|
|
||||||
} else { // mppHierarchicalStructureByDefault is false
|
|
||||||
if (project.findProperty(PropertyNames.KOTLIN_MPP_HIERARCHICAL_STRUCTURE_SUPPORT) != null)
|
|
||||||
throw GradleException("The property '${PropertyNames.KOTLIN_MPP_HIERARCHICAL_STRUCTURE_SUPPORT}' is not yet supported.")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun errorDependencyPropagationFalseConflictsWithNewFlag() {
|
|
||||||
throw GradleException(
|
|
||||||
"Conflicting properties: '${PropertyNames.KOTLIN_MPP_HIERARCHICAL_STRUCTURE_SUPPORT}=false' (enabling Kotlin/Native " +
|
|
||||||
"dependencies commonization) " +
|
|
||||||
"and '${PropertyNames.KOTLIN_NATIVE_DEPENDENCY_PROPAGATION}=false'"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun warningGranularMetadataFalseRedundantWithNewFlag(project: Project) {
|
|
||||||
SingleWarningPerBuild.show(
|
|
||||||
project,
|
|
||||||
"The property '${PropertyNames.KOTLIN_MPP_ENABLE_GRANULAR_SOURCE_SETS_METADATA}=false' is redundant with " +
|
|
||||||
"'${PropertyNames.KOTLIN_MPP_HIERARCHICAL_STRUCTURE_SUPPORT}=false'\n"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun errorGranularMetadataTrueConflictsWithNewFlag() {
|
|
||||||
throw GradleException(
|
|
||||||
"Conflicting properties: '${PropertyNames.KOTLIN_MPP_HIERARCHICAL_STRUCTURE_SUPPORT}=false' and " +
|
|
||||||
"'${PropertyNames.KOTLIN_MPP_ENABLE_GRANULAR_SOURCE_SETS_METADATA}=true'."
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun warningDependencyPropagationFalseHasNoEffect(project: Project) {
|
|
||||||
SingleWarningPerBuild.show(
|
|
||||||
project,
|
|
||||||
"The property '${PropertyNames.KOTLIN_NATIVE_DEPENDENCY_PROPAGATION}=false' has no effect in this and future " +
|
|
||||||
"Kotlin versions, as Kotlin/Native dependency commonization is now enabled by default. " +
|
|
||||||
"It is safe to remove the property.\n"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun errorDependencyPropagationTrueUnsupported() {
|
|
||||||
throw GradleException(
|
|
||||||
"Kotlin/Native dependencies commonization is now enabled by default for all projects with Native-shared code, " +
|
|
||||||
"and the property '${PropertyNames.KOTLIN_NATIVE_DEPENDENCY_PROPAGATION}=true' is not supported anymore. " +
|
|
||||||
"It is possible to temporarily disable Hierarchical Structures support altogether with the following Gradle " +
|
|
||||||
"property:\n\n" +
|
|
||||||
" ${PropertyNames.KOTLIN_MPP_HIERARCHICAL_STRUCTURE_SUPPORT}=false\n\n" +
|
|
||||||
"If you are facing any issues with shared code and Hierarchical Structures support, please report them " +
|
|
||||||
"at https://kotl.in/issue\n"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun errorGranularMetadataFalseUnsupported() {
|
|
||||||
throw GradleException(
|
|
||||||
"Kotlin Multiplatform Hierarchical Structures support is now enabled by default for all projects, and the " +
|
|
||||||
"property '${PropertyNames.KOTLIN_MPP_ENABLE_GRANULAR_SOURCE_SETS_METADATA}=false' is not supported anymore. " +
|
|
||||||
"If you need to temporarily revert to the old behavior, please use the following Gradle property:\n\n" +
|
|
||||||
" ${PropertyNames.KOTLIN_MPP_HIERARCHICAL_STRUCTURE_SUPPORT}=false\n\n" +
|
|
||||||
"If you are facing any issues with shared code and Hierarchical Structures support, please report them " +
|
|
||||||
"at https://kotl.in/issue"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun warnGranularMetadataTrueHasNoEffect(project: Project) {
|
|
||||||
SingleWarningPerBuild.show(
|
|
||||||
project,
|
|
||||||
"The property '${PropertyNames.KOTLIN_MPP_ENABLE_GRANULAR_SOURCE_SETS_METADATA}=true' has no effect in this and future " +
|
|
||||||
"Kotlin versions, as Hierarchical Structures support is now enabled by default. " +
|
|
||||||
"It is safe to remove the property.\n"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user