我有一个 Maven 插件,它在 POM 文件中配置为
<build>
<plugins>
<plugin>
<groupId>com.example</groupId>
<artifactId>example-maven-plugin</artifactId>
<configuration>
<scriptsPath>scripts</scriptsPath>
</configuration>
</plugin>
</plugins>
</build>
现在我想覆盖它scriptsPath
从命令行所以我运行
mvn -X example-maven-plugin:goal -DscriptsPath=scripts1
我可以看到的价值scriptsPath
还是scripts
并不是scripts1
。可以从命令行覆盖配置参数吗?
不幸的是,没有通用的方法可以使用属性来覆盖 Maven 插件配置。如果插件文档没有明确允许您使用属性来设置配置值,您可以使用以下模式:
<properties>
<scripts.path>scripts</scripts.path>
</properties>
<build>
<plugins>
<plugin>
<groupId>com.example</groupId>
<artifactId>example-maven-plugin</artifactId>
<configuration>
<scriptsPath>${scripts.path}</scriptsPath>
</configuration>
</plugin>
</plugins>
</build>
然后执行maven为
mvn -X example-maven-plugin:goal -Dscripts.path=scripts1
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)