zoukankan      html  css  js  c++  java
  • maven打war包的过程中,都用了哪些插件呢?

    一、maven生命周期

    http://ifeve.com/introduction-to-the-lifecycle/

    https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html

    1.内置的三个生命周期

    我这边的简单理解是:

    首先一共有三个内置的生命周期,一个为clean,一个为default,一个为site。

    There are three built-in build lifecycles: default, clean and site. The default lifecycle handles your project deployment, the clean lifecycle handles project cleaning, while the site lifecycle handles the creation of your project's site documentation.

     

    2.生命周期的组成

    一个生命周期包含了许多阶段,比如compile阶段,install阶段等等。阶段是有顺序的,典型的如下:

     3.goal是什么

    在讲阶段之前,先说下goal。

    goal可以简单理解为一个功能,功能是由插件实现的。

    牛逼的插件可以有很多个goal,当然,我们不鼓励一个插件做了所有的事,毕竟unix哲学嘛。

    比如compile插件,org.apache.maven.plugins:maven-compiler-plugin。

    它既可以编译main下面的代码,也可以编译test下面的代码,这里就被分成了两个goal:

    compile和testCompile。

    当然,也有个直观介绍(idea中的maven视图),看下图:

    4.阶段的组成

    每个阶段由0到多个目标(goal)组成。

    但是,goal可以选择不绑定到阶段,也可以绑定到多个阶段。

    所以执行整个生命周期的过程,就是按照顺序,执行各个phase,具体到每个phase的时候,按顺序执行绑定到该phase的goal。

    以打jar包为例,默认maven已经帮我们在每个phase中绑定了goal,如下:

     5.如果我们想在某个阶段新增goal怎么办呢?

    可以像下面这样,在<phase>元素中指定:

    以上配置<phase>中配置了process-test-resources阶段,该阶段我们附加了一个goal,那就是time。

    再看下面的配置:

    <build> 
      <plugins> 
        <plugin> 
          <groupId>org.apache.maven.plugins</groupId>  
          <artifactId>maven-source-plugin</artifactId>  
          <version>2.1</version>  
          <configuration> 
            <attach>true</attach> 
          </configuration>  
          <executions> 
            <execution> 
              <phase>compile</phase>  
              <goals> 
                <goal>jar</goal> 
              </goals> 
            </execution> 
          </executions> 
        </plugin> 
      </plugins> 
    </build>
    以上配置在<phase>中指定了compile,即在compile阶段附加一个goal,该goal为当前插件的jar。

    二、default生命周期中打包时默认绑定的插件

    https://maven.apache.org/ref/3.6.0/maven-core/default-bindings.html#Plugin_bindings_for_war_packaging

    专门对比了下jar包和war包,可以发现只有打包阶段用的插件不一样:

     这个可以验证,在idea中,一个默认的maven web工程,在maven视图中,plugins中显示的插件如下:

    可以看到,剩下的几个插件,正好是war包pom中默认绑定的那几个插件。

  • 相关阅读:
    004: 基本数据类型-List
    003: 基本类型-字符串类型
    002: 基本类型-数值型(int, float)
    001: Hello World
    Python中的单例模式的几种实现方式的及优化
    django之admin组件
    权限管理---设计分析以及具体细节
    基于Form组件实现的增删改和基于ModelForm实现的增删改
    Python常见问题系列
    django的render的说明
  • 原文地址:https://www.cnblogs.com/grey-wolf/p/10071549.html
Copyright © 2011-2022 走看看