maven2中常用插件(一)

学习《maven3 in action》总结如下常用插件及用法:

插件名称

用途

来源

用法例举

maven-clean-plugin

清理项目

Apache

      <plugin>

        <groupId>org.apache.maven.plugins</groupId>

        <artifactId>maven-clean-plugin</artifactId>

        <configuration>

          <filesets>

            <fileset>

              <directory>${basedir}</directory>

              <includes>

                <include>**/*.bak</include>

                <include>**/Thumbs.db</include>

              </includes>

            </fileset>

          </filesets>

        </configuration>

      </plugin>

maven-compiler-plugin

编译项目

Apache

<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-compiler-plugin</artifactId>

<version>${maven-compiler-plugin.version}</version>

<configuration>

<encoding>${project.build.sourceEncoding}</encoding>

<source>1.5</source>

<target>1.5</target>

</configuration>

</plugin>

maven-deploy-plugin

部署项目

Apache

 

maven-install-plugin

安装项目

Apache

 

maven-resources-plugin

处理资源文件

Apache

 

maven-site-plugin

生成站点

Apache

<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-site-plugin</artifactId>

<version>2.1.1</version>  <!--     3.0-beta-1   -->                                

<configuration>                                        

<locales>zh_CN,en</locales>

<inputEncoding>${project.reporting.outputEncoding}</inputEncoding>        

<outputEncoding>${project.reporting.outputEncoding}</outputEncoding>                                

</configuration>

</plugin>

maven-surefire-plugin

执行测试

Apache

<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-surefire-plugin</artifactId>

<version>2.5</version>

<configuration>

<includes> <!--包含测试-->

<include>**/*ATest.java</include>

<include>**/*BTest.java</include>

</includes>

<excludes><!--排除测试-->

<exclude>**/*CTest.java</exclude>

</excludes>

</configuration>

</plugin>

maven-jar-plugin

构件JAR文件

Apache

            <plugin>

                    <groupId>org.apache.maven.plugins</groupId>

                    <artifactId>maven-jar-plugin</artifactId>

                    <version>2.2</version>

                    <executions>

                            <execution>

                                    <goals>

                                            <goal>test-jar</goal><!--打包Test重用-->

                                    </goals>

                            </execution>

                    </executions>

            </plugin>

maven-war-plugin

构件WAR文件

Apache

<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-war-plugin</artifactId>

<version>2.1-beta-1</version>

<configuration>

<warName>${project.artifactId}</warName>

<webResources>

<resource>

<filtering>true</filtering>

<directory>src/main/webapp</directory>

<includes>

<include>**/*.css</include>

<include>**/*.js</include>

</includes>

</resource>

</webResources>

</configuration>

</plugin>

maven-shade-plugin

构件包含以来的JAR文件

Apache

<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-shade-plugin</artifactId>

<version>1.2</version>

<executions>

<execution>

<phase>package</phase>

<goals>

<goal>shade</goal>

</goals>

<configuration>

<transformers>

<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">

<mainClass>com.haifeng.autoCode.MainFrame</mainClass>

</transformer>

</transformers>

</configuration>

</execution>

</executions>              

</plugin>

maven-changelog-plugin

生成版本控制变更报告

Apache

<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-changelog-plugin</artifactId>

<version>2.2</version>

<configuration>

<type>range</type>

<range>60</range><!--默认显示30内记录改为60天-->

</configuration>

</plugin>

maven-checkstyle-plugin

生成CheckStyle报告

Apache

<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-checkstyle-plugin</artifactId>

<version>2.5</version>

<configuration><!--默认使用sun定义的编码规范,在此可以自定义,其中在checkstyle中包含四种规则,如下:sun_checks.xml、maven_checks.xml、turbine_checks.xml、avalon_checks.xml-->

<configLocation>config/maven_checks.xml</configLocation>

</configuration>

</plugin>

目前不支持多模块儿聚合

maven-javadoc-plugin

生成JavaDoc文档

Apache

   <plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-javadoc-plugin</artifactId>

<version>2.7</version>                                

</plugin>

maven-jxr-plugin

生成源代码交叉引用文档

Apache

<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-jxr-plugin</artifactId>

<version>2.2</version>

<configuration>

<aggregate>true</aggregate><!--聚合模块中整合所有源码-->

</configuration>

</plugin>

maven-pmd-plugin

生成pmd报告

Apache

<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-pmd-plugin</artifactId>

<version>2.5</version>

<configuration>

<rulesets><!--默认使用规则:rulesets/basic.xml、rulesets/unusedcode.xml、rulesets/importss.xml;更多规则见http://pmd.sourceforge.net/rules/index.html-->

<ruleset>rulesets/braces.xml</ruleset>

<ruleset>rulesets/naming.xml</ruleset>

<ruleset>rulesets/string.xml</ruleset>

</rulesets>

<aggregate>true</aggregate><!--配置以支持过模块聚合-->

</configuration>

</plugin>

maven-project-info-reports-plugin

生成项目信息报告

Apache

<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-project-info-reports-plugin</artifactId>

<version>2.1</version>

<!--<reportSets>

<reportSet>

<reports></reports>

</reportSet>

</reportSets>-->

<configuration>

<inputEncoding>${project.build.sourceEncoding}</inputEncoding>

<outputEncoding>${project.reporting.outputEncoding}</outputEncoding>

</configuration>

</plugin>

maven-surefire-report-plugin

生成单元测试报告

Apache

 

maven-antrun-plugin

调用ant任务

Apache

 

maven-archetype-plugin

基于ArcheType生成项目骨架

Apache

 

maven-assembly-plugin

构件自定义格式的分发包

Apache

 

maven-dependency-plugin

以来分析及控制

Apache

 

maven-enforcer-plugin

定义规则并强制要求项目遵守

Apache

 

 

maven-pgp-plugin

为项目构件生成PGP签名

Apache

 

maven-help-plugin

获取项目及Maven环境信息

Apache

 

maven-invoker-plugin

自动运行Maven项目构建并验证

Apache

 

mavne-release-plugin

自动化项目版本发布

Apache

<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-release-plugin</artifactId>

<version>2.0</version>

<configuration>

<tagBase>https://127.0.0.1/app/tags/</tagBase>

</configuration>

</plugin>

maven-scm-plugin

集成版本控制系统

Apache

 

maven-source-plugin

生成源码包

Apache

 

maven-eclipse-plugin

生成eclipse项目环境配置

Apache

 

maven-helper-maven-plugin

包括各种支持构件生命周期的目标

Codehaus

 

exec-maven-plugin

运行系统程序或者java程序

Codehaus

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值