From fa06965ed6d5ed43cedb0878ac01c3e2aec75795 Mon Sep 17 00:00:00 2001 From: Alexey Sedunov Date: Tue, 14 Mar 2017 18:39:04 +0300 Subject: [PATCH] Kotlin Facet: Add import test for Maven project with submodule --- .../idea/maven/KotlinMavenImporterTest.kt | 252 +++++++++++++++++- 1 file changed, 251 insertions(+), 1 deletion(-) diff --git a/idea/idea-maven/test/org/jetbrains/kotlin/idea/maven/KotlinMavenImporterTest.kt b/idea/idea-maven/test/org/jetbrains/kotlin/idea/maven/KotlinMavenImporterTest.kt index f26642d7704..06c2b172eac 100644 --- a/idea/idea-maven/test/org/jetbrains/kotlin/idea/maven/KotlinMavenImporterTest.kt +++ b/idea/idea-maven/test/org/jetbrains/kotlin/idea/maven/KotlinMavenImporterTest.kt @@ -1352,10 +1352,260 @@ class KotlinMavenImporterTest : MavenImportingTestCase() { } } + fun testSubmoduleArgsInheritance() { + createProjectSubDirs("src/main/kotlin", "myModule1/src/main/kotlin", "myModule2/src/main/kotlin", "myModule3/src/main/kotlin") + + val mainPom = createProjectPom(""" + test + project + 1.0.0 + pom + + + + org.jetbrains.kotlin + kotlin-stdlib + $kotlinVersion + + + + + src/main/kotlin + + + + org.jetbrains.kotlin + kotlin-maven-plugin + + + + compile + compile + + compile + + + + + 1.7 + temp + 1.1 + 1.0 + + -java-parameters + -Xdump-declarations-to + dumpDir + + + + + + """) + + val modulePom1 = createModulePom( + "myModule1", + """ + + + test + project + 1.0.0 + + + test + myModule1 + 1.0.0 + + + + org.jetbrains.kotlin + kotlin-stdlib + $kotlinVersion + + + + + myModule1/src/main/kotlin + + + + org.jetbrains.kotlin + kotlin-maven-plugin + + + + compile + compile + + compile + + + + + + 1.8 + + -Xdump-declarations-to + dumpDir2 + + + + + + """ + ) + + val modulePom2 = createModulePom( + "myModule2", + """ + + + test + project + 1.0.0 + + + test + myModule2 + 1.0.0 + + + + org.jetbrains.kotlin + kotlin-stdlib + $kotlinVersion + + + + + myModule2/src/main/kotlin + + + + org.jetbrains.kotlin + kotlin-maven-plugin + + + + compile + compile + + compile + + + + + + 1.8 + + -jdk-home + temp2 + + + + + + """ + ) + + val modulePom3 = createModulePom( + "myModule3", + """ + + + test + project + 1.0.0 + + + test + myModule3 + 1.0.0 + + + + org.jetbrains.kotlin + kotlin-stdlib + $kotlinVersion + + + + + myModule3/src/main/kotlin + + + + org.jetbrains.kotlin + kotlin-maven-plugin + + + + compile + compile + + compile + + + + + + 1.8 + + -jdk-home + temp2 + + + + + + """ + ) + + importProjects(mainPom, modulePom1, modulePom2, modulePom3) + + assertModules("project", "myModule1", "myModule2", "myModule3") + assertImporterStatePresent() + + with (facetSettings("myModule1")) { + Assert.assertEquals("JVM 1.8", targetPlatformKind!!.description) + Assert.assertEquals("1.1", languageLevel!!.description) + Assert.assertEquals("1.0", apiLevel!!.description) + Assert.assertEquals("1.8", (compilerArguments as K2JVMCompilerArguments).jvmTarget) + Assert.assertEquals( + listOf("-jdk-home", "temp", "-Xdump-declarations-to", "dumpDir2"), + compilerSettings!!.additionalArgumentsAsList + ) + } + + with (facetSettings("myModule2")) { + Assert.assertEquals("JVM 1.8", targetPlatformKind!!.description) + Assert.assertEquals("1.1", languageLevel!!.description) + Assert.assertEquals("1.0", apiLevel!!.description) + Assert.assertEquals("1.8", (compilerArguments as K2JVMCompilerArguments).jvmTarget) + Assert.assertEquals( + listOf("-jdk-home", "temp2", "-java-parameters", "-Xdump-declarations-to", "dumpDir"), + compilerSettings!!.additionalArgumentsAsList + ) + } + + with (facetSettings("myModule3")) { + Assert.assertEquals("JVM 1.8", targetPlatformKind!!.description) + Assert.assertEquals("1.1", languageLevel!!.description) + Assert.assertEquals("1.1", apiLevel!!.description) + Assert.assertEquals("1.8", (compilerArguments as K2JVMCompilerArguments).jvmTarget) + Assert.assertEquals( + listOf("-jdk-home", "temp2"), + compilerSettings!!.additionalArgumentsAsList + ) + } + } + private fun assertImporterStatePresent() { assertNotNull("Kotlin importer component is not present", myTestFixture.module.getComponent(KotlinImporterComponent::class.java)) } + private fun facetSettings(moduleName: String) = KotlinFacet.get(getModule(moduleName))!!.configuration.settings + private val facetSettings: KotlinFacetSettings - get() = KotlinFacet.get(getModule("project"))!!.configuration.settings + get() = facetSettings("project") } \ No newline at end of file