Maven避免将某些文件复制到测试类

时间:2018-05-04 06:41:11

标签: maven maven-resources-plugin

我试图避免某些文件类型不会在target / test-classes中复制。我现在在我的pom文件中的代码但它不起作用是:

<plugin>
 <groupId>org.apache.maven.plugins</groupId>        
  <artifactId>maven-resources-plugin</artifactId>
   <executions>
    <execution>
     <id>default-testResources</id>
      <phase>process-resources</phase>
       <goals>
        <goal>testResources</goal>
       </goals>
       <configuration>                       
        <outputDirectory>
         ${project.build.directory}/test-classes
        </outputDirectory>
        <testResources>
         <testResource>
          <directory>src/test/resources</directory>
          <filtering>true</filtering>                                   
          <excludes>
           <exclude>**/*.nc</exclude>
          </excludes>
        </testResource>
       </testResources>
      </configuration>
     </execution>               
    </executions>
  </plugin>

1 个答案:

答案 0 :(得分:0)

我终于能够做我想做的事了:

<execution>
 <id>default-testResources</id>
 <phase>test-compile</phase>
 <goals>
  <goal>testResources</goal>
 </goals>
 <configuration>
  <resources>
   <resource>
    <directory>${project.basedir}/src/test/resources </directory>
    <excludes>
     <exclude>**/*.nc</exclude>
    </excludes>
   </resource>
  </resources>
 </configuration>
</execution>

使用此代码,与我在问题中发布的代码非常相似,并且通过将我的eclipse设置中的maven版本从3.3.3更改为3.3.9我能够避免我想要复制到目标/测试类的文件