[maven][IDEA-376875] fix maven pom files execution

(cherry picked from commit 66cf8bdc8d1754870df28edb8aa7159aef5298a0)

IJ-CR-172019

GitOrigin-RevId: 83b115e63c75a735fa56ebd64f9ea66b2ac9b52c
This commit is contained in:
Alexander Bubenchikov
2025-08-06 21:48:53 +02:00
committed by intellij-monorepo-bot
parent 6d0ea6aa20
commit c4fec909b5
3 changed files with 34 additions and 2 deletions

View File

@@ -268,6 +268,7 @@ class MavenShCommandLineState(val environment: ExecutionEnvironment, private val
addSettingParameters(args)
args.addAll(myConfiguration.runnerParameters.options)
args.addAll(myConfiguration.runnerParameters.goals)
myConfiguration.runnerParameters.pomFileName?.let { args.addAll("-f", it) }
return args
}

View File

@@ -133,6 +133,37 @@ class ScriptMavenExecutionTest : MavenExecutionTest() {
}
@Test
fun testShouldExecuteMavenScriptWithPomFile() = runBlocking {
createModulePom("m1",
"""
<parent>
<groupId>test</groupId>
<artifactId>project<</artifactId>
<version>1</version>
</parent>
<artifactId>m1</artifactId>
""".trimIndent())
importProjectAsync("""
<groupId>test</groupId>
<artifactId>project</artifactId>
<version>1</version>
<packaging>pom</packaging>
<modules>
<module>m1</module>
</modules>
"""
)
createFakeProjectWrapper()
mavenGeneralSettings.mavenHomeType = MavenWrapper
val executionInfo = execute(MavenRunnerParameters(true, projectPath.toCanonicalPath(), "m1", mutableListOf("verify"), emptyList()))
assertTrue("Should run wrapper", executionInfo.stdout.contains(wrapperOutput))
assertTrue("Should run build for specified pom", executionInfo.system.contains("-f m1"))
}
companion object {
const val wrapperOutput = "WRAPPER REPLACEMENT in Intellij tests"
}

View File

@@ -102,7 +102,7 @@ class MavenLifecyclePluginImportingTest : MavenCompilingTestCase() {
}.join()
val text = projectPath.resolve("parameters.wrapper.txt").readText().trimEnd()
assertTrue(text, text.endsWith("com.intellij.mavenplugin:maven-plugin-test-lifecycle:1.0:second"))
assertTrue(text, text.endsWith("com.intellij.mavenplugin:maven-plugin-test-lifecycle:1.0:second -f pom.xml"))
}
@Test
@@ -120,7 +120,7 @@ class MavenLifecyclePluginImportingTest : MavenCompilingTestCase() {
val createdFile = projectPath.resolve("parameters.wrapper.txt")
assertTrue(createdFile.isRegularFile())
val text = createdFile.readText().trimEnd()
assertTrue(text, text.endsWith("com.intellij.mavenplugin:maven-plugin-test-lifecycle:1.0:first"))
assertTrue(text, text.endsWith("com.intellij.mavenplugin:maven-plugin-test-lifecycle:1.0:first -f pom.xml"))
}
private fun setupProjectWithMavenLifecycle(goal: String) {