Maven build lifecycle
Clean Lifecycle
运行mvn clean执行clean生命周期,包含三个生命周期阶段:
pre-cleancleanpost-clean
clean:clean会删除一次构建后的输出,默认删除_${basedir}/target/_目录(如果你没有自定义输出目录)。
执行clean阶段的时候,maven可以执行任何绑定到pre-clean阶段的_goal_(目标)。
例如:你想在pre-clean阶段时触发antrun:run_goal_来输出一个通知,或者想在构陷目录删除时,打包一下。
**Triggering a Goal on pre-clean. **
<project>
...
<build>
<plugins>... <plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>file-exists</id>
<phase>pre-clean</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echo>hello world</echo>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
我们还可以自定义clean插件的删除目录(即除了默认的目录,再删除别的目录)。可以配置fileSet配置项,该配置支持ant的通配符。
**Customizing Behavior of the Clean Plugin. **
<build>
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<configuration>
<filesets>
<fileset>
<directory>target-other</directory>
<includes>
<include>*.class</include>
</includes>
</fileset>
</filesets>
</configuration>
</plugin>
</plugins>
</build>
Default Lifecycle
maven的默认生命周期,有如下阶段:
| Lifecycle Phase | Description |
|---|---|
| validate | 验证项目的正确性和完成该构建的必要信息 |
| generate-sources | 生成包含在编译之中的源代码 |
| process-sources | 处理源码,如过滤某些值 |
| generate-resources | 生成资源文件,这些文件会包含到打包中 |
| process-resources | 将资源文件复制到目标目录,并处理,准备打包 |
| compile | 编译源码 |
| process-classes | 对生成的类文件后处理,如字节码增强 |
| generate-test-sources | 生成测试代码 |
| process-test-sources | 处理测试代码 |
| generate-test-resources | 生成测试用的资源文件 |
| process-test-resources | 复制资源文件到测试目录 |
| test-compile | 编译测试代码 |
| test | 测试 |
| prepare-package | 打包前的准备工作 |
| package | 打包,如JAR,WAR等 |
| pre-integration-test | 集成测试准备 |
| integration-test | 集成测试 |
| post-integration-test | 集成测试后的工作 |
| verify | 检查验证生成的java包 |
| install | 安装到本地仓库 |
| deploy | 部署到目标地址 |
Site Lifecycle
暂时用不到,不整理
Maven build lifecycle的更多相关文章
- Maven Build Life Cycle--reference
What is Build Lifecycle? A Build Lifecycle is a well defined sequence of phases which define the ord ...
- maven:log4j:WARN No appenders could be found for logger (loggerInfo).或者maven build error:org.apache.maven.lifecycle.LifecycleExecutionExceptio
maven在build构建时,加载资源文件时需要配置资源文件插件: 1,在pom.xml文件中加入 <build> <finalName>${project.build.tar ...
- Introduction to the Build Lifecycle
Introduction to the Build Lifecycle Table Of Contents Build Lifecycle Basics Setting Up Your Project ...
- 在eclipse如何删除无效的maven build
在Eclipse的maven项目中,点击一次“maven build...”明明没有配置,它也就会产生一个maven build,那么如何删除这些无效的配置呢?
- Maven Build Profiles--reference
What is Build Profile? A Build profile is a set of configuration values which can be used to set or ...
- No compiler is provided in this environment. --Maven build失败
今天,maven build 失败了, 遇到下面的问题 经过查找,通过这个大佬的blog( https://blog.csdn.net/lslk9898/article/details/738367 ...
- Spring Boot-右键maven build成功但是直接运行main方法出错的解决方案
1.代码就一个Controller,从官网复制过来的,如下 package com.springboot.controller; import org.springframework.boot.Spr ...
- 转:eclipse maven build、maven install 等区别
原文地址:eclipse maven build.maven install 等区别
- maven build的常用生命周期
常用的maven build goals: validate - validate the project is correct and all necessary information is av ...
随机推荐
- 【Win10 应用开发】自定义应用标题栏
Win 10 app对窗口标题栏的自定义包括两个层面:一是只定义标题中各部分的颜色,如标题栏上文本的颜色.三个系统按钮(最大化,最小化,关闭)的背景颜色等:另一层是把窗口的可视区域直接扩展到标题栏上, ...
- [C#] 走进异步编程的世界 - 剖析异步方法(上)
走进异步编程的世界 - 剖析异步方法(上) 序 这是上篇<走进异步编程的世界 - 开始接触 async/await 异步编程>(入门)的第二章内容,主要是与大家共同深入探讨下异步方法. 本 ...
- android官方下拉刷新控件SwipeRefreshLayout的使用
可能开发安卓的人大多数都用过很多下拉刷新的开源组件,但是今天用了官方v4支持包的SwipeRefreshLayout觉得效果也蛮不错的,特拿出来分享. 简介:SwipeRefreshLayout组件只 ...
- 现代3D图形编程学习-环境设置
本书系列 现代3D图形编程学习 环境设置 由于本书中的例子,均是基于OpenGL实现的,因此你的工作环境需要能够运行OpenGL,为了读者能够更好的运行原文中的示例,此处简单地介绍了linux和win ...
- HTML5-video标签-实现点击预览图播放或暂停视频
HTML5-video标签-实现点击预览图播放或暂停视频 刚刚参加工作,开始更多的接触到一些新的知识,促使我开始了解html5和css3的新特性.这时我才真的发现到html5和css3的强大. 之前关 ...
- 用SignalR 2.0开发客服系统[系列2:实现聊天室]
前言 交流群:195866844 上周发表了 用SignalR 2.0开发客服系统[系列1:实现群发通讯] 这篇文章,得到了很多帮助和鼓励,小弟在此真心的感谢大家的支持.. 这周继续系列2,实现聊天室 ...
- Javascript中关于cookie的那些事儿
Javascript-cookie 什么是cookie? 指某些网站为了辨别用户身份.进行session跟踪而储存在用户本地终端上的数据(通常经过加密).简单点来说就是:浏览器缓存. cookie由什 ...
- 一次页面从Jq到Vuejs+PartialView的迁徙
题外话 本篇分享不能帮助你入门vue,入门的文章也是无意义的,官方文档http://cn.vuejs.org/v2/guide/ 已经写的不能再清晰了.希望我们勇敢的主动地给自己创造实践的机会. 手里 ...
- Navisworks Api Tool
用Google 翻译的..做个参考 None 无有效的选择 Select 选择 SelectBox 选择框 RedlineFreehand 红线写意 RedlineLine 红线线 Redli ...
- Web Service概念梳理
计算机技术难理解的很多,Web Service 对我来说就是一个很难理解的概念:为了弄清它到底是什么,我花费了两周的时间,总算有了一些收获,参考了不少网上的资料,但有些概念说法不一.我以w3c和 一些 ...