概览
settings.xml介绍
- 存在以下几个主要的元素
localReposotory:本地仓库路径
pluginGroups:简化插件下载的时候的plugin’ gorup信息
servers+distributionManagement配合使用:
servers:远程仓库(distributionManagementB标签下)授权信息
distributionManagement:标识mvn deploy需要发布的远程仓库
mirrors:镜像仓库,mirrorOf定义了会拦截哪些repository配置
proxies:代理信息
profiles:配置清单
profile/activation:激活的配置
profile/repositories:远程仓库配置
profile/properties:参数配置
-
需要注意的点:
-
mirrors是会拦截发向profiles/profile/repositories中的仓库的请求:当请求需要从profiles/profile/repositories中的某个仓库下载时,发现mirrors中有该仓库对应的镜像配置,则从镜像中进行下载
-
settings和pom中的profile优先级:
repository(setting.xml) < repository(pom.xml) < mirror(setting.xml) -
如果setting和pom中都定义了profile:
- 相同id下:如果settings中激活了,则settings会覆盖pom中profile
- 不同id下:profile(pom) > profile(settings)
-
常见的snapshot、release处理策略
snapshot可以覆盖发布,release不可以,会存在安全性、可溯源性风险
-
-
其它settings的配置详细介绍:https://www.cnblogs.com/iceJava/p/10356309.html
pom.xml详细
- 参见:https://blog.youkuaiyun.com/qq_33363618/article/details/79438044
package示例
- 构建时,每次个阶段都依赖独立的plugin
- 构建的具体信息,参见pom.xml配置
# package过程,可以看到,会使用不同的插件进行构建
# 如果需要有特殊插件定制的时候,可在pom.xml的build中定义
mavenLearn % mvn package
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] mavenLearn [pom]
[INFO] child [jar]
[INFO]
[INFO] -----------------------< org.example:mavenLearn >-----------------------
[INFO] Building mavenLearn 1.0-SNAPSHOT [1/2]
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] -------------------------< org.example:child >--------------------------
[INFO] Building child 1.0-SNAPSHOT [2/2]
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ child ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ child ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ child ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /Users/zhaoyue/codes/mavenLearn/child/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ child ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ child ---
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ child ---
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for mavenLearn 1.0-SNAPSHOT:
[INFO]
[INFO] mavenLearn ......................................... SUCCESS [ 0.003 s]
[INFO] child .............................................. SUCCESS [ 0.885 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.988 s
[INFO] Finished at: 2020-05-05T23:02:31+08:00
[INFO] ------------------------------------------------------------------------