zno2

maven install 小技巧

创建一个简单的maven分层项目 

z-father
│  pom.xml
│      
├─z-child1
│  │  pom.xml
├─z-child2-withtool
│  │  pom.xml
└─z-tool
   │  pom.xml

 

简单说明:father 有三个modules , child2 依赖 tool

 

 

技巧一:只安装父pom

z-father>mvn install -N

解释,-N 不递归,不创建子模块

 -N,--non-recursive                     Do not recurse into sub-projects

[INFO] Scanning for projects...
[INFO]
[INFO] --------------------------< cn.zno:z-father >---------------------------
[INFO] Building z-father 0.0.1-SNAPSHOT
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ z-father ---
[INFO] Installing D:\workspaces\xxx\z-father\pom.xml to D:\mvnrepository\cn\zno\z-father\0.0.1-SNAPSHOT\z-father-0.0.1-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.358 s
[INFO] Finished at: 2020-12-24T10:20:05+08:00
[INFO] ------------------------------------------------------------------------

 

技巧二:只安装指定的模块及其依赖

z-father>mvn install -pl z-child2-withtool -am

解释,-pl  指定打包列表,该命令会打包z-child2-withtool 及其依赖z-father 和 z-tool 

-pl,--projects <arg> Comma-delimited list of specified
reactor projects to build instead
of all projects. A project can be
specified by [groupId]:artifactId
or by its relative path

解释,-am 打包列表如果依赖某个模块,那么也打包该模块

-am,--also-make If project list is specified, also
build projects required by the
list

[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] z-father                                                           [pom]
[INFO] z-tool                                                             [jar]
[INFO] z-child2-withtool                                                  [jar]
[INFO]
[INFO] --------------------------< cn.zno:z-father >---------------------------
[INFO] Building z-father 0.0.1-SNAPSHOT                                   [1/3]
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ z-father ---
[INFO] Installing D:\workspaces\xxx\z-father\pom.xml to D:\mvnrepository\cn\zno\z-father\0.0.1-SNAPSHOT\z-father-0.0.1-SNAPSHOT.pom
[INFO]
[INFO] ---------------------------< cn.zno:z-tool >----------------------------
[INFO] Building z-tool 0.0.1-SNAPSHOT                                     [2/3]
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ z-tool ---
[WARNING] Using platform encoding (GBK 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) @ z-tool ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ z-tool ---
[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ z-tool ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ z-tool ---
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ z-tool ---
[INFO] Building jar: D:\workspaces\xxx\z-father\z-tool\target\z-tool-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ z-tool ---
[INFO] Installing D:\workspaces\xxx\z-father\z-tool\target\z-tool-0.0.1-SNAPSHOT.jar to D:\mvnrepository\cn\zno\z-tool\0.0.1-SNAPSHOT\z-tool-0.0.1-SNAPSHOT.jar
[INFO] Installing D:\workspaces\xxx\z-father\z-tool\pom.xml to D:\mvnrepository\cn\zno\z-tool\0.0.1-SNAPSHOT\z-tool-0.0.1-SNAPSHOT.pom
[INFO]
[INFO] ----------------------< cn.zno:z-child2-withtool >----------------------
[INFO] Building z-child2-withtool 0.0.1-SNAPSHOT                          [3/3]
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ z-child2-withtool ---
[WARNING] Using platform encoding (GBK 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) @ z-child2-withtool ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ z-child2-withtool ---
[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ z-child2-withtool ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ z-child2-withtool ---
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ z-child2-withtool ---
[INFO] Building jar: D:\workspaces\xxx\z-father\z-child2-withtool\target\z-child2-withtool-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ z-child2-withtool ---
[INFO] Installing D:\workspaces\xxx\z-father\z-child2-withtool\target\z-child2-withtool-0.0.1-SNAPSHOT.jar to D:\mvnrepository\cn\zno\z-child2-withtool\0.0.1-SNAPSHOT\
z-child2-withtool-0.0.1-SNAPSHOT.jar
[INFO] Installing D:\workspaces\xxx\z-father\z-child2-withtool\pom.xml to D:\mvnrepository\cn\zno\z-child2-withtool\0.0.1-SNAPSHOT\z-child2-withtool-0.0.1-SNAPSHOT.pom

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for z-father 0.0.1-SNAPSHOT:
[INFO]
[INFO] z-father ........................................... SUCCESS [  0.290 s]
[INFO] z-tool ............................................. SUCCESS [  0.873 s]
[INFO] z-child2-withtool .................................. SUCCESS [  0.085 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.394 s
[INFO] Finished at: 2020-12-24T10:22:12+08:00
[INFO] ------------------------------------------------------------------------

 

posted on 2023-06-06 12:39  zno2  阅读(83)  评论(0编辑  收藏  举报

导航