Apache

Docs Plugins

Resources Plugin 3.5.0 · Other versions

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. The difference is that the main resources are the resources associated with the main source code while the test resources are associated with the test source code. Thus, this allows the separation of resources for the main source code and its unit tests.

Source
Edit this page
Wrong?
Report a problem

Custom resources filters

With version 2.5 you are now able to build your own custom resources filter(s).

Your custom resources filter classes must implements org.apache.maven.shared.filtering.MavenResourcesFiltering.

Custom Resources Filter Implementation

Your custom resources filter classes must be marked as a Plexus Component. Below a sample with a roleHint itFilter.


/**
 * @plexus.component role="org.apache.maven.shared.filtering.MavenResourcesFiltering" 
 *                   role-hint="itFilter"
 */
public class ItFilter
    implements MavenResourcesFiltering

Then you must activate in your build the mojo which will scan javadoc annotations to transform thoses to plexus component metadata.


  <plugin>
    <groupId>org.codehaus.plexus</groupId>
    <artifactId>plexus-component-metadata</artifactId>
    <version>1.7.1</version>
    <executions>
      <execution>
        <goals>
          <goal>generate-metadata</goal>
        </goals>
      </execution>
    </executions>
  </plugin>

Dependency declaration

Your classes must be available in the maven-resources-plugin classpath, this can be done with adding your artifact to the plugin dependencies.

<project>
  ...
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-resources-plugin</artifactId>
        <version>3.5.0</version>
        <configuration>
          ...
        </configuration>
        <dependencies>
          <dependency>
            <groupId>custom resources filters artifact groupId</groupId>
            <artifactId>custom resources filters artifact artifactId</artifactId>
            <version>custom resources filters artifact version</version>
          </dependency>
        </dependencies>
      </plugin>
    </plugins>
    ...
  </build>
  ...
</project>

Use of your Custom Resource Filter with the maven-resources-plugin

You must now declare you custom filter in the plugin. mavenFilteringHint must respect same syntax as your Plexus Component roleHint.

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-resources-plugin</artifactId>
    <version>3.5.0</version>
    <configuration>
      ...
      <mavenFilteringHints>
        <mavenFilteringHint>itFilter</mavenFilteringHint>
      </mavenFilteringHints>
     </configuration>
     ...
   </configuration>
 </plugin>

And that's it !