From c2de41bc55b10e36f79b0e3d2662e0c0ecbe4e65 Mon Sep 17 00:00:00 2001 From: Alexander Bubenchikov Date: Mon, 28 Apr 2025 14:29:59 +0200 Subject: [PATCH] [maven][IDEA-371747] import maven compiler args with weird names GitOrigin-RevId: b56453b894746b7a8500d01c1d4cdfe7c4d34d0d --- .../importing/MavenCompilerConfigurator.kt | 8 +++-- .../importing/MavenCompilerImportingTest.kt | 32 +++++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenCompilerConfigurator.kt b/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenCompilerConfigurator.kt index 21948ed97041..a3be2575f300 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenCompilerConfigurator.kt +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenCompilerConfigurator.kt @@ -311,12 +311,16 @@ class MavenCompilerConfigurator : MavenApplicableConfigurator(GROUP_ID, ARTIFACT } } } - MavenJDOMUtil.findChildrenValuesByPath(element, "compilerArgs", "arg").forEach { - val text = getResolvedText(it) + element.getChild("compilerArgs")?.children?.forEach { + val text = getResolvedText(it.text) if (text != null && !hasUnresolvedProperty(text)) { result.add(text) } } + + MavenJDOMUtil.findChildrenValuesByPath(element, "compilerArgs", "arg").forEach { + + } element.getChild("compilerArgument")?.textTrim?.let { val text = getResolvedText(it) if (text != null && !hasUnresolvedProperty(text)) { diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/MavenCompilerImportingTest.kt b/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/MavenCompilerImportingTest.kt index 36d78fa36c96..af48d8f37e25 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/MavenCompilerImportingTest.kt +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/MavenCompilerImportingTest.kt @@ -1214,4 +1214,36 @@ class MavenCompilerImportingTest : MavenMultiVersionImportingTestCase() { "--add-exports", "java.base/sun.reflect.annotation=ALL-UNNAMED", "--add-exports", "java.base/sun.nio.ch=ALL-UNNAMED") } + @Test + @TestFor(issues = ["IDEA-371747"]) + fun testCompilerArgumentsWithWeirdNames() = runBlocking { + importProjectAsync(""" + test + project + 1 + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.12.1 + + 17 + UTF-8 + 17 + + -blablabla + -qwerty + + + + + """.trimIndent()) + + assertModules("project") + assertOrderedElementsAreEqual(ideCompilerConfiguration.getAdditionalOptions(getModule("project")), + "-blablabla", "-qwerty") + + } + }