阶段的 Plugin.xml 配置似乎不适用于我的自定义 Maven 插件
我第一次尝试编写 Maven 插件。我编写了一个简单的插件,其目标是将 hello world 消息写入输出。我还使用 @phase 注释创建到安装生命周期阶段的默认绑定。这在我的plugin.xml 中显示为我的mojo 元素的安装元素。
我的理解是,我现在可以简单地将其添加到我的 build.plugins 部分,而不指定任何执行,并且我的插件目标将在安装阶段执行。但这并没有发生。这是不会创建我的目标的任何执行的配置:
<build>
<plugins>
<plugin>
<groupId>com.emc.chad</groupId>
<artifactId>hello-plugin</artifactId>
<version>0.0.1-SNAPSHOT</version>
</plugin>
</plugins>
</build>
但是,如果我更改它以显式指定执行,它会起作用:
<plugin>
<groupId>com.emc.chad</groupId>
<artifactId>hello-plugin</artifactId>
<version>0.0.1-SNAPSHOT</version>
<executions>
<execution>
<id>test</id>
<phase>install</phase>
<goals>
<goal>hello</goal>
</goals>
<configuration>
</configuration>
</execution>
</executions>
</plugin>
我理解为什么这当然有效,但考虑到我的插件,第一个也不应该起作用.xml阶段规范?
I'm playing around with writing a maven plugin for the first time. I've written a simple plugin with a goal that writes a hello world message to the output. I've also used the @phase annotation to create a default binding to the install lifecycle phase. This shows up in my plugin.xml as install element of my mojo element.
My understanding is that I can now simply add this to my build.plugins section, without specifying any execution, and my plugin goal will execute during the install phase. This doesn't happen though. Here's the configuration that doesn't create any exeuction of my goal:
<build>
<plugins>
<plugin>
<groupId>com.emc.chad</groupId>
<artifactId>hello-plugin</artifactId>
<version>0.0.1-SNAPSHOT</version>
</plugin>
</plugins>
</build>
However, if I change this to specify an execution explicitly, it works:
<plugin>
<groupId>com.emc.chad</groupId>
<artifactId>hello-plugin</artifactId>
<version>0.0.1-SNAPSHOT</version>
<executions>
<execution>
<id>test</id>
<phase>install</phase>
<goals>
<goal>hello</goal>
</goals>
<configuration>
</configuration>
</execution>
</executions>
</plugin>
I understand why this works of course, but shouldn't the first work as well, considering my plugin.xml phase specification?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论