I want to know how to copy an entire directory into another directory using Maven without using the Mmaven antrun plugin.
The Maven Clean Plugin, as the name implies, attempts to clean the files and directories generated by Maven during its build. While there are plugins that generate additional files, the Clean Plugin assumes that these files are generated inside the target directory.
Overview With the default Maven layout, we store resource files under the src/main/resources directory. After a build, Maven moves these files to the build output directory - target/classes. So they become available in the application classpath. There are cases where we have resource files under different directories.
The target directory is created by Maven. It contains all the compiled classes, JAR files etc. When executing the mvn clean command, Maven would clean the target directory. The webapp directory contains Java web application, if the project is a web application.
The Resources Plugin handles the copying of project resources to the output directory. There are two different kinds of resources: main resources and test resources.
You can use the Maven resources plugin.
As an example taken from their documentation:
<project>
...
<build>
<plugins>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>copy-resources</id>
<!-- here the phase you need -->
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/extra-resources</outputDirectory>
<resources>
<resource>
<directory>src/non-packaged-resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
...
</build>
...
</project>
This would copy the content of the directory
into the outputDirectory
if I'm not mistaken.
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