maven的超级pom
对于 Maven3,超级 POM 在文件 %MAVEN_HOME%/lib/maven-model-builder-x.x.x.jar 中的 org/apache/maven/model/pom-4.0.0.xml 路径下、
对于 Maven2,超级 POM 在文件 %MAVEN_HOME%/lib/maven-x.x.x-uber.jar 中的 org/apache/maven/project/pom-4.0.0.xml 目录下。
这里的 x.x.x 表示 Maven 的具体版本。
对于使用java的人而言,继承这个词大家应该都不陌生。要继承pom就需要有一个父pom,在Maven中定义了超级pom.xml,任何没有申明自己父pom.xml的pom.xml都将默认继承自这个超级pom.xml。
先来看一下这个超级pom.xml的定义:
- <project>
- <modelVersion>4.0.0</modelVersion>
- <name>Maven Default Project</name>
- <repositories>
- <repository>
- <id>central</id>
- <name>Maven Repository Switchboard</name>
- <layout>default</layout>
- <url>http://repo1.maven.org/maven2</url>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- </repository>
- </repositories>
- <pluginRepositories>
- <pluginRepository>
- <id>central</id>
- <name>Maven Plugin Repository</name>
- <url>http://repo1.maven.org/maven2</url>
- <layout>default</layout>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- <releases>
- <updatePolicy>never</updatePolicy>
- </releases>
- </pluginRepository>
- </pluginRepositories>
- <build>
- <directory>${project.basedir}/target</directory>
- <outputDirectory>${project.build.directory}/classes</outputDirectory>
- <finalName>${project.artifactId}-${project.version}</finalName>
- <testOutputDirectory>${project.build.directory}/test-classes</testOutputDirectory>
- <sourceDirectory>${project.basedir}/src/main/java</sourceDirectory>
- <!-- TODO: MNG-3731 maven-plugin-tools-api < 2.4.4 expect this to be relative... -->
- <scriptSourceDirectory>src/main/scripts</scriptSourceDirectory>
- <testSourceDirectory>${project.basedir}/src/test/java</testSourceDirectory>
- <resources>
- <resource>
- <directory>${project.basedir}/src/main/resources</directory>
- </resource>
- </resources>
- <testResources>
- <testResource>
- <directory>${project.basedir}/src/test/resources</directory>
- </testResource>
- </testResources>
- <pluginManagement>
- <plugins>
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <version>1.3</version>
- </plugin>
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <version>2.2-beta-2</version>
- </plugin>
- <plugin>
- <artifactId>maven-clean-plugin</artifactId>
- <version>2.2</version>
- </plugin>
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>2.0.2</version>
- </plugin>
- <plugin>
- <artifactId>maven-dependency-plugin</artifactId>
- <version>2.0</version>
- </plugin>
- <plugin>
- <artifactId>maven-deploy-plugin</artifactId>
- <version>2.4</version>
- </plugin>
- <plugin>
- <artifactId>maven-ear-plugin</artifactId>
- <version>2.3.1</version>
- </plugin>
- <plugin>
- <artifactId>maven-ejb-plugin</artifactId>
- <version>2.1</version>
- </plugin>
- <plugin>
- <artifactId>maven-install-plugin</artifactId>
- <version>2.2</version>
- </plugin>
- <plugin>
- <artifactId>maven-jar-plugin</artifactId>
- <version>2.2</version>
- </plugin>
- <plugin>
- <artifactId>maven-javadoc-plugin</artifactId>
- <version>2.5</version>
- </plugin>
- <plugin>
- <artifactId>maven-plugin-plugin</artifactId>
- <version>2.4.3</version>
- </plugin>
- <plugin>
- <artifactId>maven-rar-plugin</artifactId>
- <version>2.2</version>
- </plugin>
- <plugin>
- <artifactId>maven-release-plugin</artifactId>
- <version>2.0-beta-8</version>
- </plugin>
- <plugin>
- <artifactId>maven-resources-plugin</artifactId>
- <version>2.3</version>
- </plugin>
- <plugin>
- <artifactId>maven-site-plugin</artifactId>
- <version>2.0-beta-7</version>
- </plugin>
- <plugin>
- <artifactId>maven-source-plugin</artifactId>
- <version>2.0.4</version>
- </plugin>
- <plugin>
- <artifactId>maven-surefire-plugin</artifactId>
- <version>2.4.3</version>
- </plugin>
- <plugin>
- <artifactId>maven-war-plugin</artifactId>
- <version>2.1-alpha-2</version>
- </plugin>
- </plugins>
- </pluginManagement>
- </build>
- <reporting>
- <outputDirectory>${project.build.directory}/site</outputDirectory>
- </reporting>
- <profiles>
- <profile>
- <id>release-profile</id>
- <activation>
- <property>
- <name>performRelease</name>
- <value>true</value>
- </property>
- </activation>
- <build>
- <plugins>
- <plugin>
- <inherited>true</inherited>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-source-plugin</artifactId>
- <executions>
- <execution>
- <id>attach-sources</id>
- <goals>
- <goal>jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <inherited>true</inherited>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <executions>
- <execution>
- <id>attach-javadocs</id>
- <goals>
- <goal>jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <inherited>true</inherited>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-deploy-plugin</artifactId>
- <configuration>
- <updateReleaseInfo>true</updateReleaseInfo>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
- </project>
对于一个pom.xml来说有几个元素是必须定义的,一个是project根元素,然后就是它里面的modelVersion、groupId、artifactId和version。由上面的超级pom.xml的内容我们可以看到pom.xml中没有groupId、artifactId和version的定义,所以我们在建立自己的pom.xml的时候就需要定义这三个元素。和java里面的继承类似,子pom.xml会完全继承父pom.xml中所有的元素,而且对于相同的元素,一般子pom.xml中的会覆盖父pom.xml中的元素,但是有几个特殊的元素它们会进行合并而不是覆盖。这些特殊的元素是:
Ø dependencies
Ø developers
Ø contributors
Ø plugin列表,包括plugin下面的reports
Ø resources
参考:
1、http://blog.csdn.net/tounaobun/article/details/8958125
2、http://blog.csdn.net/haojiahj/article/details/49964919
maven的超级pom的更多相关文章
- 学习笔记——Maven超级POM
2014-07-04:更新如何在安装程序中找到超级pom文件.Maven有一个超级POM,所有的POM均继承此文件.你可以使用解压工具打开jar文件$M2_HOME/lib/maven-model-b ...
- maven 超级pom位置、maven命令、构件、下载位置、手动打包位置、中央仓库ip
1.超级pom位置 ----> 解压M2_HOME/lib/maven-model-builder-3.5.4.jar 2.运行maven 命令实际上是运行了 java 命令,因为maven插件 ...
- maven 仓库配置 pom中repositories属性
文章转自http://blog.csdn.net/zlgydx/article/details/51130627 什么是Maven仓库在不用Maven的时候,比如说以前我们用Ant构建项目,在项目目录 ...
- maven常用插件pom配置
一.问题描述: 部署一个maven打包项目时,jar包,依赖lib包全部手动上传至服务器,然后用maven部署报错:Exception in thread "main" java. ...
- eclipse加载maven工程提示pom.xml无法解析org.apache.maven.plugins:maven-resources-plugin:2.4.3解决方案
pom文件提示信息: Failure to transfer org.apache.maven.plugins:maven-resources-plugin:pom:2.4.3 from http:/ ...
- (转)maven配置之pom.xml配置
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/20 ...
- Maven系列一pom.xml 配置详解
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/20 ...
- 【转】maven核心,pom.xml详解
感谢如下博主: http://www.cnblogs.com/qq78292959/p/3711501.html maven核心,pom.xml详解 什么是pom? pom作为项目对象模型.通过 ...
- maven编译设置pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/20 ...
随机推荐
- 10g集群启动顺序
1. 首先, /etc/inittab(不同平台文件名可能不同),文件中的下面3行被调用. h1:35:respawn:/etc/init.d/init.evmd run >/dev/null ...
- xcode uml 工具
https://github.com/PaulTaykalo/objc-dependency-visualizer ./generate-objc-dependencies-to-json.rb -d ...
- centos7 搭建双网卡bond1(主备模式)实例
前景须知: 在redhat6 中网卡叫bond,在redhat7及centos7中改名team,此处只记录centos7中双网卡主备搭建过程. 应用情景:实现网络的高可用,防止一条网线或交换机故障影响 ...
- Gear Pump: Why Install A Pressure Reducing Valve?
When the Gear Pump Manufacturers prompts to install a gear pump, the following points should ...
- Java 一些常见问题(持续更新)
1. Java 内部类 内部类有四种常见的类型:成员内部类.局部内部类.匿名内部类和静态内部类. 1.成员内部类:定义为另一个类的里面如下: class Circle { double radius ...
- poj3537 Crosses ans Crosses
题目描述 题解: 一道非常简单的$SG$函数应用. 对于一个长度求它的$SG$函数,然后判断是否为$0$即可. 代码: #include<cstdio> #include<cstri ...
- FFT NTT 模板
NTT: #include<cstdio> #include<cstring> #include<algorithm> using namespace std; # ...
- java读取配置文件的推荐方法getResource、getResourceAsStream
在java开发中经常会读取配置文件,如果把文件路径写死,就太LOW了,也不符合编码规范. 在网上找了一些资料后,发现有两种方法:xxx.class.getResource("") ...
- 自制操作系统小样例——参考部分linux0.11内核源码
详细代码戳这里. 一.启动引导 采用软件grub2进行引导,基于规范multiboot2进行启动引导加载.multiboot2的文档资料戳这里. 二.具体内容 开发环境 系统环境:Ubuntu 14. ...
- 表单中的ngModelController
测试表单中的ngController.直接看红字结论部分即可 <!DOCTYPE html> <html lang="en"> <head> & ...