码迷,mamicode.com
首页 > 其他好文 > 详细

Maven插件

时间:2014-12-18 13:20:51      阅读:168      评论:0      收藏:0      [点我收藏+]

标签:des   ar   io   使用   sp   for   java   on   div   

1. 内置绑定插件:maven在核心为一些生命周期阶段绑定好了一些插件
插件不一定要绑定在生命周期的某个阶段上,如mvn dependency:tree|mvn help:describe

2. 自己定义绑定插件:
 配置插件时能够省略版本号信息,maven会自己主动匹配最新的插件
 maven插件
  <build><plugins><plugin></plugin></plugins></build>
  
  <plugin>
   groupId  假设Maven官方插件(即groupId为org.apache.maven.plugins),groupId能够省略
   artifaceId  
   version   
   configuration  插件參数
   executions  配置插件任务(在生命周期中某个阶段运行某任务,假设不配置这个标签,该插件就为全局插件)
  
  <execution>
   id   插件运行任务的名字
   phase   插件绑定运行的生命周期的某个阶段
   goals   插件运行任务的目标
   configuration  插件运行任务的參数

  <build>
   <plugins>
    <plugin>
     <groupId>org.apache.maven.plugins</groupId>
     <artifactId>maven-source-plugin</artifactId>
     <version>2.1.1</version>
     <executions>
      <execution>
       <id>attach-sources</id> 插件运行任务的名字
       <phase>verify</phase> 插件绑定运行的生命周期的某个阶段
       <goals>   插件运行的目标
        <goal>jar-no-fork</goal> 
       </goals> 
      </execution>
     </executions>
    </plugin>
   </plugins>
  </build>

3. 使用maven-help-plugin插件查看插件信息:
 ====================================
 Name: Maven Help Plugin
 Description: The Maven Help plugin provides goals aimed at helping to make
   sense out of the build environment. It includes the ability to view the
   effective POM and settings files, after inheritance and active profiles have
   been applied, as well as a describe a particular plugin goal to give usage
   information.
 Group Id: org.apache.maven.plugins
 Artifact Id: maven-help-plugin
 Version: 2.2
 Goal Prefix: help

 This plugin has 9 goals:

 help:active-profiles
   Description: Displays a list of the profiles which are currently active for
  this build.

 help:all-profiles
   Description: Displays a list of available profiles under the current
  project.
  Note: it will list all profiles for a project. If a profile comes up with a
  status inactive then there might be a need to set profile activation
  switches/property.

 help:describe
   Description: Displays a list of the attributes for a Maven Plugin and/or
  goals (aka Mojo - Maven plain Old Java Object).

 help:effective-pom
   Description: Displays the effective POM as an XML for this build, with the
  active profiles factored in.

 help:effective-settings
   Description: Displays the calculated settings as XML for this project,
  given any profile enhancement and the inheritance of the global settings
  into the user-level settings.

 help:evaluate
   Description: Evaluates Maven expressions given by the user in an
  interactive mode.

 help:expressions
   Description: Displays the supported Plugin expressions used by Maven.

 help:help
   Description: Display help information on maven-help-plugin.
  Call mvn help:help -Ddetail=true -Dgoal=<goal-name> to display parameter
  details.

 help:system
   Description: Displays a list of the platform details like system properties
  and environment variables.

 For more information, run ‘mvn help:describe [...] -Ddetail‘
 ====================================

3.1 描写叙述某插件指定版本号的信息:
 mvn help:describe -Dplugin=org.apache.maven.plugins:maven-compiler-plugin:3.1
 ====================================
 Name: Maven Compiler Plugin
 Description: The Compiler Plugin is used to compile the sources of your
   project.
 Group Id: org.apache.maven.plugins
 Artifact Id: maven-compiler-plugin
 Version: 3.1
 Goal Prefix: compiler

 This plugin has 3 goals:

 compiler:compile
   Description: Compiles application sources

 compiler:help
   Description: Display help information on maven-compiler-plugin.
  Call mvn compiler:help -Ddetail=true -Dgoal=<goal-name> to display
  parameter details.

 compiler:testCompile
   Description: Compiles application test sources.
 ====================================

3.2 描写叙述某插件最新版本号的的信息-省略版本号信息
 mvn help:describe -Dplugin=org.apache.maven.plugins:maven-compiler-plugin

3.3 通过goal prefix目标前缀描写叙述某插件
 mvn help:describe -Dplugin=compiler

3.4 通过goal prefix目标前缀 + goal目标描写叙述某插件
 mvn help:describe -Dplugin=compiler -Dgoal=testCompile

3.5 输出插件具体信息
 mvn help:describe -Dplugin=compiler -Ddetail

Maven插件

标签:des   ar   io   使用   sp   for   java   on   div   

原文地址:http://www.cnblogs.com/gcczhongduan/p/4171418.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!