這幾個配置文件都在 maven 的 安裝 目錄的 lib 目錄中java
1. super pom.express
在 maven-model-builder-{version}.jar 包的apache
org/apache/maven/model 中的 pom-4.0.0.xml 這個文件app
全部的pom 文件都繼承該 pom 文件。摘抄以下:less
1 <?xml version="1.0" encoding="UTF-8"?> 2 3 <!-- 4 Licensed to the Apache Software Foundation (ASF) under one 5 or more contributor license agreements. See the NOTICE file 6 distributed with this work for additional information 7 regarding copyright ownership. The ASF licenses this file 8 to you under the Apache License, Version 2.0 (the 9 "License"); you may not use this file except in compliance 10 with the License. You may obtain a copy of the License at 11 12 http://www.apache.org/licenses/LICENSE-2.0 13 14 Unless required by applicable law or agreed to in writing, 15 software distributed under the License is distributed on an 16 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 KIND, either express or implied. See the License for the 18 specific language governing permissions and limitations 19 under the License. 20 --> 21 22 <!-- START SNIPPET: superpom --> 23 <project> 24 <modelVersion>4.0.0</modelVersion> 25 26 <repositories> 27 <repository> 28 <id>central</id> 29 <name>Central Repository</name> 30 <url>https://repo.maven.apache.org/maven2</url> 31 <layout>default</layout> 32 <snapshots> 33 <enabled>false</enabled> 34 </snapshots> 35 </repository> 36 </repositories> 37 38 <pluginRepositories> 39 <pluginRepository> 40 <id>central</id> 41 <name>Central Repository</name> 42 <url>https://repo.maven.apache.org/maven2</url> 43 <layout>default</layout> 44 <snapshots> 45 <enabled>false</enabled> 46 </snapshots> 47 <releases> 48 <updatePolicy>never</updatePolicy> 49 </releases> 50 </pluginRepository> 51 </pluginRepositories> 52 53 <build> 54 <directory>${project.basedir}/target</directory> 55 <outputDirectory>${project.build.directory}/classes</outputDirectory> 56 <finalName>${project.artifactId}-${project.version}</finalName> 57 <testOutputDirectory>${project.build.directory}/test-classes</testOutputDirectory> 58 <sourceDirectory>${project.basedir}/src/main/java</sourceDirectory> 59 <scriptSourceDirectory>${project.basedir}/src/main/scripts</scriptSourceDirectory> 60 <testSourceDirectory>${project.basedir}/src/test/java</testSourceDirectory> 61 <resources> 62 <resource> 63 <directory>${project.basedir}/src/main/resources</directory> 64 </resource> 65 </resources> 66 <testResources> 67 <testResource> 68 <directory>${project.basedir}/src/test/resources</directory> 69 </testResource> 70 </testResources> 71 <pluginManagement> 72 <!-- NOTE: These plugins will be removed from future versions of the super POM --> 73 <!-- They are kept for the moment as they are very unlikely to conflict with lifecycle mappings (MNG-4453) --> 74 <plugins> 75 <plugin> 76 <artifactId>maven-antrun-plugin</artifactId> 77 <version>1.3</version> 78 </plugin> 79 <plugin> 80 <artifactId>maven-assembly-plugin</artifactId> 81 <version>2.2-beta-5</version> 82 </plugin> 83 <plugin> 84 <artifactId>maven-dependency-plugin</artifactId> 85 <version>2.8</version> 86 </plugin> 87 <plugin> 88 <artifactId>maven-release-plugin</artifactId> 89 <version>2.3.2</version> 90 </plugin> 91 </plugins> 92 </pluginManagement> 93 </build> 94 95 <reporting> 96 <outputDirectory>${project.build.directory}/site</outputDirectory> 97 </reporting> 98 99 <profiles> 100 <!-- NOTE: The release profile will be removed from future versions of the super POM --> 101 <profile> 102 <id>release-profile</id> 103 104 <activation> 105 <property> 106 <name>performRelease</name> 107 <value>true</value> 108 </property> 109 </activation> 110 111 <build> 112 <plugins> 113 <plugin> 114 <inherited>true</inherited> 115 <artifactId>maven-source-plugin</artifactId> 116 <executions> 117 <execution> 118 <id>attach-sources</id> 119 <goals> 120 <goal>jar</goal> 121 </goals> 122 </execution> 123 </executions> 124 </plugin> 125 <plugin> 126 <inherited>true</inherited> 127 <artifactId>maven-javadoc-plugin</artifactId> 128 <executions> 129 <execution> 130 <id>attach-javadocs</id> 131 <goals> 132 <goal>jar</goal> 133 </goals> 134 </execution> 135 </executions> 136 </plugin> 137 <plugin> 138 <inherited>true</inherited> 139 <artifactId>maven-deploy-plugin</artifactId> 140 <configuration> 141 <updateReleaseInfo>true</updateReleaseInfo> 142 </configuration> 143 </plugin> 144 </plugins> 145 </build> 146 </profile> 147 </profiles> 148 149 </project> 150 <!-- END SNIPPET: superpom -->
2. 生命週期綁定文件
在 maven-core-{version}.jar 包中maven
META-INF/plexus/components.xml 中。重要的幾個綁定:post
2.1 packing 類型 爲 war 時的默認綁定ui
1 2 <component> 3 <role>org.apache.maven.lifecycle.mapping.LifecycleMapping</role> 4 <role-hint>war</role-hint> 5 <implementation>org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping</implementation> 6 <configuration> 7 <lifecycles> 8 <lifecycle> 9 <id>default</id> 10 11 <phases> 12 <process-resources> 13 org.apache.maven.plugins:maven-resources-plugin:2.6:resources 14 </process-resources> 15 <compile> 16 org.apache.maven.plugins:maven-compiler-plugin:3.1:compile 17 </compile> 18 <process-test-resources> 19 org.apache.maven.plugins:maven-resources-plugin:2.6:testResources 20 </process-test-resources> 21 <test-compile> 22 org.apache.maven.plugins:maven-compiler-plugin:3.1:testCompile 23 </test-compile> 24 <test> 25 org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test 26 </test> 27 <package> 28 org.apache.maven.plugins:maven-war-plugin:2.2:war 29 </package> 30 <install> 31 org.apache.maven.plugins:maven-install-plugin:2.4:install 32 </install> 33 <deploy> 34 org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy 35 </deploy> 36 </phases> 37 38 </lifecycle> 39 </lifecycles> 40 </configuration> 41 </component>
2.2 packing 類型 爲 jar 時的默認綁定this
1 <component> 2 <role>org.apache.maven.lifecycle.mapping.LifecycleMapping</role> 3 <role-hint>jar</role-hint> 4 <implementation>org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping</implementation> 5 <configuration> 6 <lifecycles> 7 <lifecycle> 8 <id>default</id> 9 10 <phases> 11 <process-resources> 12 org.apache.maven.plugins:maven-resources-plugin:2.6:resources 13 </process-resources> 14 <compile> 15 org.apache.maven.plugins:maven-compiler-plugin:3.1:compile 16 </compile> 17 <process-test-resources> 18 org.apache.maven.plugins:maven-resources-plugin:2.6:testResources 19 </process-test-resources> 20 <test-compile> 21 org.apache.maven.plugins:maven-compiler-plugin:3.1:testCompile 22 </test-compile> 23 <test> 24 org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test 25 </test> 26 <package> 27 org.apache.maven.plugins:maven-jar-plugin:2.4:jar 28 </package> 29 <install> 30 org.apache.maven.plugins:maven-install-plugin:2.4:install 31 </install> 32 <deploy> 33 org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy 34 </deploy> 35 </phases> 36 37 </lifecycle> 38 </lifecycles> 39 </configuration> 40 </component>
2.3 packing 類型 爲 pom 時的默認綁定url
1 <component> 2 <role>org.apache.maven.lifecycle.mapping.LifecycleMapping</role> 3 <role-hint>pom</role-hint> 4 <implementation>org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping</implementation> 5 <configuration> 6 <lifecycles> 7 <lifecycle> 8 <id>default</id> 9 10 <phases> 11 <install> 12 org.apache.maven.plugins:maven-install-plugin:2.4:install 13 </install> 14 <deploy> 15 org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy 16 </deploy> 17 </phases> 18 19 </lifecycle> 20 </lifecycles> 21 </configuration> 22 </component>
2.4 maven 中的三大生命週期
1 <component> 2 <role>org.apache.maven.lifecycle.Lifecycle</role> 3 <implementation>org.apache.maven.lifecycle.Lifecycle</implementation> 4 <role-hint>default</role-hint> 5 <configuration> 6 <id>default</id> 7 8 <phases> 9 <phase>validate</phase> 10 <phase>initialize</phase> 11 <phase>generate-sources</phase> 12 <phase>process-sources</phase> 13 <phase>generate-resources</phase> 14 <phase>process-resources</phase> 15 <phase>compile</phase> 16 <phase>process-classes</phase> 17 <phase>generate-test-sources</phase> 18 <phase>process-test-sources</phase> 19 <phase>generate-test-resources</phase> 20 <phase>process-test-resources</phase> 21 <phase>test-compile</phase> 22 <phase>process-test-classes</phase> 23 <phase>test</phase> 24 <phase>prepare-package</phase> 25 <phase>package</phase> 26 <phase>pre-integration-test</phase> 27 <phase>integration-test</phase> 28 <phase>post-integration-test</phase> 29 <phase>verify</phase> 30 <phase>install</phase> 31 <phase>deploy</phase> 32 </phases> 33 34 </configuration> 35 </component><component> 36 <role>org.apache.maven.lifecycle.Lifecycle</role> 37 <implementation>org.apache.maven.lifecycle.Lifecycle</implementation> 38 <role-hint>clean</role-hint> 39 <configuration> 40 <id>clean</id> 41 42 <phases> 43 <phase>pre-clean</phase> 44 <phase>clean</phase> 45 <phase>post-clean</phase> 46 </phases> 47 <default-phases> 48 <clean> 49 org.apache.maven.plugins:maven-clean-plugin:2.5:clean 50 </clean> 51 </default-phases> 52 53 </configuration> 54 </component><component> 55 <role>org.apache.maven.lifecycle.Lifecycle</role> 56 <implementation>org.apache.maven.lifecycle.Lifecycle</implementation> 57 <role-hint>site</role-hint> 58 <configuration> 59 <id>site</id> 60 61 <phases> 62 <phase>pre-site</phase> 63 <phase>site</phase> 64 <phase>post-site</phase> 65 <phase>site-deploy</phase> 66 </phases> 67 <default-phases> 68 <site> 69 org.apache.maven.plugins:maven-site-plugin:3.3:site 70 </site> 71 <site-deploy> 72 org.apache.maven.plugins:maven-site-plugin:3.3:deploy 73 </site-deploy> 74 </default-phases> 75 76 </configuration> 77 </component>