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>

猜你喜欢

转载自sharp-fcc.iteye.com/blog/1869801