[mpp, tests] Modernize and simplify new-mpp-lib-with-tests

- Don't use presets (they are deprecated and provoke ERROR, causing
  build to fail)
- Drop two JVM targets (cause issues because ambiguous consumable
  configuration will be created; proper setup needs disambiguation
  attribute, but that's too much for this test)
- Drop jvmWithJava-target (this test case is used in several places
  as "just some MPP project", so specific advanced features like
  jvmWithJava shouldn't be covered here)

Refer to KT-60745 for proper jvmWithJava support
This commit is contained in:
Dmitry Savvinov
2023-07-25 21:09:23 +02:00
committed by Space Team
parent a9a6441d2d
commit 34f4e3cbf6
10 changed files with 14 additions and 79 deletions
@@ -101,8 +101,8 @@ class BuildCacheRelocationIT : KGPBaseTest() {
listOf("build"),
listOf(
":compileCommonMainKotlinMetadata",
":compileKotlinJvmWithJava",
":compileTestKotlinJvmWithJava",
":compileKotlinJvmWithoutJava",
":compileTestKotlinJvmWithoutJava",
":compileKotlinJs",
":compileTestKotlinJs"
)
@@ -136,7 +136,6 @@ internal class CompilerOptionsIT : KGPBaseTest() {
val compileTasks = listOf(
"compileKotlinMetadata",
"compileKotlinJvmWithJava",
"compileKotlinJvmWithoutJava",
"compileKotlinJs",
// we do not allow modifying free args for K/N at execution time
@@ -621,4 +620,4 @@ internal class CompilerOptionsIT : KGPBaseTest() {
}
}
}
}
}
@@ -421,6 +421,7 @@ open class NewMultiplatformIT : BaseGradleIT() {
}
@Test
@Ignore // KT-60745
fun testJvmWithJavaEquivalence() = doTestJvmWithJava(testJavaSupportInJvmTargets = false)
@Test
@@ -627,31 +628,12 @@ open class NewMultiplatformIT : BaseGradleIT() {
":compileTestKotlinJs",
":compileKotlinJvmWithoutJava",
":compileTestKotlinJvmWithoutJava",
":compileKotlinJvmWithJava",
":compileJava",
":compileTestKotlinJvmWithJava",
":compileTestJava",
// test tasks:
":jsTest", // does not run any actual tests for now
":jvmWithoutJavaTest",
":test"
)
val expectedKotlinOutputFiles = listOf(
*kotlinClassesDir(sourceSet = "jvmWithJava/main").let {
arrayOf(
it + "com/example/lib/JavaClassUsageKt.class",
it + "com/example/lib/CommonKt.class",
it + "META-INF/new-mpp-lib-with-tests.kotlin_module"
)
},
*kotlinClassesDir(sourceSet = "jvmWithJava/test").let {
arrayOf(
it + "com/example/lib/TestCommonCode.class",
it + "com/example/lib/TestWithJava.class",
it + "META-INF/new-mpp-lib-with-tests_test.kotlin_module"
)
},
*kotlinClassesDir(sourceSet = "jvmWithoutJava/main").let {
arrayOf(
it + "com/example/lib/CommonKt.class",
@@ -676,7 +658,6 @@ open class NewMultiplatformIT : BaseGradleIT() {
assertTestResults(
expectedTestResults,
"jsNodeTest",
"test", // jvmTest
"${targetName}Test"
)
}
@@ -161,4 +161,4 @@ private fun BuildResult.assertNoTestsStateFileException() {
// KT-55134
assertOutputDoesNotContain("Cannot read test tasks state from")
assertOutputDoesNotContain("Cannot store test tasks state into")
}
}
@@ -19,15 +19,11 @@ repositories {
}
kotlin {
targets {
fromPreset(presets.jvm, 'jvmWithoutJava')
fromPreset(presets.jvmWithJava, 'jvmWithJava')
fromPreset(presets.macosX64, 'macos64')
fromPreset(presets.macosArm64, 'macosArm64')
fromPreset(presets.linuxX64, 'linux64')
fromPreset(presets.mingwX64, 'mingw64')
}
jvm("jvmWithoutJava")
macosX64("macos64")
macosArm64()
linuxX64("linux64")
mingwX64("mingw64")
js {
nodejs()
}
@@ -61,4 +57,4 @@ kotlin {
dependsOn nativeMain
}
}
}
}
@@ -9,7 +9,6 @@ repositories {
kotlin {
val jvmWithoutJava = jvm("jvmWithoutJava")
val jvmWithJava = targetFromPreset(presets["jvmWithJava"])
val js = js {
nodejs()
}
@@ -26,18 +25,14 @@ kotlin {
}
}
val main by getting
val jvmWithoutJavaMain = jvmWithoutJava.compilations["main"].defaultSourceSet
configure(listOf(main, jvmWithoutJavaMain)) {
jvmWithoutJava.compilations["main"].defaultSourceSet {
dependencies {
implementation(kotlin("stdlib"))
implementation(kotlin("script-runtime"))
}
}
val test by getting
val jvmWithoutJavaTest = jvmWithoutJava.compilations["test"].defaultSourceSet
configure(listOf(test, jvmWithoutJavaTest)) {
jvmWithoutJava.compilations["test"].defaultSourceSet {
dependencies {
implementation(kotlin("test-junit"))
}
@@ -54,4 +49,4 @@ kotlin {
compilations["main"].defaultSourceSet.dependsOn(nativeMain)
}
}
}
}
@@ -1,5 +0,0 @@
package com.example.lib
actual fun expectedFun() { println(id(1)) }
fun f() = JavaClass()
@@ -1,11 +0,0 @@
package com.example.lib;
import org.junit.Test;
public class TestJava {
@Test
public void testJava() {
new JavaClass();
JavaClassUsageKt.f();
}
}
@@ -1,15 +0,0 @@
package com.example.lib
import org.junit.Test
class TestWithJava {
@Test
fun testJavaClass() {
JavaClass()
f()
}
companion object {
val seesJavaTestClass = TestJava::class
}
}