EN
Java / Maven - copy embedded in-source resource files to target
9
points
In this short article, we would like to show how to copy resource files located in src/
directory into target/
directory using Maven.
Quick solution:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
...
<build>
...
<plugins>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<phase>generate-sources</phase>
<configuration>
<target>
<mkdir dir="${pom.basedir}/target/classes" />
<copy todir="${pom.basedir}/target/classes">
<fileset dir="${pom.basedir}/src" includes="**/*.txt" />
</copy>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
...
</plugins>
</build>
</project>