Usage
To handle filtering this version of Maven Remote Resources Plugin uses Maven Filtering 3.3.2.
How to Create a Resource Bundle
To turn on the bundle resource manifest generation you need to configure the plugin as follows:
<project> ... <build> <plugins> <!-- Turn this into a lifecycle --> <plugin> <artifactId>maven-remote-resources-plugin</artifactId> <version>3.2.0</version> <executions> <execution> <goals> <goal>bundle</goal> </goals> </execution> </executions> </plugin> </plugins> </build> ... </project>
This will trigger the scanning of that project's ${basedir}/src/main/resources
directory and create the ${basedir}/target/classes/META-INF/maven/remote-resources.xml
manifest file.
Note: The files have to be named like *.vm
to mark them as Velocity macro files which will be filtered by the process goal. If you don't name the files according to this, they will not be filtered.
How to Use Remote Resource Bundles
To use remote resource bundles you need to configure the plugin as follows:
<project> ... <build> <plugins> <!-- Turn this into a lifecycle --> <plugin> <artifactId>maven-remote-resources-plugin</artifactId> <version>3.2.0</version> <executions> <execution> <id>process-remote-resources</id> <goals> <goal>process</goal> </goals> <configuration> <resourceBundles> <resourceBundle>org.apache:apache-jar-resource-bundle:1.0</resourceBundle> </resourceBundles> </configuration> </execution> </executions> </plugin> </plugins> </build> ... </project>
This will retrieve the apache-jar-resource-bundle-1.0.jar
from the remote repositories specified in your POM, process each resource in the bundle and deposit them in your projects ${basedir}/target/classes
directory.
Running Once in a Multi-Module Build
Note: The parameter runOnlyAtExecutionRoot
was removed in version 3.1.0 and was replaced by aggregate
goal.
In many cases, an application build consists of multiple Maven modules, but you only need to include the license files, dependencies listing, etc. once for the entire application. Of course, in such cases, the dependencies listing needs to aggregate all dependencies of all modules.
To accomplish this, you can use the aggregate
goal when you configure the Remote Resources Plugin in your application root POM. You must configure execution with inherited set to false to limit execution only in root POM of your application.
In most cases, the application's distribution archives will be created at this top directory, so this is a natural location into which licensing and dependency information should be generated.
To run the Remote Resources Plugin only in the root of your project, use the following:
<project> ... <build> <plugin> <artifactId>maven-remote-resources-plugin</artifactId> <version>3.2.0</version> [...] <executions> <execution> <id>process-remote-resources</id> <inherited>false</inherited> <goals> <goal>aggregate</goal> </goals> <configuration> [...] </configuration> </execution> </executions> </plugin> </build> ... </project>
Specifying Delimiters for Filterable Expressions
Note: This feature was added in version 1.1.
By default, the Remote Resources Plugin supports expressions specified using either the '${expr}
' or '@expr@
' format. However, at times it may be more convenient to use a different set of filter delimiters. By configuring the filterDelimiters
and useDefaultFilterDelimiters
parameters, you have a high degree of control over the filtering process.
To enable the filter delimiters for the format '#{expr}
' (Ruby-style), add the following to your plugin configuration:
<project> ... <build> <plugin> <artifactId>maven-remote-resources-plugin</artifactId> <version>3.2.0</version> <executions> <execution> <id>process-remote-resources</id> <goals> <goal>process</goal> </goals> <configuration> <filterDelimiters> <filterDelimiter>#{*}</filterDelimiter> </filterDelimiters> [...] </configuration> </execution> </executions> </plugin> </build> ... </project>
Notice the '*
' character above. This denotes the dividing point between start and end delimiter, where the actual expression will be specified.
If your start and end delimiters are the same, you can use an even simpler configuration. For example, to enable filter delimiters for the format '#expr#
', add the following to your plugin configuration:
<project> ... <build> <plugin> <artifactId>maven-remote-resources-plugin</artifactId> <version>3.2.0</version> <executions> <execution> <id>process-remote-resources</id> <goals> <goal>process</goal> </goals> <configuration> <filterDelimiters> <filterDelimiter>#</filterDelimiter> </filterDelimiters> [...] </configuration> </execution> </executions> </plugin> </build> ... </project>
When the filter processor executes and notices this delimiter specification missing a '*
' character, it will simply assume the provided delimiter will be used as both the start and end delimiter for an expression.
All of the above assumes that you still want the ability to use '${expr}
' and '@expr@
' delimiters. However, in cases where this would cause trouble, you can disable these default delimiters as follows:
<project> ... <build> <plugin> <artifactId>maven-remote-resources-plugin</artifactId> <version>3.2.0</version> <executions> <execution> <id>process-remote-resources</id> <goals> <goal>process</goal> </goals> <configuration> <useDefaultFilterDelimiters>false</useDefaultFilterDelimiters> [...] </configuration> </execution> </executions> </plugin> </build> ... </project>