maven plugins 常用

1。  测试用例

  1. <plugin>  
  2.     <groupId>org.apache.maven.plugins</groupId>  
  3.     <artifactId>maven-surefire-plugin</artifactId>  
  4.     <version>2.5</version>  
  5.     <configuration>  
  6.         <skipTests>true</skipTests>  
  7.     </configuration>  
  8. </plugin>
  9. <plugin>  
  10.     <groupId>org.apache.maven.plugins</groupId>  
  11.     <artifactId>maven-surefire-plugin</artifactId>  
  12.     <version>2.5</version>  
  13.     <configuration>  
  14.         <includes>  
  15.             <include>**/*Tests.java</include>  
  16.         </includes>  
  17.         <excludes>  
  18.             <exclude>**/*ServiceTest.java</exclude>  
  19.             <exclude>**/TempDaoTest.java</exclude>  
  20.         </excludes>  
  21.     </configuration>  
  22. </plugin>  

 

2.   拷贝依赖

<plugin>

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

<artifactId>maven-dependency-plugin</artifactId>

<executions>

<execution>

<id>copy-dependencies</id>

<phase>package</phase>

<goals>

<goal>copy-dependencies</goal>

</goals>

<configuration>

<outputDirectory>${project.build.directory}/lib</outputDirectory>

<overWriteReleases>false</overWriteReleases>

<overWriteSnapshots>false</overWriteSnapshots>

<overWriteIfNewer>true</overWriteIfNewer>

</configuration>

</execution>

</executions>

</plugin>

 

3.   指定编译版本

<plugin>

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

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

<configuration>

<source>1.6</source>

<target>1.6</target>

<verbose>true</verbose>

<encoding>UTF-8</encoding>

<compilerArguments>

<sourcepath>${project.build.sourceDirectory}</sourcepath>

</compilerArguments>

</configuration>

</plugin>

 

4.  资源打包

<plugin>

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

<artifactId>maven-source-plugin</artifactId>

<configuration>

<include>${project.build.sourceDirectory}</include>

</configuration>

<executions>

<execution>

<id>attach-sources</id>

<goals>

<goal>jar</goal>

</goals>

</execution>

</executions>

</plugin>

 

5.  指定资源

 <resources>

<resource>

<directory>src/main/java/</directory>

<excludes>

<exclude>.svn</exclude>

</excludes>

</resource>

<resource>

<directory>src/main/resources/</directory>

</resource>

</resources>

 

6. 拷贝资源文件到指定文职

 <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <version>2.6</version>
        <executions>
          <execution>
            <id>copy-resources</id>
            <!-- here the phase you need -->
            <phase>validate</phase>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <configuration>
              <outputDirectory>${basedir}/target/extra-resources</outputDirectory>
              <resources>          
                <resource>
                  <directory>src/non-packaged-resources</directory>
                  <filtering>true</filtering>
                </resource>
              </resources>              
            </configuration>            
          </execution>
        </executions>
      </plugin>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值