pom.xml中build标签
1.分类
(1)全局配置(project build)
针对整个项目的所有情况都有效
(2)配置(profile build)
针对不同的profile配置
- <project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
- http://maven.apache.org/maven-v4_0_0.xsd">
- …
- <!– "Project Build" contains more elements than just the BaseBuild set –>
- <build>…</build>
- <profiles>
- <profile>
- <!– "Profile Build" contains a subset of "Project Build"s elements –>
- <build>…</build>
- </profile>
- </profiles>
- </project>
2.配置说明
(1)基本元素
- <build>
- <defaultGoal>install</defaultGoal>
- <directory>${basedir}/target</directory>
- <finalName>${artifactId}-${version}</finalName>
- <filters>
- <filter>filters/filter1.properties</filter>
- </filters>
- ...
- </build>
1)defaultGoal
执行build任务时,如果没有指定目标,将使用的默认值。
如上配置:在命令行中执行mvn,则相当于执行mvn install
2)directory
build目标文件的存放目录,默认在${basedir}/target目录
3)finalName
build目标文件的名称,默认情况为${artifactId}-${version}
4)filter
定义*.properties文件,包含一个properties列表,该列表会应用到支持filter的resources中。
也就是说,定义在filter的文件中的name=value键值对,会在build时代替${name}值应用到resources中。
maven的默认filter文件夹为${basedir}/src/main/filters
(2)Resources配置
用于包含或者排除某些资源文件
- <build>
- ...
- <resources>
- <resource>
- <targetPath>META-INF/plexus</targetPath>
- <filtering>false</filtering>
- <directory>${basedir}/src/main/plexus</directory>
- <includes>
- <include>configuration.xml</include>
- </includes>
- <excludes>
- <exclude>**/*.properties</exclude>
- </excludes>
- </resource>
- </resources>
- <testResources>
- ...
- </testResources>
- ...
- </build>
1)resources
一个resources元素的列表。每一个都描述与项目关联的文件是什么和在哪里
2)targetPath
指定build后的resource存放的文件夹,默认是basedir。
通常被打包在jar中的resources的目标路径是META-INF
3)filtering
true/false,表示为这个resource,filter是否激活
4)directory
定义resource文件所在的文件夹,默认为${basedir}/src/main/resources
5)includes
指定哪些文件将被匹配,以*作为通配符
6)excludes
指定哪些文件将被忽略
7)testResources
定义和resource类似,只不过在test时使用
(3)plugins配置
用于指定使用的插件
- <build>
- ...
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <version>2.0</version>
- <extensions>false</extensions>
- <inherited>true</inherited>
- <configuration>
- <classifier>test</classifier>
- </configuration>
- <dependencies>...</dependencies>
- <executions>...</executions>
- </plugin>
- </plugins>
- </build>
1)GAV
指定插件的标准坐标
2)extensions
是否加载plugin的extensions,默认为false
3)inherited
true/false,这个plugin是否应用到该pom的孩子pom,默认为true
4)configuration
配置该plugin期望得到的properties
5)dependencies
作为plugin的依赖
6)executions
plugin可以有多个目标,每一个目标都可以有一个分开的配置,可以将一个plugin绑定到不同的阶段
假如绑定antrun:run目标到verify阶段
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <version>1.1</version>
- <executions>
- <execution>
- <id>echodir</id>
- <goals>
- <goal>run</goal>
- </goals>
- <phase>verify</phase>
- <inherited>false</inherited>
- <configuration>
- <tasks>
- <echo>Build Dir: ${project.build.directory}</echo>
- </tasks>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
id:标识,用于和其他execution区分。当这个阶段执行时,它将以这个形式展示[plugin:goal execution: id]。在这里为: [antrun:run execution: echodir]
goals:目标列表
phase:目标执行的阶段
inherit:子类pom是否继承
configuration:在指定目标下的配置
(4)pluginManagement配置
pluginManagement的配置和plugins的配置是一样的,只是用于继承,使得可以在孩子pom中使用。
父pom:
- <build>
- ...
- <pluginManagement>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <version>2.2</version>
- <executions>
- <execution>
- <id>pre-process-classes</id>
- <phase>compile</phase>
- <goals>
- <goal>jar</goal>
- </goals>
- <configuration>
- <classifier>pre-process</classifier>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </pluginManagement>
- ...
- </build>
则在子pom中,我们只需要配置:
- <build>
- ...
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- </plugin>
- </plugins>
- ...
- </build>
这样就大大简化了孩子pom的配置
pom.xml中build标签的更多相关文章
- maven项目pom.xml中parent标签的使用(转)
原文地址:https://blog.csdn.net/qq_41254677/article/details/81011681 使用maven是为了更好的帮项目管理包依赖,maven的核心就是pom. ...
- maven pom.xml 中各个标签元素的作用
<groupId> : 项目或者组织的唯一标识 <artifactId>项目的通用名称 <artifactId>项目的通用名称 <version> 项目 ...
- Java 在pom.xml中配置build resources, 来防止我们资源导出失败问题(Maven项目)
在pom.xml中配置build, 来防止我们资源导出失败问题 <!--在build中配置resources, 来防止我们资源导出失败问题--> <build> <res ...
- 刨析Maven(对pom.xml配置文件常用标签的解析)
昨天在阿里云看到了一句话,"当你Learning和Trying之后,如果能尽量把Teaching也做好,会促进我们思考".共勉! 这是关于Maven的第三篇博客,这次我们深入了解p ...
- eclipse中基于maven构建的web项目pom.xml中指定的jar包无法发布到tomcat中
eclipse运行maven web项目报错: 信息: Starting Servlet Engine: Apache Tomcat/7.0.57 一月 07, 2015 11:50:44 下午 or ...
- (转)如何在maven的pom.xml中添加本地jar包
1 maven本地仓库认识 maven本地仓库中的jar目录一般分为三层:图中的1 2 3分别如下所示: 1 groupId 2 artifactId 3 version 4 jar包的依赖 如果要将 ...
- 在maven pom.xml中加载不同的properties ,如localhost 和 dev master等jdbc.properties 中的链接不一样
[参考]:maven pom.xml加载不同properties配置[转] 首先 看看效果: 点开我们项目中的Maven projects 后,会发现右侧 我们profile有个可勾选选项.默认勾选l ...
- Maven pom.xml中的元素modules、parent、properties以及import
前言 项目中用到了maven,而且用到的内容不像利用maven/eclipse搭建ssm(spring+spring mvc+mybatis)用的那么简单:maven的核心是pom.xml,那么我就它 ...
- (转)如何在maven的pom.xml中添加本地jar包
转载自: https://www.cnblogs.com/lixuwu/p/5855031.html 1 maven本地仓库认识 maven本地仓库中的jar目录一般分为三层:图中的1 2 3分别如下 ...
随机推荐
- 功能的显著性分析——GO Enrichment Analysis
Gene Ontology(GO)是基因功能国际标准分类体系.GO富集分析是对差异基因等按GO分类,并对分类结果进行基于离散分布的显著性分析.错判率分析.富集度分析,得到与实验目的有显著联系的.低 ...
- Spring 无缝整合 quartz
关键步骤: 1. 配置 SchedulerFactoryBean <bean class="org.springframework.scheduling.quartz.Schedule ...
- 转:wcf大文件传输解决之道(2)
此篇文章主要是基于http协议应用于大文件传输中的应用,现在我们先解析下wcf中编码器的定义,编码器实现了类的编码,并负责将Message内存中消息转变为网络发送的字节流或者字节缓冲区(对于发送方而言 ...
- eos中BM与有BM特色的去中心化。区块链世界,白皮书为共识,代码为法律。
比特币挖矿是谁算力高,谁更容易挖到新的比特币,而BM认为这太浪费资源了,于是设计了DPoS:在DPoS系统里,大家不再挖矿.而是指定几个人负责记账,不叫矿工,而叫见证人.比特股里开始是101人,EOS ...
- SpringMVC MultiActionController 默认方法名解析器
MultiActionController默认方法名解析器是指在请求的地址中加入指定方法名称 MultiActionController类具有一个属性methodNameResolver,方法名解析器 ...
- mxnet下如何查看中间结果
https://blog.csdn.net/disen10/article/details/79376631 固定权重:https://www.cnblogs.com/chenyliang/p/678 ...
- eclipse 出现内存溢出问题解决办法
1.eclipse.ini添加设置: -vm#eclipse启动使用的jdk设置,路径根据自己实际路径修改 C:/Program Files/Java/jdk1.6.0_45/bin/javaw.ex ...
- Docker MySQL5.5镜像
定制MySQL的镜像有个很大的难题:mysqld启动之前要初始化数据目录,5.5自带有空账号密码需要初始化. Dockerfile FROM centos # 拷贝需要的安装和MySQL初始脚本 CO ...
- Win7的话,可能有十种简单的方法进行提速呢
1.窗口转换更快速 Windows7绚丽的效果的确美观,但漂亮的效果就需要拿速度来交换,因此如果你想要Windows7中的各个窗口切换得更快速,那关闭窗口最大.最小化的动画效果后,你会发现窗口切换得更 ...
- 热扩容LVM形式的/(根)分区(无损增大、缩小LVM分区)
警告! 本文为虚拟机环境,生产环境请务必在操作前优先备份重要数据! 再有,请确保所需扩充的分区为非进程占用分区 实验背景:当时规划系统分区时/(根)目录分配过小 实验目的 : 无损增大/(根)分区容量 ...