从命令行覆盖pom pluginManagement中定义的Maven插件配置

rus*_*tyx 17 java maven-2 maven maven-release-plugin

我的项目继承的POM包含一些指定一些额外<pluginManagement>release插件arguments.

我的问题是:arguments在这种情况下,有没有办法从命令行覆盖参数?

父POM有这个:

<pluginManagement>
    <plugin>
        <artifactId>maven-release-plugin</artifactId>
        <configuration>
            <arguments>-Prelease</arguments>
        </configuration>
    </plugin>
</pluginManagement>
Run Code Online (Sandbox Code Playgroud)

由于命令行参数不起作用:

mvn release:prepare -Darguments="-Pmock -Prelease"
Run Code Online (Sandbox Code Playgroud)

-Darguments="-Pmock -Prelease"部分没有效果.什么时候arguments没有指定,它的工作原理.

我无法修改父POM或不使用它.

rus*_*tyx 12

找到了解决方案.在我的 POM中,我添加了这个,它覆盖了 POM中的设置,并允许在命令行上指定其他参数,例如-Darguments=-Pmock

<pluginManagement>
    <plugin>
        <artifactId>maven-release-plugin</artifactId>
        <configuration>
            <arguments>${arguments} -Prelease</arguments>
        </configuration>
    </plugin>
</pluginManagement>
Run Code Online (Sandbox Code Playgroud)


Ste*_*ner 8

您无法覆盖已在POM中设置的配置(请参阅Maven Bug MNG-4979).您可以使用变量以避免此行为.你的答案的片段使用它.