I have a pom.xml file with the following:
<sourceDirectory>${basedir}/src/main/test</sourceDirectory>
<outputDirectory>${basedir}/src/main/bin </outputDirectory>
Inside ${basedir}/src/main/test
I have some folders which do not contain any .java files. When I start a compilation they are not copied to ${basedir}/src/main/bin
directory.
Only .java files are moved (after compilation of course) and stored on the right folder.
Can someone help me to solve this problem without using any plugin ?
I tried with
<resources>
<resource>
<filtering>false</filtering>
<directory>${basedir}/src/main/test/scenarios</directory>
<includes>
<include>*.xml</include>
</includes>
<targetPath>${basedir}/src/main/bin/scenarios</targetPath>
</resource>
<resource>
<filtering>false</filtering>
<directory>${basedir}/src/main/test/sut</directory>
<includes>
<include>*.xml</include>
</includes>
<targetPath>${basedir}/src/main/bin/sut</targetPath>
</resource>
</resources>
But it does not work. What is wrong?
Apache Maven Resources Plugin – Including and excluding files and directories.
As both goals of the compiler plugin are automatically bound to phases in the Maven default lifecycle, we can execute these goals with the commands mvn compile and mvn test-compile.
You can add src/main/test as a resource directory using the maven resources plugin. see http://maven.apache.org/plugins/maven-resources-plugin/examples/resource-directory.html for basic information and http://maven.apache.org/plugins/maven-resources-plugin/examples/include-exclude.html for information on only including certain files (since you won't want to copy your .java files)
If they are not java files you should move them to the src/main/resources
and/or src/test/resources
directory. That's the maven convention for storing the non java files.
Your other option is to use the maven-resources-plugin.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.3</version>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/test</directory>
<includes>
<include> <the_files_you_want_to_include></include>
</includes>
</resource>
</resources>
You have another option is to use the maven-antrun-plugin and execute an ant task to copy the files manually.
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