maven中的默认插件

转载:https://www.cnblogs.com/fnlingnzb-learner/p/10536947.html

一、 Maven 默认插件

已知 Maven 使用 plugin 来执行实际操作的,在默认情况下,Maven 会绑定以下几个插件来完成基本操作。

pluginfunctionlife cycle phase
maven-clean-plugin清理上一次执行创建的目标文件clean
maven-resources-plugin清理上一次执行创建的目标文件resources,testResources
maven-compiler-plugin编译源文件和测试源文件compile,testCompile
maven-surefire-plugin执行测试文件test
maven-jar-plugin创建 jarjar
maven-install-plugin安装 jar,将创建生成的 jar 拷贝到 .m2/repository 下面install
maven-deploy-plugin发布 jardeploy

如果针对各个 plugin 有特殊配置的话,需要显示指定 plugin 和 属性配置。

二、样例

举个?:创建一个空的 maven 项目 HelloWorld,pom.xml 文件不包含任何 plugin。

<?xml version="1.0" encoding="UTF-8"?>
<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.meituan.log</groupId>
    <artifactId>HelloWorld</artifactId>
    <version>1.0-SNAPSHOT</version>

    <packaging>jar</packaging>

    <dependencies>
        <dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>zookeeper</artifactId>
            <version>3.3.1</version>
        </dependency>

        <dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>zookeeper</artifactId>
            <version>3.3.1</version>
        </dependency>
    </dependencies>
</project>
复制代码
下面是执行 mvn clean install 产生的执行日志,通过日志可以看到每个步骤都显示 plugin 名称,版本号,生命周期阶段,执行操作等。
maven-clean-plugin:2.5:clean (default-clean)
maven-resources-plugin:2.6:resources (default-resources)
maven-compiler-plugin:3.1:compile (default-compile)
maven-resources-plugin:2.6:testResources (default-testResources)
maven-compiler-plugin:3.1:testCompile (default-testCompile)
maven-surefire-plugin:2.12.4:test (default-test)
maven-jar-plugin:2.4:jar (default-jar)
maven-install-plugin:2.4:install (default-install)

复制代码
zhangguanghuideMacBook-Pro-3:HelloWorld zhangguanghui$ mvn clean install
[INFO] Scanning for projects...
[WARNING] 
[WARNING] Some problems were encountered while building the effective model for com.meituan.log:HelloWorld:jar:1.0-SNAPSHOT
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: org.apache.hadoop:zookeeper:jar -> duplicate declaration of version 3.3.1 @ line 20, column 21
[WARNING] 
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING] 
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING] 
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building HelloWorld 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ HelloWorld ---
[INFO] Deleting /Users/zhangguanghui/git/IDEA_workspace/HelloWorld/target
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ HelloWorld ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ HelloWorld ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /Users/zhangguanghui/git/IDEA_workspace/HelloWorld/target/classes
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ HelloWorld ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/zhangguanghui/git/IDEA_workspace/HelloWorld/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ HelloWorld ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ HelloWorld ---
[INFO] No tests to run.
[INFO] 
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ HelloWorld ---
[INFO] Building jar: /Users/zhangguanghui/git/IDEA_workspace/HelloWorld/target/HelloWorld-1.0-SNAPSHOT.jar
[INFO] 
[INFO] --- maven-install-plugin:2.4:install (default-install) @ HelloWorld ---
[INFO] Installing /Users/zhangguanghui/git/IDEA_workspace/HelloWorld/target/HelloWorld-1.0-SNAPSHOT.jar to /Users/zhangguanghui/.m2/repository/com/meituan/log/HelloWorld/1.0-SNAPSHOT/HelloWorld-1.0-SNAPSHOT.jar
[INFO] Installing /Users/zhangguanghui/git/IDEA_workspace/HelloWorld/pom.xml to /Users/zhangguanghui/.m2/repository/com/meituan/log/HelloWorld/1.0-SNAPSHOT/HelloWorld-1.0-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.232 s
[INFO] Finished at: 2017-02-13T17:43:06+08:00
[INFO] Final Memory: 17M/331M
[INFO] ------------------------------------------------------------------------
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值