为什么我的 Maven Mojo 在单独运行时可能会丢失其配置属性?
我在 jasmine-maven-plugin 我无法弄清楚。
欢迎您自己尝试一下,但要点是,当运行时:
mvn jasmine:test
在 pom.xml 中为插件配置的属性未在 Mojo bean 上设置。
经过检查,很明显 bean 上的每个属性都恢复到其默认值。但是,当您运行测试阶段本身( jasmine:test 绑定到)时,例如:
mvn test
它工作正常。
有什么想法吗? TestMojo 看起来像:
/**
* @component
* @goal test
* @phase test
* @execute lifecycle="jasmine-lifecycle" phase="process-test-resources"
*/
更新:现在我更困惑了。经过进一步阅读,这种行为似乎确实出乎意料,因为我看到缺少的配置是在插件下方的
元素中完成的,而不是在 < ;execution/>
,根据本文档 :
注意:标记内部的配置与外部的配置不同,因为它们不能从直接命令行调用中使用。相反,它们仅在调用它们所绑定的生命周期阶段时才应用。或者,如果您将配置部分移到执行部分之外,它将全局应用于插件的所有调用。
I've got an outstanding issue in jasmine-maven-plugin and I can't figure it out.
You're welcome to try this out yourself, but the gist is that when one runs:
mvn jasmine:test
The properties configured in the pom.xml for the plugin are not set on the Mojo bean.
Upon inspection it's pretty clear that each property on the bean is falling back on its default value. However, when you run the test phase itself (which jasmine:test is bound to), like:
mvn test
It works fine.
Any ideas? The preamble at the top of the TestMojo looks like:
/**
* @component
* @goal test
* @phase test
* @execute lifecycle="jasmine-lifecycle" phase="process-test-resources"
*/
Update: Now I'm even more confused. Upon further reading, it seems this behavior is really unexpected, since the configuration that I'm seeing as missing is done in a <configuration>
element right under the plugin, not under an <execution/>
, per this document:
Note: Configurations inside the tag differ from those that are outside in that they cannot be used from a direct command line invocation. Instead they are only applied when the lifecycle phase they are bound to are invoked. Alternatively, if you move a configuration section outside of the executions section, it will apply globally to all invocations of the plugin.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当然我是个白痴。我查看了错误的 POM,果然配置位于
块内。因此,我将尝试通过用大粗体字母回答我自己的问题来向 Google 提供信息:
当您从命令行调用 Maven 目标时,如果该配置是直接在下面进行的,它只会选取您的 pom.xml 的配置元素
元素,而不是任何
元素下。And of course I'm an idiot. I was looking at the wrong POM, and sure enough the configuration was inside an
<execution>
block.So I'll try to feed Google by answering my own question in big bold letters:
When you invoke a Maven goal from the command line, it will only pick up your pom.xml's configuration element if that configuration was made directly under the
<plugin/>
element, and not under any<execution/>
element.