1. 程式人生 > >maven 常用外掛

maven 常用外掛

1 maven-compiler-plugin 

[html] view plaincopyprint?在CODE上檢視程式碼片派生到我的程式碼片
  1. <plugin>
  2.     <artifactId>maven-compiler-plugin</artifactId>
  3.     <extensions>true</extensions>
  4.     <configuration>
  5.         <source>1.6</source>
  6.         <target>1.6</target
    >
  7.     </configuration>
  8. </plugin>

2 maven-dependency-plugin 把依賴的jar包拷到指定目錄下 [html] view plaincopyprint?在CODE上檢視程式碼片派生到我的程式碼片
  1. <plugin>
  2.     <groupId>org.apache.maven.plugins</groupId>
  3.     <artifactId>maven-dependency-plugin</artifactId>
  4.     <executions
    >
  5.         <execution>
  6.             <id>copy-dependencies</id>
  7.             <phase>process-resources</phase>
  8.             <goals>
  9.                 <goal>copy-dependencies</goal>
  10.             </goals>
  11.             <configuration>
  12.                 <
    excludeScope>provided</excludeScope>
  13.                 <excludeArtifactIds>
  14.                     module1,module2  
  15.                 </excludeArtifactIds>
  16.                 <outputDirectory>${project.build.directory}/lib</outputDirectory>
  17.             </configuration>
  18.         </execution>
  19.         <execution>
  20.             <id>copy-modules</id>
  21.             <phase>process-resources</phase>
  22.             <goals>
  23.                 <goal>copy-dependencies</goal>
  24.             </goals>
  25.             <configuration>
  26.                 <includeArtifactIds>
  27.                     module1,module2  
  28.                 </includeArtifactIds>
  29.                 <outputDirectory>${project.build.directory}/lib/modules</outputDirectory>
  30.             </configuration>
  31.         </execution>
  32.     </executions>
  33. </plugin>

3 maven-resources-plugin 把依賴的資源拷到指定目錄下

[html] view plaincopyprint?在CODE上檢視程式碼片派生到我的程式碼片
  1. <plugin>
  2.     <groupId>org.apache.maven.plugins</groupId>
  3.     <artifactId>maven-resources-plugin</artifactId>
  4.     <version>2.6</version>
  5.     <executions>
  6.         <execution>
  7.             <id>copy-resources</id>
  8.             <!-- here the phase you need -->
  9.             <phase>validate</phase>
  10.             <goals>
  11.                 <goal>copy-resources</goal>
  12.             </goals>
  13.             <configuration>
  14.                 <outputDirectory>${basedir}/target/test-classes</outputDirectory>
  15.                 <