Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

maven-resources-plugin breaks the resource copy to test-classes

Normally, my POM file is working fine and all unit tests pass and all artifacts are packaged properly. However, once I've added this maven-resources-plugin to create specific configuration depending upon profile all my tests fail because nothing in 'src/test/resources' is copied to 'test-classes':

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-resources-plugin</artifactId>
            <version>2.7</version>
            <configuration>
                <overwrite>true</overwrite>
                <outputDirectory>${project.build.directory}/${config.dir}/${project.activeProfiles[1].id}</outputDirectory>
                <resources>
                    <filtering>true</filtering>
                    <resource>
                        <directory>src/main/resources</directory>
                    </resource>
                </resources>
            </configuration>
        </plugin>   

I don't understand why this would block the copying of test resources. Any ideas?

like image 837
TemarV Avatar asked Jan 21 '15 15:01

TemarV


Video Answer


1 Answers

After much trial and error, I came to a solution. The maven-resources-plugin needed to be attached to the process-resources phase in order for everything to resolve as expected. Now, this may not be the best answer, but it worked for me. Let me know if you have a better solution.

<executions>
  <execution>
     <id>create specific server configuration</id> 
     <phase>process-resources</phase> 
     <goals>
       <goal>resources</goal> 
     </goals>
    <configuration>
    /** as above **/
    </configuration>
  </execution>
</executions>
like image 78
TemarV Avatar answered Nov 15 '22 05:11

TemarV