0

I'm trying to avoid that certain file types don't end copied in target/test-classes. The code I have right now in my pom file but it's not working is:

<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>
republicca
  • 43
  • 1
  • 8
  • 1
    If they are not test resources, why are those files under `src/test/resources` in the first place? – Ralf May 04 '18 at 07:38
  • Simple answer remove them from `src/test/resources`... – khmarbaise May 04 '18 at 08:48
  • But i do want them inside src/test/resources just not all of them to be copied to target/test-classes because some of them are quite big and it takes too long to compile – republicca May 04 '18 at 10:23
  • Than I ask a again. Why do you need them in `src/test/resources` if don't like to get them copied? Either you need or not? If they are needed for tests I would think hard about your tests if they are going the right path...furthermore what do you mean by "quite big"? – khmarbaise May 04 '18 at 18:37

1 Answers1

1

I was finally able to do what I wanted with:

<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>

With this code, which is very similar to the one I posted in the question, and by changing the maven version in my eclipse settings from 3.3.3 to 3.3.9 I'm able to avoid the files that I wanted to be copied to target/test-classes

republicca
  • 43
  • 1
  • 8