Maven cheat sheet 手抄
写给懒人看的
概念
生命周期由阶段构成:validate,compile,test,package,verify,install,deploy
基础
-
基础编译:mvn clean package
-
环境变量:MAVEN_HOME, MAVEN_OPTS, MAVEN_ARGS
配置
-
打印激活的配置:
mvn help:active-profiles
-
激活Profile:
-Pprofile1 -Pprofile2 -P!profile3
参数
- 调试:
-X
- 不打印下载进度:
-ntp
- 按指定模块构建: -am -pl <module,s>
阶段
- 安装到本地缓存:
install
- 发布到Nexus私服:
deploy
- 打印依赖树:
dependency:tree
- 手动下载依赖:
dependency:get -Dartifact=<GAV>[:classifier]
- 从文件安装:
install:install-file -DgroupId=<G> -DartifactId=<A> -Dversion=<V> -Dpackaging=jar -Dfile=<file>
- 生成源代码:
generate-sources
- 处理源代码:
process-sources
配置文件
- 用户配置文件:(%USER_HOME%/.m2/settings.xml)
- 全局配置文件:(${maven.home}/conf/settings.xml)
网络代理
<proxies><proxy></proxy></proxies>
参数:id,active,protocol,host,port,username,password,nonProxyhosts:分隔符|
[========]
maven系统依赖
<scope>system</scope>
<systemPath>${java.home}/../lib/tools.jar</systemPath>
HttpClient HTTP Wagon配置
<servers><server><id></id> <configuration></configuration></server></servers>
参数:c:httpHeaders:property,c:timeout, c:httpConfiguration:all:readTimeout
常用插件清单
场景 | 插件名称 | 关键信息 |
---|---|---|
组织,分发ZIP包 | maven-assembly-plugin | assembly:single |
打包源码 | maven-source-plugin | 生成classifier=sources的jar |
SpringBoot | spring-boot-maven-plugin | executable, repackage |
打包jar包 | maven-jar-plugin | include, exclude, manifestEntries |
shade依赖 | maven-shade-plugin | relocation,META-INF transformer, SPI |
复制,解压依赖 | maven-dependency-plugin | copy-dependencies,unpack |
常见Transformer配置
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Main-Class>com.slankka.maven</Main-Class>
</manifestEntries>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
<transformer
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.handlers</resource>
</transformer>
<transformer
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.schemas</resource>
</transformer>
</transformers>
标签:maven,sheet,配置文件,plugin,cheat,jar,Maven,install
From: https://www.cnblogs.com/slankka/p/17520831.html