开发者

Why might my Maven Mojo lose its configuration properties when run individually?

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 mi开发者_开发知识库ssing 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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜