使用Maven多模塊——打包指定模塊
Maven多模塊——打包指定模塊
mvn -h 查看命令及其用途
E:\nicole\workspace\test_parent>mvn -h usage: mvn [options] [<goal(s)>] [<phase(s)>] Options: -am,--also-make If project list is specified, also build projects required by the list -amd,--also-make-dependents If project list is specified, also build projects that depend on projects on the list -B,--batch-mode Run in non-interactive (batch) mode (disables output color) -b,--builder <arg> The id of the build strategy to use -C,--strict-checksums Fail the build if checksums don't match -c,--lax-checksums Warn if checksums don't match -cpu,--check-plugin-updates Ineffective, only kept for backward compatibility -D,--define <arg> Define a system property -e,--errors Produce execution error messages -emp,--encrypt-master-password <arg> Encrypt master security password -ep,--encrypt-password <arg> Encrypt server password -f,--file <arg> Force the use of an alternate POM file (or directory with pom.xml) -fae,--fail-at-end Only fail the build afterwards; allow all non-impacted builds to continue -ff,--fail-fast Stop at first failure in reactorized builds -fn,--fail-never NEVER fail the build, regardless of project result -gs,--global-settings <arg> Alternate path for the global settings file -gt,--global-toolchains <arg> Alternate path for the global toolchains file -h,--help Display help information -l,--log-file <arg> Log file where all build output will go (disables output color) -llr,--legacy-local-repository Use Maven 2 Legacy Local Repository behaviour, ie no use of _remote.repositories. Can also be activated by using -Dmaven.legacyLocalRepo=true -N,--non-recursive Do not recurse into sub-projects -npr,--no-plugin-registry Ineffective, only kept for backward compatibility -npu,--no-plugin-updates Ineffective, only kept for backward compatibility -nsu,--no-snapshot-updates Suppress SNAPSHOT updates -ntp,--no-transfer-progress Do not display transfer progress when downloading or uploading -o,--offline Work offline -P,--activate-profiles <arg> Comma-delimited list of profiles to activate -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 -q,--quiet Quiet output - only show errors -rf,--resume-from <arg> Resume reactor from specified project -s,--settings <arg> Alternate path for the user settings file -t,--toolchains <arg> Alternate path for the user toolchains file -T,--threads <arg> Thread count, for instance 2.0C where C is core multiplied -U,--update-snapshots Forces a check for missing releases and updated snapshots on remote repositories -up,--update-plugins Ineffective, only kept for backward compatibility -v,--version Display version information -V,--show-version Display version information WITHOUT stopping build -X,--debug Produce execution debug output
假設(shè)Maven多模塊項(xiàng)目
如下:
- test-parent pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.nicole</groupId> <artifactId>test-parent</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>pom</packaging> <name>test-parent</name> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <modules> <module>test-common</module> <module>test-module1</module> <module>test-module2</module> <module>test-module3</module> </modules> <dependencyManagement> <dependencies> <dependency> <groupId>com.nicole</groupId> <artifactId>test-common</artifactId> <version>0.0.1-SNAPSHOT</version> </dependency> </dependencies> </dependencyManagement> </project>
- test-common pom.xml:
<?xml version="1.0"?> <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>com.nicole</groupId> <artifactId>test-parent</artifactId> <version>0.0.1-SNAPSHOT</version> </parent> <artifactId>test-common</artifactId> <name>test-common</name> <url>http://maven.apache.org</url> <packaging>jar</packaging> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> </project>
- test-module1 pom.xml:
<?xml version="1.0"?> <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>com.nicole</groupId> <artifactId>test-parent</artifactId> <version>0.0.1-SNAPSHOT</version> </parent> <artifactId>test-module1</artifactId> <packaging>war</packaging> <name>test-module1 Maven Webapp</name> <dependencies> <dependency> <groupId>com.nicole</groupId> <artifactId>test-common</artifactId> </dependency> </dependencies> <build> <finalName>test-module1</finalName> </build> </project>
test-common被test-module1,test-module2,test-module3給繼承。
示例一、打包所有模塊
E:\nicole\workspace\test_parent>mvn clean install
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for test-parent 0.0.1-SNAPSHOT:
[INFO]
[INFO] test-parent ........................................ SUCCESS [ 0.623 s]
[INFO] test-common ........................................ SUCCESS [ 3.274 s]
[INFO] test-module1 Maven Webapp .......................... SUCCESS [ 0.966 s]
[INFO] test-module2 Maven Webapp .......................... SUCCESS [ 0.434 s]
[INFO] test-module3 Maven Webapp .......................... SUCCESS [ 0.678 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.424 s
[INFO] Finished at: 2019-12-30T18:01:30+08:00
[INFO] ------------------------------------------------------------------------
示例二、-pl 打包指定模塊
E:\nicole\workspace\test_parent>mvn clean install -pl test-common,test-module1
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for test-common 0.0.1-SNAPSHOT:
[INFO]
[INFO] test-common ........................................ SUCCESS [ 3.494 s]
[INFO] test-module1 Maven Webapp .......................... SUCCESS [ 1.056 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.909 s
[INFO] Finished at: 2019-12-30T18:02:39+08:00
[INFO] ------------------------------------------------------------------------
示例三、-am 同時(shí)打包所指定模塊的依賴模塊
E:\nicole\workspace\test_parent>mvn clean install -pl test-module1 -am
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for test-parent 0.0.1-SNAPSHOT:
[INFO]
[INFO] test-parent ........................................ SUCCESS [ 0.559 s]
[INFO] test-common ........................................ SUCCESS [ 3.198 s]
[INFO] test-module1 Maven Webapp .......................... SUCCESS [ 1.020 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.127 s
[INFO] Finished at: 2019-12-30T18:04:49+08:00
[INFO] ------------------------------------------------------------------------
示例四、-amd 同時(shí)打包依賴于所指定模塊的模塊
E:\nicole\workspace\test_parent>mvn clean install -pl test-common -amd
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for test-common 0.0.1-SNAPSHOT:
[INFO]
[INFO] test-common ........................................ SUCCESS [ 3.497 s]
[INFO] test-module1 Maven Webapp .......................... SUCCESS [ 1.178 s]
[INFO] test-module2 Maven Webapp .......................... SUCCESS [ 0.536 s]
[INFO] test-module3 Maven Webapp .......................... SUCCESS [ 0.746 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.330 s
[INFO] Finished at: 2019-12-30T18:06:11+08:00
[INFO] ------------------------------------------------------------------------
示例五、-rf 從所指定模塊順序開始打包
E:\nicole\workspace\test_parent>mvn clean install -rf test-module2
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for test-module2 Maven Webapp 0.0.1-SNAPSHOT:
[INFO]
[INFO] test-module2 Maven Webapp .......................... SUCCESS [ 2.146 s]
[INFO] test-module3 Maven Webapp .......................... SUCCESS [ 0.489 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.128 s
[INFO] Finished at: 2019-12-30T18:06:43+08:00
[INFO] ------------------------------------------------------------------------
示例六、-pl -amd -rf 對(duì)裁剪后的模塊堆再次裁剪
E:\nicole\workspace\test_parent>mvn clean install -pl test-common -amd -rf test-module1
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for test-module1 Maven Webapp 0.0.1-SNAPSHOT:
[INFO]
[INFO] test-module1 Maven Webapp .......................... SUCCESS [ 2.195 s]
[INFO] test-module2 Maven Webapp .......................... SUCCESS [ 0.523 s]
[INFO] test-module3 Maven Webapp .......................... SUCCESS [ 0.633 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.889 s
[INFO] Finished at: 2019-12-30T18:07:46+08:00
[INFO] ------------------------------------------------------------------------
- -pl -amd 得到test-common,test-module1,test-module2,test-module3
- rf 從test-module1開始打包
總結(jié)
以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
javabean?中使用@Transient屬性處理臨時(shí)字段
@Transient表示該屬性并非一個(gè)到數(shù)據(jù)庫(kù)表的字段的映射,ORM框架將忽略該屬性,本文給大家介紹javabean?中臨時(shí)字段的處理:@Transient,感興趣的朋友跟隨小編一起看看吧2023-08-08SpringBoot居然有44種應(yīng)用啟動(dòng)器,你都知道嗎
很多人都不知道SpringBoot應(yīng)用啟動(dòng)器竟然有44個(gè),本文就一起來(lái)介紹一下,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來(lái)看看吧2021-01-01解析Java的可變長(zhǎng)參數(shù)列表及其使用時(shí)的注意點(diǎn)
這篇文章主要介紹了解析Java的可變參數(shù)列表及其使用時(shí)的注意點(diǎn),注意可變參數(shù)必須位于最后一項(xiàng),需要的朋友可以參考下2016-03-03eclipse+myeclipse 環(huán)境配置方法
eclipse+myeclipse配置環(huán)境2009-07-07mybatisplus中的xml對(duì)象參數(shù)傳遞問題
這篇文章主要介紹了mybatisplus中的xml對(duì)象參數(shù)傳遞問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-11-11Eclipse搭建spring開發(fā)環(huán)境圖文教程(推薦)
下面小編就為大家?guī)?lái)一篇Eclipse搭建spring開發(fā)環(huán)境圖文教程(推薦)。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來(lái)看看吧2017-07-07springboot+Vue實(shí)現(xiàn)分頁(yè)的示例代碼
本文主要介紹了springboot+Vue實(shí)現(xiàn)分頁(yè)的示例代碼,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2021-06-06Java結(jié)構(gòu)型設(shè)計(jì)模式之組合模式詳解
組合模式,又叫部分整體模式,它創(chuàng)建了對(duì)象組的數(shù)據(jù)結(jié)構(gòu)組合模式使得用戶對(duì)單個(gè)對(duì)象和組合對(duì)象的訪問具有一致性。本文將通過示例為大家詳細(xì)介紹一下組合模式,需要的可以參考一下2022-09-09