Maven 常用命令

123 阅读1分钟
  1. Maven Help 插件

    1.1 mvn help:active-profiles
    列出当前构建活动中的 Profile,包括项目的,用户的,全局的(settings.xml 默认 jdk-1.8)
    
    1.2 mvn help:effective-pom
    显示当前构建的实际 POM,包含活动的 Profile。一般会展示 pom 文件中未显示的一些内置插件(test
    compile 等插件信息)
    
    1.3 mvn help:effective-settings
    打印出项目的实际 settings, 包括从全局 settings.xml 和用户级别 settings.xml 继承的配置(一般
    包括 profile 和 repository mirror)
    
    1.4 mvn help:describe
    打印其他插件的使用方法
    
    1.5 mvn help:describe -Dplugin=help
    打印 maven-help-plugin 插件的所有使用方法
    
    1.6 mvn help:describe -Dplugin=compile -Dfull
    打印 maven-help-plugin 插件的所有目标的使用方法
    
    1.7 mvn help:describe -Dplugin=compiler -Dmojo=compile -Dfull
    打印 maven-help-plugin 插件 compile 目标的用法
    
  2. Maven Archetype 插件

    2.1 mvn archetype:generate -DgroupId=top.flywen.simple  \
                           -DartifactId=simple \
                           -DpackageName=top.flywen.simple \
                           -DarchetypeArtifactId=maven-archetype-quickstart
    创建一个 maven 项目
    
    2.2 mvn archetype:generate -DgroupId=top.flywen.webapp \
                           -DartifactId=webapp \
                           -DpackageName=top.flywen.webapp \
                           -DarchetypeArtifactId=maven-archetype-webapp
    创建一个 maven web 项目
    
  3. Maven 生命周期

    3.1 mvn process-resources   ------------------------------- resources:resources
    3.2 mvn compile  ------------------------------------------ compiler:compile
    3.3 mvn process-test-resources  --------------------------- resources:testResources
    3.4 mvn test-compile  ------------------------------------- compiler:testCompile
    3.5 mvn test  --------------------------------------------- surefire:test
    3.6 mvn package  ------------------------------------------ jar:jar
    3.7 mvn install  ------------------------------------------ install:install
    3.8 mvn deploy  ------------------------------------------- deploy:deploy
    3.9 mvn package
    等同于下面
    mvn resources:resources \
        compiler:compile \
        resources:testResources \
        compiler:testCompile \
        surefire:test \
        jar:jar