[Gradle] Fix gradle integration tests after enabling HMPP by default
This commit is contained in:
+2
-2
@@ -95,12 +95,12 @@ open class KotlinAndroid36GradleIT : KotlinAndroid34GradleIT() {
|
|||||||
":lib:compileReleaseKotlinAndroidLib",
|
":lib:compileReleaseKotlinAndroidLib",
|
||||||
":lib:compileKotlinJvmLib",
|
":lib:compileKotlinJvmLib",
|
||||||
":lib:compileKotlinJsLib",
|
":lib:compileKotlinJsLib",
|
||||||
":lib:compileKotlinMetadata",
|
":lib:compileCommonMainKotlinMetadata",
|
||||||
":app:compileDebugKotlinAndroidApp",
|
":app:compileDebugKotlinAndroidApp",
|
||||||
":app:compileReleaseKotlinAndroidApp",
|
":app:compileReleaseKotlinAndroidApp",
|
||||||
":app:compileKotlinJvmApp",
|
":app:compileKotlinJvmApp",
|
||||||
":app:compileKotlinJsApp",
|
":app:compileKotlinJsApp",
|
||||||
":app:compileKotlinMetadata",
|
":app:compileCommonMainKotlinMetadata",
|
||||||
":lib:compileDebugUnitTestJavaWithJavac",
|
":lib:compileDebugUnitTestJavaWithJavac",
|
||||||
":app:compileDebugUnitTestJavaWithJavac"
|
":app:compileDebugUnitTestJavaWithJavac"
|
||||||
)
|
)
|
||||||
|
|||||||
+10
@@ -262,6 +262,8 @@ abstract class BaseGradleIT {
|
|||||||
val customEnvironmentVariables: Map<String, String> = mapOf(),
|
val customEnvironmentVariables: Map<String, String> = mapOf(),
|
||||||
val dryRun: Boolean = false,
|
val dryRun: Boolean = false,
|
||||||
val abiSnapshot: Boolean = false,
|
val abiSnapshot: Boolean = false,
|
||||||
|
val hierarchicalMPPStructureSupport: Boolean? = null,
|
||||||
|
val enableCompatibilityMetadataVariant: Boolean? = null,
|
||||||
)
|
)
|
||||||
|
|
||||||
enum class ConfigurationCacheProblems {
|
enum class ConfigurationCacheProblems {
|
||||||
@@ -921,6 +923,14 @@ Finished executing task ':$taskName'|
|
|||||||
add("-Dkotlin.incremental.classpath.snapshot.enabled=true")
|
add("-Dkotlin.incremental.classpath.snapshot.enabled=true")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options.hierarchicalMPPStructureSupport != null) {
|
||||||
|
add("-Pkotlin.mpp.hierarchicalStructureSupport=${options.hierarchicalMPPStructureSupport}")
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options.enableCompatibilityMetadataVariant != null) {
|
||||||
|
add("-Pkotlin.mpp.enableCompatibilityMetadataVariant=${options.enableCompatibilityMetadataVariant}")
|
||||||
|
}
|
||||||
|
|
||||||
add("-Dorg.gradle.unsafe.configuration-cache=${options.configurationCache}")
|
add("-Dorg.gradle.unsafe.configuration-cache=${options.configurationCache}")
|
||||||
add("-Dorg.gradle.unsafe.configuration-cache-problems=${options.configurationCacheProblems.name.toLowerCase()}")
|
add("-Dorg.gradle.unsafe.configuration-cache-problems=${options.configurationCacheProblems.name.toLowerCase()}")
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -109,7 +109,7 @@ class BuildCacheRelocationIT : KGPBaseTest() {
|
|||||||
secondProject,
|
secondProject,
|
||||||
listOf("build"),
|
listOf("build"),
|
||||||
listOf(
|
listOf(
|
||||||
":compileKotlinMetadata",
|
":compileCommonMainKotlinMetadata",
|
||||||
":compileKotlinJvmWithJava",
|
":compileKotlinJvmWithJava",
|
||||||
":compileTestKotlinJvmWithJava",
|
":compileTestKotlinJvmWithJava",
|
||||||
":compileKotlinJs",
|
":compileKotlinJs",
|
||||||
|
|||||||
+2
-2
@@ -234,8 +234,8 @@ class HierarchicalMppIT : BaseGradleIT() {
|
|||||||
transformNativeTestProjectWithPluginDsl(projectName, gradleVersion, directoryPrefix).apply {
|
transformNativeTestProjectWithPluginDsl(projectName, gradleVersion, directoryPrefix).apply {
|
||||||
beforePublishing()
|
beforePublishing()
|
||||||
|
|
||||||
if (withGranularMetadata) {
|
if (!withGranularMetadata) {
|
||||||
projectDir.resolve("gradle.properties").appendText("kotlin.mpp.enableGranularSourceSetsMetadata=true")
|
projectDir.resolve("gradle.properties").appendText("kotlin.internal.mpp.hierarchicalStructureByDefault=false")
|
||||||
}
|
}
|
||||||
|
|
||||||
build(
|
build(
|
||||||
|
|||||||
+8
-8
@@ -16,7 +16,7 @@ import kotlin.test.assertTrue
|
|||||||
@RunWith(Parameterized::class)
|
@RunWith(Parameterized::class)
|
||||||
internal class HierarchicalStructureOptInMigrationArtifactContentIT : BaseGradleIT() {
|
internal class HierarchicalStructureOptInMigrationArtifactContentIT : BaseGradleIT() {
|
||||||
enum class Mode {
|
enum class Mode {
|
||||||
FLIPPED_DEFAULT, FLIPPED_DISABLE, NON_FLIPPED_DEFAULT
|
HMPP_BY_DEFAULT, OPT_OUT_HMPP, DISABLE_HMPP_BY_DEFAULT
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@@ -39,12 +39,12 @@ internal class HierarchicalStructureOptInMigrationArtifactContentIT : BaseGradle
|
|||||||
add("clean")
|
add("clean")
|
||||||
add("publish")
|
add("publish")
|
||||||
when (mode) {
|
when (mode) {
|
||||||
FLIPPED_DISABLE, FLIPPED_DEFAULT -> add("-Pkotlin.internal.mpp.hierarchicalStructureByDefault=true")
|
OPT_OUT_HMPP, HMPP_BY_DEFAULT -> {}
|
||||||
NON_FLIPPED_DEFAULT -> {}
|
DISABLE_HMPP_BY_DEFAULT -> { add("-Pkotlin.internal.mpp.hierarchicalStructureByDefault=false") }
|
||||||
}
|
}
|
||||||
when (mode) {
|
when (mode) {
|
||||||
FLIPPED_DISABLE -> add("-Pkotlin.mpp.hierarchicalStructureSupport=false")
|
OPT_OUT_HMPP -> add("-Pkotlin.mpp.hierarchicalStructureSupport=false")
|
||||||
FLIPPED_DEFAULT, NON_FLIPPED_DEFAULT -> {}
|
HMPP_BY_DEFAULT, DISABLE_HMPP_BY_DEFAULT -> {}
|
||||||
}
|
}
|
||||||
}.toTypedArray(),
|
}.toTypedArray(),
|
||||||
) {
|
) {
|
||||||
@@ -55,14 +55,14 @@ internal class HierarchicalStructureOptInMigrationArtifactContentIT : BaseGradle
|
|||||||
zip.entries().asSequence().toList().map { it.name }
|
zip.entries().asSequence().toList().map { it.name }
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode != NON_FLIPPED_DEFAULT) {
|
if (mode != DISABLE_HMPP_BY_DEFAULT) {
|
||||||
assertTrue { metadataJarEntries.any { "commonMain" in it } }
|
assertTrue { metadataJarEntries.any { "commonMain" in it } }
|
||||||
}
|
}
|
||||||
|
|
||||||
val hasJvmAndJsMainEntries = metadataJarEntries.any { "jvmAndJsMain" in it }
|
val hasJvmAndJsMainEntries = metadataJarEntries.any { "jvmAndJsMain" in it }
|
||||||
val shouldHaveJvmAndJsMainEntries = when (mode) {
|
val shouldHaveJvmAndJsMainEntries = when (mode) {
|
||||||
FLIPPED_DISABLE, NON_FLIPPED_DEFAULT -> false
|
OPT_OUT_HMPP, DISABLE_HMPP_BY_DEFAULT -> false
|
||||||
FLIPPED_DEFAULT -> true
|
HMPP_BY_DEFAULT -> true
|
||||||
}
|
}
|
||||||
assertEquals(shouldHaveJvmAndJsMainEntries, hasJvmAndJsMainEntries)
|
assertEquals(shouldHaveJvmAndJsMainEntries, hasJvmAndJsMainEntries)
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-14
@@ -14,7 +14,7 @@ import org.junit.runners.Parameterized
|
|||||||
@RunWith(Parameterized::class)
|
@RunWith(Parameterized::class)
|
||||||
internal class MppFlagsMigrationIT : BaseGradleIT() {
|
internal class MppFlagsMigrationIT : BaseGradleIT() {
|
||||||
internal data class TestCase(
|
internal data class TestCase(
|
||||||
var hierarchiesByDefault: Boolean = false,
|
var hierarchiesByDefault: Boolean? = null,
|
||||||
var hierarchiesSupportFlag: Boolean? = null,
|
var hierarchiesSupportFlag: Boolean? = null,
|
||||||
var granularMetadataFlag: Boolean? = null,
|
var granularMetadataFlag: Boolean? = null,
|
||||||
var dependencyPropagationFlag: Boolean? = null,
|
var dependencyPropagationFlag: Boolean? = null,
|
||||||
@@ -37,52 +37,44 @@ internal class MppFlagsMigrationIT : BaseGradleIT() {
|
|||||||
@OptIn(ExperimentalStdlibApi::class)
|
@OptIn(ExperimentalStdlibApi::class)
|
||||||
private val testCases = buildList {
|
private val testCases = buildList {
|
||||||
add(TestCase {
|
add(TestCase {
|
||||||
hierarchiesByDefault = true
|
|
||||||
granularMetadataFlag = null
|
granularMetadataFlag = null
|
||||||
dependencyPropagationFlag = null
|
dependencyPropagationFlag = null
|
||||||
expectedToPass = true
|
expectedToPass = true
|
||||||
notExpectedPhraseInOutput = "It is safe to remove the property."
|
notExpectedPhraseInOutput = "It is safe to remove the property."
|
||||||
})
|
})
|
||||||
add(TestCase {
|
add(TestCase {
|
||||||
hierarchiesByDefault = true
|
|
||||||
granularMetadataFlag = true
|
granularMetadataFlag = true
|
||||||
expectedToPass = true
|
expectedToPass = true
|
||||||
expectedPhraseInOutput = "It is safe to remove the property."
|
expectedPhraseInOutput = "It is safe to remove the property."
|
||||||
})
|
})
|
||||||
add(TestCase {
|
add(TestCase {
|
||||||
hierarchiesByDefault = true
|
|
||||||
granularMetadataFlag = false
|
granularMetadataFlag = false
|
||||||
expectedToPass = false
|
expectedToPass = false
|
||||||
expectedPhraseInOutput = "Multiplatform Hierarchical Structures support is now enabled by default"
|
expectedPhraseInOutput = "Multiplatform Hierarchical Structures support is now enabled by default"
|
||||||
})
|
})
|
||||||
add(TestCase {
|
add(TestCase {
|
||||||
hierarchiesByDefault = true
|
|
||||||
dependencyPropagationFlag = false
|
dependencyPropagationFlag = false
|
||||||
expectedToPass = true
|
expectedToPass = true
|
||||||
expectedPhraseInOutput = "It is safe to remove the property"
|
expectedPhraseInOutput = "It is safe to remove the property"
|
||||||
})
|
})
|
||||||
add(TestCase {
|
add(TestCase {
|
||||||
hierarchiesByDefault = true
|
|
||||||
dependencyPropagationFlag = true
|
dependencyPropagationFlag = true
|
||||||
expectedToPass = false
|
expectedToPass = false
|
||||||
expectedPhraseInOutput = "Kotlin/Native dependencies commonization is now enabled by default"
|
expectedPhraseInOutput = "Kotlin/Native dependencies commonization is now enabled by default"
|
||||||
})
|
})
|
||||||
add(TestCase {
|
add(TestCase {
|
||||||
hierarchiesByDefault = true
|
|
||||||
hierarchiesSupportFlag = false
|
hierarchiesSupportFlag = false
|
||||||
granularMetadataFlag = true
|
granularMetadataFlag = true
|
||||||
expectedToPass = false
|
expectedToPass = false
|
||||||
expectedPhraseInOutput = "Conflicting properties"
|
expectedPhraseInOutput = "Conflicting properties"
|
||||||
})
|
})
|
||||||
add(TestCase {
|
add(TestCase {
|
||||||
hierarchiesByDefault = true
|
|
||||||
hierarchiesSupportFlag = false
|
hierarchiesSupportFlag = false
|
||||||
granularMetadataFlag = false
|
granularMetadataFlag = false
|
||||||
expectedToPass = true
|
expectedToPass = true
|
||||||
expectedPhraseInOutput = "is redundant"
|
expectedPhraseInOutput = "is redundant"
|
||||||
})
|
})
|
||||||
add(TestCase {
|
add(TestCase {
|
||||||
hierarchiesByDefault = true
|
|
||||||
hierarchiesSupportFlag = false
|
hierarchiesSupportFlag = false
|
||||||
dependencyPropagationFlag = false
|
dependencyPropagationFlag = false
|
||||||
expectedToPass = false
|
expectedToPass = false
|
||||||
@@ -95,10 +87,8 @@ internal class MppFlagsMigrationIT : BaseGradleIT() {
|
|||||||
expectedPhraseInOutput = "not yet supported"
|
expectedPhraseInOutput = "not yet supported"
|
||||||
})
|
})
|
||||||
add(TestCase {
|
add(TestCase {
|
||||||
hierarchiesByDefault = false
|
|
||||||
hierarchiesSupportFlag = true
|
hierarchiesSupportFlag = true
|
||||||
expectedToPass = false
|
expectedToPass = true
|
||||||
expectedPhraseInOutput = "not yet supported"
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,8 +116,8 @@ internal class MppFlagsMigrationIT : BaseGradleIT() {
|
|||||||
fun doTest() {
|
fun doTest() {
|
||||||
val args = buildList {
|
val args = buildList {
|
||||||
with(testCase) {
|
with(testCase) {
|
||||||
if (hierarchiesByDefault)
|
if (hierarchiesByDefault == false)
|
||||||
add("-Pkotlin.internal.mpp.hierarchicalStructureByDefault=true")
|
add("-Pkotlin.internal.mpp.hierarchicalStructureByDefault=false")
|
||||||
if (hierarchiesSupportFlag != null)
|
if (hierarchiesSupportFlag != null)
|
||||||
add("-Pkotlin.mpp.hierarchicalStructureSupport=$hierarchiesSupportFlag")
|
add("-Pkotlin.mpp.hierarchicalStructureSupport=$hierarchiesSupportFlag")
|
||||||
if (granularMetadataFlag != null)
|
if (granularMetadataFlag != null)
|
||||||
|
|||||||
+107
-42
@@ -45,35 +45,89 @@ class NewMultiplatformIT : BaseGradleIT() {
|
|||||||
private fun Project.targetClassesDir(targetName: String, sourceSetName: String = "main") =
|
private fun Project.targetClassesDir(targetName: String, sourceSetName: String = "main") =
|
||||||
classesDir(sourceSet = "$targetName/$sourceSetName")
|
classesDir(sourceSet = "$targetName/$sourceSetName")
|
||||||
|
|
||||||
|
private data class HmppFlags(
|
||||||
|
val hmppSupport: Boolean,
|
||||||
|
val enableCompatibilityMetadataArtifact: Boolean,
|
||||||
|
val name: String
|
||||||
|
) {
|
||||||
|
override fun toString() = name
|
||||||
|
}
|
||||||
|
|
||||||
|
private val noHMPP = HmppFlags(
|
||||||
|
name = "No HMPP",
|
||||||
|
hmppSupport = false,
|
||||||
|
enableCompatibilityMetadataArtifact = 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
|
||||||
|
)
|
||||||
|
|
||||||
|
private val HmppFlags.buildOptions get() = defaultBuildOptions().copy(
|
||||||
|
hierarchicalMPPStructureSupport = hmppSupport,
|
||||||
|
enableCompatibilityMetadataVariant = enableCompatibilityMetadataArtifact,
|
||||||
|
)
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testLibAndApp() = doTestLibAndApp(
|
fun testLibAndApp() = doTestLibAndApp(
|
||||||
"sample-lib",
|
"sample-lib",
|
||||||
"sample-app"
|
"sample-app",
|
||||||
|
hmppWoCompatibilityMetadataArtifact
|
||||||
|
)
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testLibAndAppWithoutHMPP() = doTestLibAndApp(
|
||||||
|
"sample-lib",
|
||||||
|
"sample-app",
|
||||||
|
noHMPP
|
||||||
|
)
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testLibAndAppWithCompatibilityArtifact() = doTestLibAndApp(
|
||||||
|
"sample-lib",
|
||||||
|
"sample-app",
|
||||||
|
hmppWithCompatibilityMetadataArtifact
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testLibAndAppWithGradleKotlinDsl() = doTestLibAndApp(
|
fun testLibAndAppWithGradleKotlinDsl() = doTestLibAndApp(
|
||||||
"sample-lib-gradle-kotlin-dsl",
|
"sample-lib-gradle-kotlin-dsl",
|
||||||
"sample-app-gradle-kotlin-dsl"
|
"sample-app-gradle-kotlin-dsl",
|
||||||
|
hmppWoCompatibilityMetadataArtifact
|
||||||
)
|
)
|
||||||
|
|
||||||
private fun doTestLibAndApp(
|
private fun doTestLibAndApp(
|
||||||
libProjectName: String,
|
libProjectName: String,
|
||||||
appProjectName: String
|
appProjectName: String,
|
||||||
|
hmppFlags: HmppFlags,
|
||||||
) {
|
) {
|
||||||
val libProject = transformNativeTestProjectWithPluginDsl(libProjectName, directoryPrefix = "new-mpp-lib-and-app")
|
val libProject = transformNativeTestProjectWithPluginDsl(libProjectName, directoryPrefix = "new-mpp-lib-and-app")
|
||||||
val appProject = transformNativeTestProjectWithPluginDsl(appProjectName, 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 oldStyleAppProject = Project("sample-old-style-app", directoryPrefix = "new-mpp-lib-and-app")
|
||||||
|
|
||||||
|
val buildOptions = hmppFlags.buildOptions
|
||||||
val compileTasksNames =
|
val compileTasksNames =
|
||||||
listOf("Jvm6", "NodeJs", "Metadata", "Linux64").map { ":compileKotlin$it" }
|
listOf("Jvm6", "NodeJs", "Linux64").map { ":compileKotlin$it" }
|
||||||
|
|
||||||
with(libProject) {
|
with(libProject) {
|
||||||
build(
|
build(
|
||||||
"publish"
|
"publish",
|
||||||
|
options = buildOptions
|
||||||
) {
|
) {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
assertTasksExecuted(*compileTasksNames.toTypedArray(), ":jvm6Jar", ":nodeJsJar", ":metadataJar")
|
assertTasksExecuted(*compileTasksNames.toTypedArray(), ":jvm6Jar", ":nodeJsJar", ":compileCommonMainKotlinMetadata")
|
||||||
|
|
||||||
|
if (hmppFlags.enableCompatibilityMetadataArtifact) {
|
||||||
|
assertTasksExecuted(":compileKotlinMetadata", ":metadataJar")
|
||||||
|
}
|
||||||
|
|
||||||
val groupDir = projectDir.resolve("repo/com/example")
|
val groupDir = projectDir.resolve("repo/com/example")
|
||||||
val jvmJarName = "sample-lib-jvm6/1.0/sample-lib-jvm6-1.0.jar"
|
val jvmJarName = "sample-lib-jvm6/1.0/sample-lib-jvm6-1.0.jar"
|
||||||
@@ -113,7 +167,8 @@ class NewMultiplatformIT : BaseGradleIT() {
|
|||||||
Assert.assertTrue("function main(" in compiledJs)
|
Assert.assertTrue("function main(" in compiledJs)
|
||||||
|
|
||||||
val metadataJarEntries = ZipFile(groupDir.resolve(metadataJarName)).entries().asSequence().map { it.name }.toSet()
|
val metadataJarEntries = ZipFile(groupDir.resolve(metadataJarName)).entries().asSequence().map { it.name }.toSet()
|
||||||
Assert.assertTrue("com/example/lib/CommonKt.kotlin_metadata" in metadataJarEntries)
|
val metadataFileFound = "com/example/lib/CommonKt.kotlin_metadata" in metadataJarEntries
|
||||||
|
Assert.assertEquals(hmppFlags.enableCompatibilityMetadataArtifact, metadataFileFound)
|
||||||
|
|
||||||
Assert.assertTrue(groupDir.resolve(nativeKlibName).exists())
|
Assert.assertTrue(groupDir.resolve(nativeKlibName).exists())
|
||||||
}
|
}
|
||||||
@@ -142,8 +197,10 @@ class NewMultiplatformIT : BaseGradleIT() {
|
|||||||
Assert.assertTrue(resolve("com/example/app/Jdk8ApiUsageKt.class").exists())
|
Assert.assertTrue(resolve("com/example/app/Jdk8ApiUsageKt.class").exists())
|
||||||
}
|
}
|
||||||
|
|
||||||
projectDir.resolve(targetClassesDir("metadata")).run {
|
if (hmppFlags.enableCompatibilityMetadataArtifact) {
|
||||||
Assert.assertTrue(resolve("com/example/app/AKt.kotlin_metadata").exists())
|
projectDir.resolve(targetClassesDir("metadata")).run {
|
||||||
|
Assert.assertTrue(resolve("com/example/app/AKt.kotlin_metadata").exists())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
projectDir.resolve(targetClassesDir("nodeJs")).resolve("sample-app.js").readText().run {
|
projectDir.resolve(targetClassesDir("nodeJs")).resolve("sample-app.js").readText().run {
|
||||||
@@ -162,7 +219,8 @@ class NewMultiplatformIT : BaseGradleIT() {
|
|||||||
|
|
||||||
build(
|
build(
|
||||||
"assemble",
|
"assemble",
|
||||||
"resolveRuntimeDependencies"
|
"resolveRuntimeDependencies",
|
||||||
|
options = buildOptions
|
||||||
) {
|
) {
|
||||||
checkAppBuild()
|
checkAppBuild()
|
||||||
assertTasksExecuted(":resolveRuntimeDependencies") // KT-26301
|
assertTasksExecuted(":resolveRuntimeDependencies") // KT-26301
|
||||||
@@ -183,27 +241,30 @@ class NewMultiplatformIT : BaseGradleIT() {
|
|||||||
build(
|
build(
|
||||||
"clean",
|
"clean",
|
||||||
"assemble",
|
"assemble",
|
||||||
"--rerun-tasks"
|
"--rerun-tasks",
|
||||||
|
options = buildOptions
|
||||||
) {
|
) {
|
||||||
checkAppBuild()
|
checkAppBuild()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
with(oldStyleAppProject) {
|
if (hmppFlags.enableCompatibilityMetadataArtifact) {
|
||||||
setupWorkingDir()
|
with(oldStyleAppProject) {
|
||||||
gradleBuildScript().appendText("\nallprojects { repositories { maven { url '$libLocalRepoUri' } } }")
|
setupWorkingDir()
|
||||||
|
gradleBuildScript().appendText("\nallprojects { repositories { maven { url '$libLocalRepoUri' } } }")
|
||||||
|
|
||||||
build("assemble") {
|
build("assemble", options = buildOptions) {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
assertTasksExecuted(":app-js:compileKotlin2Js", ":app-jvm:compileKotlin", ":app-common:compileKotlinCommon")
|
assertTasksExecuted(":app-js:compileKotlin2Js", ":app-jvm:compileKotlin", ":app-common:compileKotlinCommon")
|
||||||
|
|
||||||
assertFileExists(kotlinClassesDir("app-common") + "com/example/app/CommonAppKt.kotlin_metadata")
|
assertFileExists(kotlinClassesDir("app-common") + "com/example/app/CommonAppKt.kotlin_metadata")
|
||||||
|
|
||||||
val jvmClassFile = projectDir.resolve(kotlinClassesDir("app-jvm") + "com/example/app/JvmAppKt.class")
|
val jvmClassFile = projectDir.resolve(kotlinClassesDir("app-jvm") + "com/example/app/JvmAppKt.class")
|
||||||
checkBytecodeContains(jvmClassFile, "CommonKt.id", "MainKt.expectedFun")
|
checkBytecodeContains(jvmClassFile, "CommonKt.id", "MainKt.expectedFun")
|
||||||
|
|
||||||
val jsCompiledFilePath = kotlinClassesDir("app-js") + "app-js.js"
|
val jsCompiledFilePath = kotlinClassesDir("app-js") + "app-js.js"
|
||||||
assertFileContains(jsCompiledFilePath, "lib.expectedFun", "lib.id")
|
assertFileContains(jsCompiledFilePath, "lib.expectedFun", "lib.id")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -268,7 +329,6 @@ class NewMultiplatformIT : BaseGradleIT() {
|
|||||||
"NodeJs${IR.lowerName.capitalize()}",
|
"NodeJs${IR.lowerName.capitalize()}",
|
||||||
)
|
)
|
||||||
}),
|
}),
|
||||||
"Metadata"
|
|
||||||
).map { ":compileKotlin$it" }
|
).map { ":compileKotlin$it" }
|
||||||
|
|
||||||
with(libProject) {
|
with(libProject) {
|
||||||
@@ -277,7 +337,8 @@ class NewMultiplatformIT : BaseGradleIT() {
|
|||||||
options = defaultBuildOptions().copy(jsCompilerType = jsCompilerType)
|
options = defaultBuildOptions().copy(jsCompilerType = jsCompilerType)
|
||||||
) {
|
) {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
assertTasksExecuted(*compileTasksNames.toTypedArray(), ":metadataJar")
|
assertTasksSkipped(":compileCommonMainKotlinMetadata")
|
||||||
|
assertTasksExecuted(*compileTasksNames.toTypedArray(), ":allMetadataJar")
|
||||||
|
|
||||||
val groupDir = projectDir.resolve("repo/com/example")
|
val groupDir = projectDir.resolve("repo/com/example")
|
||||||
val jsExtension = if (jsCompilerType == LEGACY) "jar" else "klib"
|
val jsExtension = if (jsCompilerType == LEGACY) "jar" else "klib"
|
||||||
@@ -317,9 +378,6 @@ class NewMultiplatformIT : BaseGradleIT() {
|
|||||||
}
|
}
|
||||||
BOTH -> {}
|
BOTH -> {}
|
||||||
}
|
}
|
||||||
|
|
||||||
val metadataJarEntries = ZipFile(groupDir.resolve(metadataJarName)).entries().asSequence().map { it.name }.toSet()
|
|
||||||
Assert.assertTrue("com/example/lib/CommonKt.kotlin_metadata" in metadataJarEntries)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -336,17 +394,10 @@ class NewMultiplatformIT : BaseGradleIT() {
|
|||||||
val compileTaskNames = if (jsCompilerType == compilerType) {
|
val compileTaskNames = if (jsCompilerType == compilerType) {
|
||||||
compileTasksNames.toTypedArray()
|
compileTasksNames.toTypedArray()
|
||||||
} else {
|
} else {
|
||||||
arrayOf(
|
arrayOf(":compileKotlinNodeJs")
|
||||||
":compileKotlinNodeJs",
|
|
||||||
":compileKotlinMetadata"
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
assertTasksExecuted(*compileTaskNames)
|
assertTasksExecuted(*compileTaskNames)
|
||||||
|
|
||||||
projectDir.resolve(targetClassesDir("metadata")).run {
|
|
||||||
Assert.assertTrue(resolve("com/example/app/AKt.kotlin_metadata").exists())
|
|
||||||
}
|
|
||||||
|
|
||||||
if (jsCompilerType == LEGACY) {
|
if (jsCompilerType == LEGACY) {
|
||||||
projectDir.resolve(targetClassesDir("nodeJs")).resolve("sample-app.js").readText().run {
|
projectDir.resolve(targetClassesDir("nodeJs")).resolve("sample-app.js").readText().run {
|
||||||
Assert.assertTrue(contains("console.info"))
|
Assert.assertTrue(contains("console.info"))
|
||||||
@@ -715,7 +766,7 @@ class NewMultiplatformIT : BaseGradleIT() {
|
|||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
)
|
)
|
||||||
|
|
||||||
listOf("compileKotlinMetadata", "compileKotlinJvm6", "compileKotlinNodeJs").forEach {
|
listOf("compileCommonMainKotlinMetadata", "compileKotlinJvm6", "compileKotlinNodeJs").forEach {
|
||||||
build(it) {
|
build(it) {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
assertTasksExecuted(":$it")
|
assertTasksExecuted(":$it")
|
||||||
@@ -743,7 +794,7 @@ class NewMultiplatformIT : BaseGradleIT() {
|
|||||||
)
|
)
|
||||||
|
|
||||||
listOf(
|
listOf(
|
||||||
"compileKotlinMetadata", "compileKotlinJvm6", "compileKotlinNodeJs", "compileKotlinLinux64"
|
"compileCommonMainKotlinMetadata", "compileKotlinJvm6", "compileKotlinNodeJs", "compileKotlinLinux64"
|
||||||
).forEach {
|
).forEach {
|
||||||
build(it) {
|
build(it) {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
@@ -768,7 +819,7 @@ class NewMultiplatformIT : BaseGradleIT() {
|
|||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
)
|
)
|
||||||
|
|
||||||
listOf("compileKotlinMetadata", "compileKotlinJvm6", "compileKotlinNodeJs").forEach {
|
listOf("compileCommonMainKotlinMetadata", "compileKotlinJvm6", "compileKotlinNodeJs").forEach {
|
||||||
build(it) {
|
build(it) {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
assertTasksExecuted(":$it")
|
assertTasksExecuted(":$it")
|
||||||
@@ -909,13 +960,26 @@ class NewMultiplatformIT : BaseGradleIT() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testResolveJsPartOfMppLibDependencyToMetadata() {
|
fun testResolveJsPartOfMppLibDependencyToMetadataWithHmpp() =
|
||||||
|
testResolveJsPartOfMppLibDependencyToMetadata(hmppWoCompatibilityMetadataArtifact)
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testResolveJsPartOfMppLibDependencyToMetadataWithHmppAndCompatibilityMetadataArtifact() =
|
||||||
|
testResolveJsPartOfMppLibDependencyToMetadata(hmppWithCompatibilityMetadataArtifact)
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testResolveJsPartOfMppLibDependencyToMetadataWithoutHmpp() =
|
||||||
|
testResolveJsPartOfMppLibDependencyToMetadata(noHMPP)
|
||||||
|
|
||||||
|
|
||||||
|
private fun testResolveJsPartOfMppLibDependencyToMetadata(hmppFlags: HmppFlags) {
|
||||||
val libProject = Project("sample-lib", gradleVersion, "new-mpp-lib-and-app")
|
val libProject = Project("sample-lib", gradleVersion, "new-mpp-lib-and-app")
|
||||||
val appProject = Project("sample-app", gradleVersion, "new-mpp-lib-and-app")
|
val appProject = Project("sample-app", gradleVersion, "new-mpp-lib-and-app")
|
||||||
|
|
||||||
|
val buildOptions = hmppFlags.buildOptions
|
||||||
libProject.build(
|
libProject.build(
|
||||||
"publish",
|
"publish",
|
||||||
options = defaultBuildOptions().copy(jsCompilerType = BOTH)
|
options = buildOptions.copy(jsCompilerType = BOTH)
|
||||||
) {
|
) {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
}
|
}
|
||||||
@@ -957,7 +1021,7 @@ class NewMultiplatformIT : BaseGradleIT() {
|
|||||||
|
|
||||||
build(
|
build(
|
||||||
"printMetadataFiles",
|
"printMetadataFiles",
|
||||||
options = defaultBuildOptions().copy(jsCompilerType = IR)
|
options = buildOptions.copy(jsCompilerType = IR)
|
||||||
) {
|
) {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
|
|
||||||
@@ -1036,7 +1100,8 @@ class NewMultiplatformIT : BaseGradleIT() {
|
|||||||
fun testNonMppConsumersOfLibraryPublishedWithNoMetadataOptIn() {
|
fun testNonMppConsumersOfLibraryPublishedWithNoMetadataOptIn() {
|
||||||
val repoDir = with(transformNativeTestProject("sample-lib", gradleVersion, "new-mpp-lib-and-app")) {
|
val repoDir = with(transformNativeTestProject("sample-lib", gradleVersion, "new-mpp-lib-and-app")) {
|
||||||
build(
|
build(
|
||||||
"publish"
|
"publish",
|
||||||
|
options = hmppWithCompatibilityMetadataArtifact.buildOptions
|
||||||
) { assertSuccessful() }
|
) { assertSuccessful() }
|
||||||
projectDir.resolve("repo")
|
projectDir.resolve("repo")
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
kotlin.mpp.enableGranularSourceSetsMetadata=true
|
kotlin.mpp.enableCompatibilityMetadataVariant=true
|
||||||
-1
@@ -1,2 +1 @@
|
|||||||
kotlin.mpp.enableGranularSourceSetsMetadata=true
|
|
||||||
kotlin.mpp.enableCompatibilityMetadataVariant=true
|
kotlin.mpp.enableCompatibilityMetadataVariant=true
|
||||||
-2
@@ -1,2 +0,0 @@
|
|||||||
kotlin.mpp.enableGranularSourceSetsMetadata=true
|
|
||||||
kotlin.mpp.enableCompatibilityMetadataVariant=true
|
|
||||||
Reference in New Issue
Block a user