java - Maven 在包含“-”时无法识别参数
问题描述
我试图在一个简单的 spring-boot 项目上测试这个maven 插件。但是我遇到了 mojo 参数的问题,当我使用包含“-”的参数和目标时,它似乎不起作用:
$ mvn clean install fabric8:build fabric8:resource \
> -Dfabric8.openshift.enableAutomaticTrigger=false \
> -Dfabric8.enricher.fmp-openshift-imageChangeTrigger.enrichAll=true
但是当我将这些参数作为系统属性放在项目的pom.xml
. 它们似乎被 maven 插件选中并按预期工作。我像这样将它添加到 pom 中:
<properties>
<fabric8.openshift.enableAutomaticTrigger>false</fabric8.openshift.enableAutomaticTrigger>
<fabric8.enricher.fmp-openshift-imageChangeTrigger.enrichAll>true</fabric8.enricher.fmp-openshift-imageChangeTrigger.enrichAll>
</properties>
我在这里很困惑。谁能告诉我为什么它在以前的情况下不起作用?是否有某种我们应该遵循的 mojo 参数命名约定?
解决方案
我建议您使用一种解决方法(在我看来比调试 maven 更快的解决方案):
<properties>
<f8.autoTrigger>your_default_here</f8.autoTrigger>
<f8.enrichAll>your_other_default_here<f8.enrichAll>
<fabric8.openshift.enableAutomaticTrigger>${f8.autoTrigger}</fabric8.openshift.enableAutomaticTrigger>
<fabric8.enricher.fmp-openshift-imageChangeTrigger.enrichAll>${f8.enrichAll}</fabric8.enricher.fmp-openshift-imageChangeTrigger.enrichAll>
</properties>
如果你想覆盖你的默认值,你可以调用 maven,如:
$ mvn clean install fabric8:build fabric8:resource \
> -Df8.autoTrigger=false \
> -Df8.enrichAll=true
它甚至更短:)
推荐阅读
- python - Python - ValueError:解包的值太多
- javascript - 如何在输入中显示单选按钮值
- python - 找到最大的偶数子树,python
- unity3d - 使用统一广告或 admob 或其他任何东西在我的游戏中显示我自己的广告或自定义广告
- laravel - 如果用户不想添加hasMany FormItems如何提交表单
- docker - 使用 env_file 在撰写文件中设置变量时发出警告
- c++ - C++ 将数组传递给函数并读取其成员
- javascript - 何时调用自定义元素的 setter?
- excel - Excel:根据单元格 B 输入自动覆盖单元格 A
- python - 识别值后如何显示列标题