maven常用插件

有用插件:
Maven Release Plugin 版本发布;
cargo-maven2-plugin 自动化部署;
jetty-maven-plugin web测试;
maven-gpg-plugin, GPG:http://www.gnupg.org/download/ 给maven构件加密 hkp://pgp.mit.edu 美国麻省理工大学公钥服务器
maven-surefire-plugin: 单元测试,集成测试
maven-site-plugin:生成站点 //mvn site
maven-javadoc-plugin
maven-jxr-plugin:在生成站点时配置该插件,会以Web页面的形式将Java源代码展现出来
maven-checkstyle-plugin
maven-pmd-plugin:分析Java源代码,查找代码中的问题
maven-changelog-plugin
cobertura-maven-plugin

常用命令:
mvn -v
mvn help:system
mvn clean compile
mvn clean package
mvn clean test
mvn clean deploy //部署到版本仓库
mvn clean install //使其他项目使用这个jar,会安装到maven本地仓库中
mvn archetype:generate //创建项目架构
mvn dependency:list //查看已解析依赖
mvn dependency:tree
mvn dependency:analyze
mvn install -Dmaven.test.skip=true// -D 参数的使用,这里是跳过test阶段
-am, –also-make :同时构建所列模块的依赖模块
-amd -also-make-dependents 同时构建依赖于所列模块的模块 mvn clean install -pl account-parent -amd -rf account-email
-pl, –projects 构建指定的模块,模块间用逗号分隔 mvn clean install -pl account-email,account-persist
-rf -resume-from 从指定的模块回复反应堆 mvn clean install -rf account-email
mvn help:active-profiles :查看当前激活的profiles
mvn help:all-profiles : 查看所有profiles
mvn help:effective -pom 查看完整的pom信息

下面是一些插件的完整配置 

<plugins> 
     <!-- war --> 
     <plugin> 
          <artifactId>maven-war-plugin</artifactId> 
          <version>2.1.1</version> 
          <configuration> 
          </configuration> 
     </plugin> 
     
     <!-- compiler --> 
     <plugin> 
          <groupId>org.apache.maven.plugins</groupId> 
          <artifactId>maven-compiler-plugin</artifactId> 
          <configuration> 
               <source>1.6</source> 
               <target>1.6</target> 
               <encoding>UTF-8</encoding> 
          </configuration> 
     </plugin> 
     
     <!-- eclipse --> 
     <plugin> 
          <artifactId>maven-eclipse-plugin</artifactId> 
          <version>2.4</version> 
          <configuration> 
               <additionalProjectnatures> 
                    <projectnature>org.springframework.ide.eclipse.core.springnature</projectnature> 
               </additionalProjectnatures> 
               <additionalBuildcommands> 
                    <buildcommand>org.springframework.ide.eclipse.core.springbuilder</buildcommand> 
               </additionalBuildcommands> 
               <downloadSources>true</downloadSources> 
               <downloadJavadocs>false</downloadJavadocs> 
               <wtpversion>1.5</wtpversion> 
          </configuration> 
     </plugin> 
     


     <!-- jetty run --> 
     <plugin> 
          <groupId>org.mortbay.jetty</groupId> 
          <artifactId>maven-jetty-plugin</artifactId> 
          <version>6.1.21</version> 
          <configuration> 
               <contextPath>/</contextPath> 
               <scanIntervalSeconds>3</scanIntervalSeconds> 
               <scanTargetPatterns> 
                    <scanTargetPattern> 
                         <directory>src/main/webapp/WEB-INF</directory> 
                         <excludes> 
                              <exclude>**/*.jsp</exclude> 
                              <exclude>**/*.js</exclude> 
                              <exclude>**/*.css</exclude> 
                         </excludes> 
                         <includes> 
                              <include>**/*.properties</include> 
                              <include>**/*.xml</include> 
                         </includes> 
                    </scanTargetPattern> 
                    <scanTargetPattern> 
                         <directory>src/main/resources</directory> 
                         <includes> 
                              <include>**/*.properties</include> 
                              <include>**/*.xml</include> 
                         </includes> 
                    </scanTargetPattern> 
                    <scanTargetPattern> 
                         <directory>src/main/java</directory> 
                         <includes> 
                              <include>**/*.java</include> 
                              <include>**/*.xml</include> 
                         </includes> 
                    </scanTargetPattern> 
               </scanTargetPatterns> 
               <connectors> 
                  <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector"> 
                         <port>9999</port> 
                         <maxIdleTime>60000</maxIdleTime> 
                    </connector> 
               </connectors> 
          </configuration> 
     </plugin> 
          
          <!-- javadoc--> 
     <plugin> 
          <groupId>org.apache.maven.plugins</groupId> 
          <artifactId>maven-javadoc-plugin</artifactId> 
          <version>2.8</version> 
          <configuration> 
               <encoding>UTF-8</encoding> 
          </configuration> 
     </plugin> 
     

     <!-- 打包插件 --> 
     <plugin> 
          <groupId>org.apache.maven.plugins</groupId> 
          <artifactId>maven-shade-plugin</artifactId> 
          <version>1.2.1</version> 
          <executions> 
               <execution> 
                    <phase>package</phase> 
                    <goals> 
                         <goal>shade</goal> 
                    </goals> 
                    <configuration> 
                         <transformers> 
                              <transformer 
                                   implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> 
                                   <mainClass>com.iwgame.fetche.log.LogFetcher</mainClass> 
                              </transformer> 
                         </transformers> 
                    </configuration> 
               </execution> 
          </executions> 
     </plugin> 
     
     <!-- assembly --> 
     <plugin> 
          <artifactId>maven-assembly-plugin</artifactId> 
          <configuration> 
               <archive> 
                    <manifest> 
                         <!--  这里就是mainclass 配置 --> 
                         <mainClass>auto.lazy.test.LazyT</mainClass>  
                    </manifest> 
               </archive> 
               <descriptorRefs> 
                    <descriptorRef>jar-with-dependencies</descriptorRef> 
               </descriptorRefs> 
          </configuration> 
     </plugin> 
</plugins>

发表评论

电子邮件地址不会被公开。 必填项已用*标注