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

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

问题描述:

我的项目继承的POM包含一些< pluginManagement> ,用于发布插件,它指定了一些额外的参数。

The POM that my project inherits contains some <pluginManagement> for the release plugin that specifies some additional arguments.

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

My question is: Is there a way to override the arguments parameter from the command line in this case?

父POM有这个:

<pluginManagement>
    <plugin>
        <artifactId>maven-release-plugin</artifactId>
        <configuration>
            <arguments>-Prelease</arguments>
        </configuration>
    </plugin>
</pluginManagement>

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

Due to that the command line argument doesn't work:

mvn release:prepare -Darguments="-Pmock -Prelease"

-Darguments = - Pmock -Please部分无效。当参数尚未指定时,它可以正常工作。

The -Darguments="-Pmock -Prelease" part has no effect. When arguments is not already specified, it works.

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

It is not possible for me to modify the parent POM or not to use it.

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

Found the solution. In my POM I add this which overrides the settings in the parent POM and allows to specify additional arguments on command line, e.g. -Darguments=-Pmock

<pluginManagement>
    <plugin>
        <artifactId>maven-release-plugin</artifactId>
        <configuration>
            <arguments>${arguments} -Prelease</arguments>
        </configuration>
    </plugin>
</pluginManagement>