Based on this comment I am trying to copy an empty directory from test resources folder in Maven based project to the test build output but with no luck. I have already been successfully using maven-resource-plugin for copying basic resources so I tried to add another execution part for test resources like this to my pom.xml:
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.7</version>
<executions>
<execution>
<id>copy-resource</id>
<phase>package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<includeEmptyDirs>true</includeEmptyDirs>
<outputDirectory>${project.build.outputDirectory}</outputDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
</configuration>
</execution>
<execution>
<id>copy-test-resource</id>
<phase>package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<includeEmptyDirs>true</includeEmptyDirs>
<outputDirectory>${project.build.testSourceDirectory}</outputDirectory>
<resources>
<resource>
<directory>src/test/resources</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
I also tried to define it in build section like this:
<testResources>
<testResource>
<directory>src/test/resources</directory>
</testResource>
</testResources>
but it also didn't help.
All files and non-empty directories gets correctly copied but the single empty directory doesn't.
Thanks for any help or advice.
Finally, I solved it!
The problem is that element <includeEmptyDirs> was in the wrong place in the plugin section. it should be a part of plugin configuration, NOT part of execution configuration.
Also I changed goal of copy-test-resource to testResources and outputDirectory to ${project.build.testOutputDirectory}
So the correct plugin section is following:
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.7</version>
<configuration>
<includeEmptyDirs>true</includeEmptyDirs>
</configuration>
<executions>
<execution>
<id>copy-resource</id>
<phase>package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.outputDirectory}</outputDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
</configuration>
</execution>
<execution>
<id>copy-test-resource</id>
<phase>package</phase>
<goals>
<goal>testResources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.testOutputDirectory}</outputDirectory>
<resources>
<resource>
<directory>src/test/resources</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With