[Gradle] Remove tests related to Legacy Metadata Compilation
it is no longer supported in k2 ^KT-61817 ^KT-61106 Verification Pending
This commit is contained in:
committed by
Space Team
parent
642c9e4261
commit
311b4c2deb
+1
-8
@@ -17,7 +17,6 @@ import org.jetbrains.kotlin.gradle.model.ModelFetcherBuildAction
|
||||
import org.jetbrains.kotlin.gradle.report.BuildReportType
|
||||
import org.jetbrains.kotlin.gradle.testbase.*
|
||||
import org.jetbrains.kotlin.gradle.util.*
|
||||
import org.jetbrains.kotlin.gradle.util.modify
|
||||
import org.jetbrains.kotlin.konan.target.HostManager
|
||||
import org.jetbrains.kotlin.konan.target.KonanTarget
|
||||
import org.jetbrains.kotlin.test.RunnerWithMuteInDatabase
|
||||
@@ -33,7 +32,6 @@ import java.nio.file.Paths
|
||||
import java.util.*
|
||||
import java.util.regex.Pattern
|
||||
import javax.xml.parsers.DocumentBuilderFactory
|
||||
import kotlin.collections.HashSet
|
||||
import kotlin.io.path.absolutePathString
|
||||
import kotlin.io.path.isDirectory
|
||||
import kotlin.test.*
|
||||
@@ -269,7 +267,6 @@ abstract class BaseGradleIT {
|
||||
val dryRun: Boolean = false,
|
||||
val abiSnapshot: Boolean = false,
|
||||
val hierarchicalMPPStructureSupport: Boolean? = null,
|
||||
val enableCompatibilityMetadataVariant: Boolean? = null,
|
||||
val withReports: List<BuildReportType> = emptyList(),
|
||||
val enableKpmModelMapping: Boolean? = null,
|
||||
val useDaemonFallbackStrategy: Boolean = false,
|
||||
@@ -915,10 +912,6 @@ abstract class BaseGradleIT {
|
||||
add("-Pkotlin.mpp.hierarchicalStructureSupport=${options.hierarchicalMPPStructureSupport}")
|
||||
}
|
||||
|
||||
if (options.enableCompatibilityMetadataVariant != null) {
|
||||
add("-Pkotlin.mpp.enableCompatibilityMetadataVariant=${options.enableCompatibilityMetadataVariant}")
|
||||
}
|
||||
|
||||
if (options.withReports.isNotEmpty()) {
|
||||
add("-Pkotlin.build.report.output=${options.withReports.joinToString { it.name }}")
|
||||
}
|
||||
@@ -942,7 +935,7 @@ abstract class BaseGradleIT {
|
||||
|
||||
// temporary suppression for the usage of deprecated pre-HMPP properties.
|
||||
// Should be removed together with the flags support in 2.0
|
||||
if (options.hierarchicalMPPStructureSupport != null || options.enableCompatibilityMetadataVariant != null) {
|
||||
if (options.hierarchicalMPPStructureSupport != null) {
|
||||
add("-Pkotlin.internal.suppressGradlePluginErrors=PreHMPPFlagsError")
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -41,7 +41,7 @@ open class HierarchicalMppIT : KGPBaseTest() {
|
||||
fun testPublishedModules(gradleVersion: GradleVersion, @TempDir tempDir: Path) {
|
||||
val buildOptions = defaultBuildOptions.copy(logLevel = LogLevel.DEBUG)
|
||||
|
||||
publishThirdPartyLib(withGranularMetadata = false, gradleVersion = gradleVersion, localRepoDir = tempDir)
|
||||
publishThirdPartyLib(withGranularMetadata = true, gradleVersion = gradleVersion, localRepoDir = tempDir)
|
||||
|
||||
nativeProject(
|
||||
"my-lib-foo".withPrefix,
|
||||
@@ -201,7 +201,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 = false, gradleVersion = gradleVersion, localRepoDir = tempDir)
|
||||
publishThirdPartyLib(withGranularMetadata = true, gradleVersion = gradleVersion, localRepoDir = tempDir)
|
||||
|
||||
with(
|
||||
nativeProject(
|
||||
|
||||
+10
-117
@@ -5,22 +5,22 @@
|
||||
package org.jetbrains.kotlin.gradle
|
||||
|
||||
import org.gradle.api.logging.LogLevel
|
||||
import org.jetbrains.kotlin.gradle.native.GeneralNativeIT.Companion.withNativeCommandLineArguments
|
||||
import org.jetbrains.kotlin.gradle.native.GeneralNativeIT.Companion.containsSequentially
|
||||
import org.gradle.util.GradleVersion
|
||||
import org.jetbrains.kotlin.cli.common.arguments.K2NativeCompilerArguments
|
||||
import org.jetbrains.kotlin.cli.common.arguments.parseCommandLineArguments
|
||||
import org.jetbrains.kotlin.gradle.native.*
|
||||
import org.jetbrains.kotlin.gradle.native.GeneralNativeIT.Companion.containsSequentially
|
||||
import org.jetbrains.kotlin.gradle.native.GeneralNativeIT.Companion.withNativeCommandLineArguments
|
||||
import org.jetbrains.kotlin.gradle.native.MPPNativeTargets
|
||||
import org.jetbrains.kotlin.gradle.native.configureJvmMemory
|
||||
import org.jetbrains.kotlin.gradle.native.transformNativeTestProject
|
||||
import org.jetbrains.kotlin.gradle.native.transformNativeTestProjectWithPluginDsl
|
||||
import org.jetbrains.kotlin.gradle.plugin.ProjectLocalConfigurations
|
||||
import org.jetbrains.kotlin.gradle.plugin.diagnostics.KotlinToolingDiagnostics
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinMultiplatformPlugin
|
||||
import org.jetbrains.kotlin.gradle.plugin.sources.METADATA_CONFIGURATION_NAME_SUFFIX
|
||||
import org.jetbrains.kotlin.gradle.plugin.sources.UnsatisfiedSourceSetVisibilityException
|
||||
import org.jetbrains.kotlin.gradle.targets.jvm.KotlinJvmTarget
|
||||
import org.jetbrains.kotlin.gradle.testbase.*
|
||||
import org.jetbrains.kotlin.gradle.testbase.TestVersions
|
||||
import org.jetbrains.kotlin.gradle.testbase.assertHasDiagnostic
|
||||
import org.jetbrains.kotlin.gradle.testbase.assertNoDiagnostic
|
||||
import org.jetbrains.kotlin.gradle.util.*
|
||||
import org.jetbrains.kotlin.konan.target.HostManager
|
||||
import org.jetbrains.kotlin.konan.target.KonanTarget
|
||||
@@ -43,7 +43,6 @@ open class NewMultiplatformIT : BaseGradleIT() {
|
||||
|
||||
private data class HmppFlags(
|
||||
val hmppSupport: Boolean,
|
||||
val enableCompatibilityMetadataArtifact: Boolean,
|
||||
val name: String,
|
||||
) {
|
||||
override fun toString() = name
|
||||
@@ -51,26 +50,17 @@ open class NewMultiplatformIT : BaseGradleIT() {
|
||||
|
||||
private val noHMPP = HmppFlags(
|
||||
name = "No HMPP",
|
||||
hmppSupport = false,
|
||||
enableCompatibilityMetadataArtifact = false
|
||||
hmppSupport = false
|
||||
)
|
||||
|
||||
private val hmppWoCompatibilityMetadataArtifact = HmppFlags(
|
||||
name = "HMPP without Compatibility Metadata Artifact",
|
||||
hmppSupport = true,
|
||||
enableCompatibilityMetadataArtifact = false
|
||||
)
|
||||
|
||||
private val hmppWithCompatibilityMetadataArtifact = HmppFlags(
|
||||
name = "HMPP with Compatibility Metadata Artifact",
|
||||
hmppSupport = true,
|
||||
enableCompatibilityMetadataArtifact = true
|
||||
hmppSupport = true
|
||||
)
|
||||
|
||||
private val HmppFlags.buildOptions
|
||||
get() = defaultBuildOptions().copy(
|
||||
hierarchicalMPPStructureSupport = hmppSupport,
|
||||
enableCompatibilityMetadataVariant = enableCompatibilityMetadataArtifact,
|
||||
hierarchicalMPPStructureSupport = hmppSupport
|
||||
)
|
||||
|
||||
@Test
|
||||
@@ -87,13 +77,6 @@ open class NewMultiplatformIT : BaseGradleIT() {
|
||||
noHMPP
|
||||
)
|
||||
|
||||
@Test
|
||||
fun testLibAndAppWithCompatibilityArtifact() = doTestLibAndApp(
|
||||
"sample-lib",
|
||||
"sample-app",
|
||||
hmppWithCompatibilityMetadataArtifact
|
||||
)
|
||||
|
||||
@Test
|
||||
fun testLibAndAppWithGradleKotlinDsl() = doTestLibAndApp(
|
||||
"sample-lib-gradle-kotlin-dsl",
|
||||
@@ -108,7 +91,6 @@ open class NewMultiplatformIT : BaseGradleIT() {
|
||||
) {
|
||||
val libProject = transformNativeTestProjectWithPluginDsl(libProjectName, directoryPrefix = "new-mpp-lib-and-app")
|
||||
val appProject = transformNativeTestProjectWithPluginDsl(appProjectName, directoryPrefix = "new-mpp-lib-and-app")
|
||||
val oldStyleAppProject = Project("sample-old-style-app", directoryPrefix = "new-mpp-lib-and-app")
|
||||
|
||||
val buildOptions = hmppFlags.buildOptions
|
||||
val compileTasksNames =
|
||||
@@ -122,10 +104,6 @@ open class NewMultiplatformIT : BaseGradleIT() {
|
||||
assertSuccessful()
|
||||
assertTasksExecuted(*compileTasksNames.toTypedArray(), ":jvm6Jar", ":nodeJsJar", ":compileCommonMainKotlinMetadata")
|
||||
|
||||
if (hmppFlags.enableCompatibilityMetadataArtifact) {
|
||||
assertTasksExecuted(":compileKotlinMetadata", ":metadataJar")
|
||||
}
|
||||
|
||||
val groupDir = projectDir.resolve("repo/com/example")
|
||||
val jvmJarName = "sample-lib-jvm6/1.0/sample-lib-jvm6-1.0.jar"
|
||||
val jsExtension = "klib"
|
||||
@@ -158,10 +136,6 @@ open class NewMultiplatformIT : BaseGradleIT() {
|
||||
|
||||
Assert.assertTrue(groupDir.resolve(jsKlibName).exists())
|
||||
|
||||
val metadataJarEntries = ZipFile(groupDir.resolve(metadataJarName)).entries().asSequence().map { it.name }.toSet()
|
||||
val metadataFileFound = "com/example/lib/CommonKt.kotlin_metadata" in metadataJarEntries
|
||||
Assert.assertEquals(hmppFlags.enableCompatibilityMetadataArtifact, metadataFileFound)
|
||||
|
||||
Assert.assertTrue(groupDir.resolve(nativeKlibName).exists())
|
||||
}
|
||||
}
|
||||
@@ -189,12 +163,6 @@ open class NewMultiplatformIT : BaseGradleIT() {
|
||||
Assert.assertTrue(resolve("com/example/app/Jdk8ApiUsageKt.class").exists())
|
||||
}
|
||||
|
||||
if (hmppFlags.enableCompatibilityMetadataArtifact) {
|
||||
projectDir.resolve(targetClassesDir("metadata")).run {
|
||||
Assert.assertTrue(resolve("com/example/app/AKt.kotlin_metadata").exists())
|
||||
}
|
||||
}
|
||||
|
||||
val nativeExeName = if (isWindows) "main.exe" else "main.kexe"
|
||||
assertFileExists("build/bin/linux64/mainDebugExecutable/$nativeExeName")
|
||||
|
||||
@@ -233,26 +201,6 @@ open class NewMultiplatformIT : BaseGradleIT() {
|
||||
checkAppBuild()
|
||||
}
|
||||
}
|
||||
|
||||
if (hmppFlags.enableCompatibilityMetadataArtifact) {
|
||||
with(oldStyleAppProject) {
|
||||
setupWorkingDir()
|
||||
gradleBuildScript().appendText("\nallprojects { repositories { maven { url '$libLocalRepoUri' } } }")
|
||||
|
||||
build("assemble", options = buildOptions) {
|
||||
assertSuccessful()
|
||||
assertTasksExecuted(":app-jvm:compileKotlin", ":app-common:compileKotlinCommon")
|
||||
|
||||
assertFileExists(kotlinClassesDir("app-common") + "com/example/app/CommonAppKt.kotlin_metadata")
|
||||
|
||||
val jvmClassFile = projectDir.resolve(kotlinClassesDir("app-jvm") + "com/example/app/JvmAppKt.class")
|
||||
checkBytecodeContains(jvmClassFile, "CommonKt.id", "MainKt.expectedFun")
|
||||
|
||||
// val jsCompiledFilePath = kotlinClassesDir("app-js") + "app-js.js"
|
||||
// assertFileContains(jsCompiledFilePath, "lib.expectedFun", "lib.id")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -901,10 +849,6 @@ open class NewMultiplatformIT : BaseGradleIT() {
|
||||
fun testResolveJsPartOfMppLibDependencyToMetadataWithHmpp() =
|
||||
testResolveJsPartOfMppLibDependencyToMetadata(hmppWoCompatibilityMetadataArtifact)
|
||||
|
||||
@Test
|
||||
fun testResolveJsPartOfMppLibDependencyToMetadataWithHmppAndCompatibilityMetadataArtifact() =
|
||||
testResolveJsPartOfMppLibDependencyToMetadata(hmppWithCompatibilityMetadataArtifact)
|
||||
|
||||
@Test
|
||||
fun testResolveJsPartOfMppLibDependencyToMetadataWithoutHmpp() =
|
||||
testResolveJsPartOfMppLibDependencyToMetadata(noHMPP)
|
||||
@@ -1026,57 +970,6 @@ open class NewMultiplatformIT : BaseGradleIT() {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testNonMppConsumersOfLibraryPublishedWithNoMetadataOptIn() {
|
||||
val repoDir = with(transformNativeTestProject("sample-lib", gradleVersion, "new-mpp-lib-and-app")) {
|
||||
build(
|
||||
"publish",
|
||||
options = hmppWithCompatibilityMetadataArtifact.buildOptions
|
||||
) { assertSuccessful() }
|
||||
projectDir.resolve("repo")
|
||||
}
|
||||
|
||||
with(Project("sample-old-style-app", gradleVersion, "new-mpp-lib-and-app")) {
|
||||
setupWorkingDir()
|
||||
gradleBuildScript().appendText("\nallprojects { repositories { maven { url '${repoDir.toURI()}' } } }")
|
||||
gradleBuildScript("app-jvm").modify { it.replace("com.example:sample-lib:", "com.example:sample-lib-jvm6:") }
|
||||
|
||||
build("assemble", "run") {
|
||||
assertSuccessful()
|
||||
assertTasksExecuted(":app-common:compileKotlinCommon", ":app-jvm:compileKotlin", ":app-jvm:run")
|
||||
}
|
||||
|
||||
// Then run again without even reading the metadata from the repo:
|
||||
projectDir.resolve("settings.gradle").modify { it.replace("enableFeaturePreview('GRADLE_METADATA')", "") }
|
||||
|
||||
build("assemble", "run", "--rerun-tasks") {
|
||||
assertSuccessful()
|
||||
assertTasksExecuted(":app-common:compileKotlinCommon", ":app-jvm:compileKotlin", ":app-jvm:run")
|
||||
}
|
||||
}
|
||||
|
||||
with(Project("sample-app-without-kotlin", gradleVersion, "new-mpp-lib-and-app")) {
|
||||
setupWorkingDir()
|
||||
gradleBuildScript().modify {
|
||||
it.replace("com.example:sample-lib:1.0", "com.example:sample-lib-jvm6:1.0") + "\n" + """
|
||||
repositories { maven { url '${repoDir.toURI()}' } }
|
||||
""".trimIndent()
|
||||
}
|
||||
|
||||
build("run") {
|
||||
assertSuccessful()
|
||||
assertTasksExecuted(":compileJava", ":run")
|
||||
}
|
||||
|
||||
// Then run again without even reading the metadata from the repo:
|
||||
projectDir.resolve("settings.gradle").modify { it.replace("enableFeaturePreview('GRADLE_METADATA')", "") }
|
||||
build("run", "--rerun-tasks") {
|
||||
assertSuccessful()
|
||||
assertTasksExecuted(":compileJava", ":run")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testOptionalExpectations() = with(transformNativeTestProject("new-mpp-lib-with-tests", gradleVersion)) {
|
||||
projectDir.resolve("src/commonMain/kotlin/Optional.kt").writeText(
|
||||
@@ -1862,7 +1755,7 @@ open class NewMultiplatformIT : BaseGradleIT() {
|
||||
setupWorkingDir()
|
||||
gradleBuildScript().modify(::transformBuildScriptWithPluginsDsl)
|
||||
|
||||
build("publish", options = defaultBuildOptions().copy(enableCompatibilityMetadataVariant = false)) {
|
||||
build("publish") {
|
||||
assertSuccessful()
|
||||
}
|
||||
}
|
||||
|
||||
-35
@@ -8,7 +8,6 @@ package org.jetbrains.kotlin.gradle
|
||||
import org.gradle.util.GradleVersion
|
||||
import org.jetbrains.kotlin.gradle.util.*
|
||||
import org.junit.Test
|
||||
import java.io.File
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
class VariantAwareDependenciesMppIT : BaseGradleIT() {
|
||||
@@ -256,40 +255,6 @@ class VariantAwareDependenciesMppIT : BaseGradleIT() {
|
||||
assertTrue(items.toString()) { items.any { "atomicfu-jvm" in it } }
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testResolveCompatibilityMetadataVariantWithNative() = with(Project("native-libraries")) {
|
||||
setupWorkingDir()
|
||||
val nestedProjectName = "nested"
|
||||
embedProject(Project("native-libraries"), nestedProjectName)
|
||||
|
||||
projectDir.resolve("gradle.properties").appendText(
|
||||
"\n" + """
|
||||
kotlin.mpp.enableCompatibilityMetadataVariant=true
|
||||
kotlin.internal.suppressGradlePluginErrors=PreHMPPFlagsError
|
||||
"""
|
||||
)
|
||||
|
||||
val resolveConfigurationTaskName = "resolveConfiguration"
|
||||
val marker = "###=>"
|
||||
|
||||
gradleBuildScript().appendText(
|
||||
"\n" + """
|
||||
dependencies { "commonMainImplementation"(project(":$nestedProjectName")) }
|
||||
tasks.create("$resolveConfigurationTaskName") {
|
||||
doFirst {
|
||||
println("$marker" + configurations.getByName("metadataCompileClasspath").toList())
|
||||
}
|
||||
}
|
||||
"""
|
||||
)
|
||||
build(resolveConfigurationTaskName) {
|
||||
assertSuccessful()
|
||||
val output = output.lines().single { marker in it }.substringAfter(marker).removeSurrounding("[", "]").split(",")
|
||||
assertTrue { output.any { "$nestedProjectName-1.0.jar" in it } }
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
internal fun BaseGradleIT.Project.embedProject(other: BaseGradleIT.Project, renameTo: String? = null) {
|
||||
|
||||
Reference in New Issue
Block a user