Maven Plugin的@Mojo和@Execute的具体使用
作者:sabersword 时间:2021-12-19 05:23:17
本文以spring-boot-maven-plugin 2.5.4为例
@Mojo defaultPhase
以spring-boot-maven-plugin:start为例, 他的@Mojo defaultPhase是PRE_INTEGRATION_TEST,该目标默认绑定到此阶段.
@Mojo(name = "start", requiresProject = true, defaultPhase = LifecyclePhase.PRE_INTEGRATION_TEST,
requiresDependencyResolution = ResolutionScope.TEST)
public class StartMojo extends AbstractRunMojo {
}
在pom中,我们只需要指定goal,就会在PRE_INTEGRATION_TEST阶段执行
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<id>start</id>
<goals>
<goal>start</goal>
</goals>
<!--如果额外指定phase=verify,会忽略defaultPhase,而在verify阶段执行-->
<phase>verify</phase>
</execution>
</executions>
@Execute phase
以spring-boot-maven-plugin:run为例,他的@Execute phase=TEST_COMPILE,在运行该目标前,让maven先运行一个并行的生命周期,到指定的阶段TEST_COMPLIE为止。到phase执行完,才执行插件目标
所以执行run,总是会运行到TEST_COMPLIE阶段
@Mojo(name = "run", requiresProject = true, defaultPhase = LifecyclePhase.VALIDATE,
requiresDependencyResolution = ResolutionScope.TEST)
@Execute(phase = LifecyclePhase.TEST_COMPILE)
public class RunMojo extends AbstractRunMojo {
参考资料
maven官方
博客
来源:https://juejin.cn/post/7006505209052528648
标签:Maven,Plugin,@Mojo,@Execute
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
spring mvc中的@PathVariable获得请求url中的动态参数
2023-08-22 22:08:40
java实现图片写入高清字体及带边框的方法
2023-11-29 03:43:47
springmvc4+hibernate4分页查询功能实现
2021-08-16 02:28:08
![](https://img.aspxhome.com/file/2023/3/68733_0s.png)
springboot 定时任务@Scheduled实现解析
2023-11-10 16:18:24
java实现五子棋小游戏
2021-12-25 06:58:56
![](https://img.aspxhome.com/file/2023/0/63380_0s.jpg)
C语言编程C++动态内存分配示例讲解
2023-11-02 18:00:12
![](https://img.aspxhome.com/file/2023/5/105185_0s.png)
Java使用Math.random()结合蒙特卡洛方法计算pi值示例
2023-05-10 10:43:13
![](https://img.aspxhome.com/file/2023/6/60606_0s.jpg)
Java Socket实现多人聊天系统
2023-08-08 04:44:35
![](https://img.aspxhome.com/file/2023/2/65322_0s.jpg)
Java堆&优先级队列示例讲解(上)
2023-04-09 11:09:59
![](https://img.aspxhome.com/file/2023/6/64166_0s.jpg)
Mybatis配置解析看这一篇就够了
2023-05-15 22:42:12
![](https://img.aspxhome.com/file/2023/1/64551_0s.png)
Android 微信摇一摇功能实现详细介绍
2023-06-21 21:00:09
c#实现多线程局域网聊天系统
2022-12-01 23:34:25
Java通过PropertyDescriptor反射调用set和get方法
2023-10-11 19:34:17
java快速生成数据库文档详情
2023-11-10 05:25:20
![](https://img.aspxhome.com/file/2023/3/59363_0s.png)
Java为什么基本数据类型不需要进行创建对象?
2022-03-16 08:59:03
SpringBoot Redis用注释实现接口限流详解
2022-03-15 17:40:55
C语言头文件<string.h>函数详解
2023-07-01 18:59:34
![](https://img.aspxhome.com/file/2023/2/105162_0s.png)
SSM如何实现在Controller中添加事务管理
2023-11-29 07:23:18
Mybatis中 mapper-locations和@MapperScan的作用
2023-07-13 08:08:34
![](https://img.aspxhome.com/file/2023/0/57700_0s.png)
C++容器适配与栈的实现及dequeque和优先级详解
2023-11-02 12:57:52
![](https://img.aspxhome.com/file/2023/9/105179_0s.png)