Maven mojo插件,如何定义在此目标之前必须触发的阶段?
嘿, 我有一个部署 pojo 插件(将战争部署到远程服务器)。我在 pom 定义的构建部分中有远程部署插件,我需要在部署远程目标之前触发包阶段,因为在我将其安全复制到远程服务器之前,战争已经创建了。
通过执行元素(根据文档),我可以将我的目标附加到特定阶段,例如将其绑定到之后的阶段,所以在我的例子中,安装阶段......但这只是一种解决方法。
<build>
<plugins>
<plugin>
<groupId>sample.plugin</groupId>
<artifactId>maven-hello-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>sayhi</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
简而言之,如果我只将我的目标放入构建部分并运行它,则之前不会运行包阶段。请帮忙
hey,
I have a deploy pojo plugin (deploying a war to a remote server). I have the remote-deploy plugin in the build section of pom definition, I need package phase to be triggered before deploy-remote goal, for it the war be already created before I secure-copy it to a remote server.
With the execution elements (according to a documentation), I can attach my goal to a particular phase, for instance bind it to the phase after, so in my case, install phase ...but that's just a workaround.
<build>
<plugins>
<plugin>
<groupId>sample.plugin</groupId>
<artifactId>maven-hello-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>sayhi</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
simply put, if I place only my goal into the build section, and run it, package phase is not run before. Please help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你不能。
只需将其绑定到
package
阶段,默认情况下,您的目标将在目标绑定到package
后被调用(因此战争将会在那里)。下面是一个使用如下配置的 Maven AntRun 插件演示此行为的示例:
以及
mvn package
的输出:正如预期的那样,antrun 插件在
package
之后执行。You can't.
Just bind it to the
package
phase, your goal will be called after the goals bounds topackage
by default (so the war will be there).Here is an example demonstrating this behavior with the Maven AntRun plugin configured like this:
And the output of
mvn package
:The antrun plugin is executed after
package
, as expected.您可以尝试在 @Mojo 注释中使用 PREPARE_PACKAGE 阶段:
You can try use PREPARE_PACKAGE phase in your @Mojo annotation: