Maven - Resources
About
Maven supports two kinds of resources.
Articles Related
Type
Application
application resources or resources that the application needs
- Default location: basedir/src/main/resources
Test
Test resources used during the test phase and that is not deployed
- Default location: basedir/src/test/resources
- During the test, they are automatically copied over to /target/test-classes.
Configuration
Pom
Maven - pom.xml - Project Object Model. See https://maven.apache.org/pom.html#Resources
<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>
...
<! -- a list of resource elements that each describe what and where to include files associated with this project -->
<resources>
<resource>
<!-- Source Directory (Default: ${basedir}/src/main/resources) -->
<directory>${basedir}/src/main/plexus</directory>
<!-- Target path in the build:
default value: base directory
for a Jar: a common value is META-INF.
-->
<targetPath>META-INF/plexus</targetPath>
<!-- TRUE or FALSE -->
<filtering>false</filtering>
<!-- A set of include files patterns using * as a wildcard. -->
<includes>
<include>configuration.xml</include>
</includes>
<!-- A set of exclude files patterns using * as a wildcard.
Between include and exclude, exclude wins always -->
<excludes>
<exclude>**/*.properties</exclude>
</excludes>
</resource>
</resources>
<!-- test phases resources used during the test phase and that is not deployed -->
<testResources>
<resource>
<!-- Source Directory (Default: ${basedir}/src/test/resources) -->
<directory>${basedir}/src/test/plexus</directory>
</resource>
</testResources>
</build>
</project>
The pom Xml Resources can also use properties.
Management
Filtering
Maven Properties can be included in resources.
See https://maven.apache.org/plugins/maven-resources-plugin/examples/filter.html
Share between modules
See http://maven.apache.org/plugins/maven-remote-resources-plugin/