Maven 避免某些文件被复制到 test-类

Maven avoid certain files from being copied to test-classes

我试图避免某些文件类型未在 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>

我终于可以做我想做的事了:

<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我能够避免将我想复制到 target/test-classes

的文件