[Gradle] Remove kpm Gradle integration tests
KT-61463
This commit is contained in:
committed by
Space Team
parent
02c2c76ffe
commit
eb0e7fa55b
@@ -166,27 +166,6 @@ projectTest(
|
||||
includeNative(false)
|
||||
}
|
||||
|
||||
projectTest(
|
||||
"testKpmModelMapping",
|
||||
shortenTempRootName = shortenTempRootName,
|
||||
jUnitMode = JUnitMode.JUnit5
|
||||
) {
|
||||
systemProperty("kotlin.gradle.kpm.enableModelMapping", "true")
|
||||
includeMppAndAndroid(true)
|
||||
includeNative(false)
|
||||
}
|
||||
|
||||
projectTest(
|
||||
"testAdvanceGradleVersionKpmModelMapping",
|
||||
shortenTempRootName = shortenTempRootName,
|
||||
jUnitMode = JUnitMode.JUnit5
|
||||
) {
|
||||
systemProperty("kotlin.gradle.kpm.enableModelMapping", "true")
|
||||
advanceGradleVersion()
|
||||
includeMppAndAndroid(true)
|
||||
includeNative(false)
|
||||
}
|
||||
|
||||
if (splitGradleIntegrationTestTasks) {
|
||||
projectTest(
|
||||
"testNative",
|
||||
|
||||
+1
-16
@@ -42,24 +42,13 @@ abstract class BaseGradleIT {
|
||||
|
||||
protected var workingDir = File(".")
|
||||
|
||||
internal open fun defaultBuildOptions(): BuildOptions = BuildOptions(
|
||||
withDaemon = true,
|
||||
enableKpmModelMapping = isKpmModelMappingEnabled
|
||||
)
|
||||
internal open fun defaultBuildOptions(): BuildOptions = BuildOptions(withDaemon = true)
|
||||
|
||||
open val defaultGradleVersion: GradleVersionRequired
|
||||
get() = GradleVersionRequired.None
|
||||
|
||||
val isTeamCityRun = System.getenv("TEAMCITY_VERSION") != null
|
||||
|
||||
/**
|
||||
* `var` makes it configurable per test
|
||||
* `open` makes it configurable per test suite
|
||||
*/
|
||||
protected open var isKpmModelMappingEnabled = System
|
||||
.getProperty("kotlin.gradle.kpm.enableModelMapping")
|
||||
.toBoolean()
|
||||
|
||||
@Before
|
||||
open fun setUp() {
|
||||
// Aapt2 from Android Gradle Plugin 3.2 and below does not handle long paths on Windows.
|
||||
@@ -930,10 +919,6 @@ abstract class BaseGradleIT {
|
||||
add("-Pkotlin.build.report.output=${options.withReports.joinToString { it.name }}")
|
||||
}
|
||||
|
||||
if (options.enableKpmModelMapping != null) {
|
||||
add("-Pkotlin.kpm.experimentalModelMapping=${options.enableKpmModelMapping}")
|
||||
}
|
||||
|
||||
add("-Pkotlin.daemon.useFallbackStrategy=${options.useDaemonFallbackStrategy}")
|
||||
|
||||
add("-Dorg.gradle.unsafe.configuration-cache=${options.configurationCache}")
|
||||
|
||||
-37
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2022 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.gradle.util.GradleVersion
|
||||
import org.jetbrains.kotlin.gradle.testbase.*
|
||||
import org.junit.jupiter.api.Disabled
|
||||
import org.junit.jupiter.api.DisplayName
|
||||
|
||||
@MppGradlePluginTests
|
||||
@GradleTestVersions(minVersion = TestVersions.Gradle.MIN_SUPPORTED_KPM)
|
||||
@Disabled
|
||||
class BuildIdeaKpmProjectModelIT : KGPBaseTest() {
|
||||
|
||||
@GradleTest
|
||||
@DisplayName("Check 'buildIdeaKpmProjectModel' creates expected files")
|
||||
fun `test - simple kpm project`(gradleVersion: GradleVersion) {
|
||||
project(
|
||||
"kpm-simple",
|
||||
gradleVersion,
|
||||
buildOptions = defaultBuildOptions.suppressDeprecationWarningsSinceGradleVersion(
|
||||
TestVersions.Gradle.G_7_4,
|
||||
gradleVersion,
|
||||
"Workaround for KT-55751"
|
||||
)
|
||||
) {
|
||||
build("buildIdeaKpmProjectModel") {
|
||||
assertFileInProjectExists("build/IdeaKpmProject/model.txt")
|
||||
assertFileInProjectExists("build/IdeaKpmProject/model.java.bin")
|
||||
assertFileInProjectExists("build/IdeaKpmProject/model.proto.bin")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+6
-53
@@ -6,33 +6,22 @@
|
||||
package org.jetbrains.kotlin.gradle
|
||||
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.GradleKpmModule
|
||||
import org.jetbrains.kotlin.gradle.tooling.BuildKotlinToolingMetadataTask
|
||||
import org.jetbrains.kotlin.gradle.tooling.BuildKotlinToolingMetadataTask.Companion.taskNameForKotlinModule
|
||||
import org.jetbrains.kotlin.konan.target.KonanTarget
|
||||
import org.jetbrains.kotlin.tooling.KotlinToolingMetadata
|
||||
import org.jetbrains.kotlin.tooling.parseJsonOrThrow
|
||||
import org.junit.Assume.assumeFalse
|
||||
import org.junit.AssumptionViolatedException
|
||||
import org.junit.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
class KotlinToolingMetadataMppIT : BaseGradleIT() {
|
||||
override val defaultGradleVersion: GradleVersionRequired = GradleVersionRequired.FOR_MPP_SUPPORT
|
||||
|
||||
private val defaultKotlinToolingMetadataJsonPath get() =
|
||||
if (isKpmModelMappingEnabled) {
|
||||
"build/kotlinToolingMetadata/main/kotlin-tooling-metadata.json"
|
||||
} else {
|
||||
"build/kotlinToolingMetadata/kotlin-tooling-metadata.json"
|
||||
}
|
||||
private val defaultKotlinToolingMetadataJsonPath
|
||||
get() = "build/kotlinToolingMetadata/kotlin-tooling-metadata.json"
|
||||
|
||||
private val buildKotlinToolingMetadataTaskName get() =
|
||||
if (isKpmModelMappingEnabled) {
|
||||
taskNameForKotlinModule(GradleKpmModule.MAIN_MODULE_NAME)
|
||||
} else {
|
||||
BuildKotlinToolingMetadataTask.defaultTaskName
|
||||
}
|
||||
|
||||
private val buildKotlinToolingMetadataTaskName
|
||||
get() = BuildKotlinToolingMetadataTask.defaultTaskName
|
||||
|
||||
@Test
|
||||
fun `new-mpp-published`() = with(transformProjectWithPluginsDsl("new-mpp-published")) {
|
||||
@@ -46,7 +35,7 @@ class KotlinToolingMetadataMppIT : BaseGradleIT() {
|
||||
val metadata = KotlinToolingMetadata.parseJsonOrThrow(metadataJson)
|
||||
assertEquals(
|
||||
listOfNotNull(
|
||||
KotlinPlatformType.common.name.takeIf { !isKpmModelMappingEnabled },
|
||||
KotlinPlatformType.common.name,
|
||||
KotlinPlatformType.jvm.name,
|
||||
KotlinPlatformType.js.name,
|
||||
KotlinPlatformType.native.name,
|
||||
@@ -107,7 +96,6 @@ class KotlinToolingMetadataMppIT : BaseGradleIT() {
|
||||
|
||||
@Test
|
||||
fun `kotlin-js-browser-project`() = with(transformProjectWithPluginsDsl("kotlin-js-browser-project")) {
|
||||
assumeFalse("KPM model mapping is not yet supported in single-platform projects", isKpmModelMappingEnabled)
|
||||
build(BuildKotlinToolingMetadataTask.defaultTaskName) {
|
||||
assertSuccessful()
|
||||
assertTasksExecuted(":app:$buildKotlinToolingMetadataTaskName")
|
||||
@@ -115,39 +103,4 @@ class KotlinToolingMetadataMppIT : BaseGradleIT() {
|
||||
assertTasksExecuted(":lib:$buildKotlinToolingMetadataTaskName")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `kpm multiple modules`() {
|
||||
// TODO: Move it to Integration Tests Container for pure KPM projects
|
||||
if (isKpmModelMappingEnabled) throw AssumptionViolatedException("Pure KPM tests don't need KPM model mapping flag")
|
||||
|
||||
with(transformProjectWithPluginsDsl("kpm-multi-module-published")) {
|
||||
val expectedMetadataByModule = mapOf<String, KotlinToolingMetadata.() -> Unit>(
|
||||
GradleKpmModule.MAIN_MODULE_NAME to {
|
||||
val nativeTarget = projectTargets.single { it.platformType == KotlinPlatformType.native.name }
|
||||
assertEquals(KonanTarget.LINUX_X64.name, nativeTarget.extras.native?.konanTarget)
|
||||
},
|
||||
"secondaryModule" to {
|
||||
val nativeTarget = projectTargets.single { it.platformType == KotlinPlatformType.native.name }
|
||||
assertEquals(KonanTarget.LINUX_ARM64.name, nativeTarget.extras.native?.konanTarget)
|
||||
},
|
||||
)
|
||||
|
||||
// FIXME: Use `publish` task for Integration Tests.
|
||||
// However Publishing of multiple modules fails currently and need proper design & implementation KT-49704
|
||||
build(BuildKotlinToolingMetadataTask.defaultTaskName) {
|
||||
assertSuccessful()
|
||||
expectedMetadataByModule.forEach { (moduleName, assertExpected) ->
|
||||
assertTasksExecuted(":${taskNameForKotlinModule(moduleName)}")
|
||||
|
||||
val pathToMetadata = "build/kotlinToolingMetadata/$moduleName/kotlin-tooling-metadata.json"
|
||||
assertFileExists(pathToMetadata)
|
||||
val metadataJson = projectDir.resolve(pathToMetadata).readText()
|
||||
val metadata = KotlinToolingMetadata.parseJsonOrThrow(metadataJson)
|
||||
|
||||
metadata.assertExpected()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-75
@@ -1,75 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2018 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.testbase.TestVersions
|
||||
import org.junit.Test
|
||||
import kotlin.test.Ignore
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
class KpmCompilerPluginMppIT : BaseGradleIT() {
|
||||
override val defaultGradleVersion: GradleVersionRequired = GradleVersionRequired.FOR_MPP_SUPPORT
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
fun testTransientPluginOptions() = with(transformProjectWithPluginsDsl("kpmTransientPluginOptions")) {
|
||||
val currentGradleVersion = chooseWrapperVersionOrFinishTest()
|
||||
val options = defaultBuildOptions().suppressDeprecationWarningsSinceGradleVersion(
|
||||
TestVersions.Gradle.G_7_4,
|
||||
currentGradleVersion,
|
||||
"Workaround for KT-55751"
|
||||
)
|
||||
|
||||
fun updatePluginOptions(regularOptionValue: String, transientOptionValue: String) {
|
||||
gradleProperties().writeText(
|
||||
"""
|
||||
test-plugin.regular=$regularOptionValue
|
||||
test-plugin.transient=$transientOptionValue
|
||||
""".trimIndent()
|
||||
)
|
||||
}
|
||||
|
||||
updatePluginOptions("XXX", "YYY")
|
||||
build("compileKotlin", options = options) {
|
||||
assertSuccessful()
|
||||
assertTasksExecuted(":compileKotlinJvm")
|
||||
compilerArgs(":compileKotlinJvm").also { args ->
|
||||
assertTrue(
|
||||
args.contains("plugin:test-plugin:regular=XXX"),
|
||||
"Expected regular plugin option in compilation args"
|
||||
)
|
||||
assertTrue(
|
||||
args.contains("plugin:test-plugin:transient=YYY"),
|
||||
"Expected transient plugin option in compilation args"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// When transient plugin option change
|
||||
updatePluginOptions("XXX", "ZZZ")
|
||||
build("compileKotlin", options = options) {
|
||||
assertSuccessful()
|
||||
assertTasksUpToDate(":compileKotlinJvm")
|
||||
}
|
||||
|
||||
// When regular plugin option change
|
||||
updatePluginOptions("ZZZ", "ZZZ")
|
||||
build("compileKotlin", options = options) {
|
||||
assertSuccessful()
|
||||
assertTasksExecuted(":compileKotlinJvm")
|
||||
compilerArgs(":compileKotlinJvm").also { args ->
|
||||
assertTrue(
|
||||
args.contains("plugin:test-plugin:regular=ZZZ"),
|
||||
"Expected regular plugin option in compilation args"
|
||||
)
|
||||
assertTrue(
|
||||
args.contains("plugin:test-plugin:transient=ZZZ"),
|
||||
"Expected transient plugin option in compilation args"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-53
@@ -1,53 +0,0 @@
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinPm20PluginWrapper
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.*
|
||||
|
||||
plugins {
|
||||
`maven-publish`
|
||||
}
|
||||
|
||||
buildscript {
|
||||
dependencies {
|
||||
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:<pluginMarkerVersion>")
|
||||
}
|
||||
}
|
||||
|
||||
apply<KotlinPm20PluginWrapper>()
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
group = "com.example.bar"
|
||||
version = "1.0"
|
||||
|
||||
configure<KotlinPm20ProjectExtension> {
|
||||
// feel free to add more modules, variants and fragments
|
||||
mainAndTest {
|
||||
jvm
|
||||
val linuxX64 by fragments.creating(GradleKpmLinuxX64Variant::class)
|
||||
}
|
||||
|
||||
val secondaryModule by modules.creating {
|
||||
jvm
|
||||
val linuxArm64 by fragments.creating(GradleKpmLinuxArm64Variant::class)
|
||||
|
||||
makePublic()
|
||||
}
|
||||
|
||||
test {
|
||||
dependencies { implementation(kotlin("test")) }
|
||||
jvm.dependencies { implementation(kotlin("test-junit")) }
|
||||
}
|
||||
|
||||
val integrationTest by modules.creating {
|
||||
jvm
|
||||
val linuxX64 by fragments.creating(GradleKpmLinuxX64Variant::class)
|
||||
}
|
||||
}
|
||||
|
||||
publishing {
|
||||
repositories {
|
||||
maven("../repo")
|
||||
}
|
||||
}
|
||||
-1
@@ -1 +0,0 @@
|
||||
rootProject.name = "my-multimodule-kpm-lib"
|
||||
-3
@@ -1,3 +0,0 @@
|
||||
package com.example.bar
|
||||
|
||||
fun stub() = ""
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
package com.example.bar
|
||||
|
||||
import kotlin.test.Test
|
||||
|
||||
class BarTest {
|
||||
@Test
|
||||
fun testBar() {
|
||||
|
||||
}
|
||||
}
|
||||
-3
@@ -1,3 +0,0 @@
|
||||
package com.example.bar
|
||||
|
||||
fun jvmStub() = ""
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
package com.example.bar
|
||||
|
||||
import kotlin.test.Test
|
||||
|
||||
class JvmBarTest {
|
||||
@Test
|
||||
fun testBar() {
|
||||
|
||||
}
|
||||
}
|
||||
-3
@@ -1,3 +0,0 @@
|
||||
package com.example.bar
|
||||
|
||||
fun linuxArm64Stub() =""
|
||||
-3
@@ -1,3 +0,0 @@
|
||||
package com.example.bar
|
||||
|
||||
fun linuxStub() =""
|
||||
-28
@@ -1,28 +0,0 @@
|
||||
import org.gradle.api.Project
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinPm20PluginWrapper
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.*
|
||||
import org.jetbrains.kotlin.project.model.*
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${property("kotlin_version")}")
|
||||
}
|
||||
}
|
||||
|
||||
apply<KotlinPm20PluginWrapper>()
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
configure<KotlinPm20ProjectExtension> {
|
||||
main {
|
||||
jvm
|
||||
}
|
||||
}
|
||||
-1
@@ -1 +0,0 @@
|
||||
rootProject.name = "kpm-simple"
|
||||
-4
@@ -1,4 +0,0 @@
|
||||
package testProject.kpmSimple
|
||||
|
||||
class Foo {
|
||||
}
|
||||
-64
@@ -1,64 +0,0 @@
|
||||
import org.gradle.api.Project
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinPm20PluginWrapper
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.*
|
||||
import org.jetbrains.kotlin.project.model.*
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:<pluginMarkerVersion>")
|
||||
}
|
||||
}
|
||||
|
||||
apply<KotlinPm20PluginWrapper>()
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
plugins.apply(KpmGradlePluginWithTransientPluginOptions::class.java)
|
||||
|
||||
configure<KotlinPm20ProjectExtension> {
|
||||
main {
|
||||
jvm
|
||||
}
|
||||
}
|
||||
|
||||
class KpmPluginWithTransientPluginOptions(
|
||||
private val regularOptionValue: String,
|
||||
private val transientOptionValue: String
|
||||
) : KpmCompilerPlugin {
|
||||
private fun pluginData() = PluginData(
|
||||
pluginId = "test-plugin",
|
||||
// allopen artifact is used to avoid boilerplate with cooking custom compiler plugin
|
||||
artifact = PluginData.ArtifactCoordinates("org.jetbrains.kotlin", "kotlin-allopen"),
|
||||
options = listOf(
|
||||
StringOption("regular", regularOptionValue, isTransient = false),
|
||||
StringOption("transient", transientOptionValue, isTransient = true)
|
||||
)
|
||||
)
|
||||
|
||||
override fun forMetadataCompilation(fragment: KpmFragment) = pluginData()
|
||||
override fun forNativeMetadataCompilation(fragment: KpmFragment) = pluginData()
|
||||
override fun forPlatformCompilation(variant: KpmVariant) = pluginData()
|
||||
}
|
||||
|
||||
class KpmGradlePluginWithTransientPluginOptions : GradleKpmCompilerPlugin {
|
||||
private lateinit var project: Project
|
||||
|
||||
override fun apply(target: Project) {
|
||||
project = target
|
||||
}
|
||||
|
||||
override val kpmCompilerPlugin by lazy {
|
||||
KpmPluginWithTransientPluginOptions(
|
||||
regularOptionValue = project.property("test-plugin.regular") as String,
|
||||
transientOptionValue = project.property("test-plugin.transient") as String
|
||||
)
|
||||
}
|
||||
}
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
test-plugin.regular=REGULAR_VALUE
|
||||
test-plugin.transient=TRANSIENT_VALUE
|
||||
-1
@@ -1 +0,0 @@
|
||||
rootProject.name = "kpmTransientPluginOptions"
|
||||
-4
@@ -1,4 +0,0 @@
|
||||
package testProject.kpmTransientPluginOptions
|
||||
|
||||
class Foo {
|
||||
}
|
||||
@@ -24,7 +24,6 @@ kotlin {
|
||||
optIn.addAll(
|
||||
listOf(
|
||||
"kotlin.RequiresOptIn",
|
||||
"org.jetbrains.kotlin.gradle.plugin.mpp.pm20.AdvancedKotlinGradlePluginApi",
|
||||
"org.jetbrains.kotlin.gradle.InternalKotlinGradlePluginApi",
|
||||
"org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi",
|
||||
"org.jetbrains.kotlin.gradle.ExternalKotlinTargetApi",
|
||||
|
||||
-1
@@ -16,7 +16,6 @@ import org.gradle.jvm.tasks.Jar
|
||||
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
|
||||
import org.jetbrains.kotlin.gradle.dsl.*
|
||||
import org.jetbrains.kotlin.gradle.plugin.*
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.*
|
||||
import org.jetbrains.kotlin.gradle.plugin.sources.awaitPlatformCompilations
|
||||
import org.jetbrains.kotlin.gradle.plugin.sources.internal
|
||||
import org.jetbrains.kotlin.gradle.targets.metadata.*
|
||||
|
||||
Reference in New Issue
Block a user