[笔记]maven

概览

在这里插入图片描述


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] ------------------------------------------------------------------------
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值