1.開啟多線程
命令
mvn clean package -T 1C -Dmaven.test.skip=true -Dmaven.compile.fork=true
說明
-Dmaven.compile.fork=true 表示開啟多線程
-T 1c 表示利用多線程,一核一線程
mvn -T 4 install -- will use 4 threads
mvn -T 1C install -- will use 1 thread per available CPU core
2.按需加載所需模塊
多模塊項目,只需要重新編譯修改模塊:
mvn install -pl $moduleName -am
-pl - makes Maven build only specified modules and not the whole project.
-am - 使Maven找出目標模塊所依賴的模塊並進行構建
3.限制聯網
如果本地編譯沒有引入新的包或者更新,可以將maven設置脫機模式
--offline
最終效果為
mvn -T 1C install -pl $moduleName -am --offline