logo Apache Maven Resources Plugin

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.

homepage: maven.apache.org/plugins
fresh index:
last release: 1 year ago, first release: 2 decades ago
packaging: maven-plugin
get this artifact from: central
see this artifact on: search.maven.org


Display vulnerabilities (snyk): Vulnerability check

This chart shows how much is this artifact used as a dependency in other Maven artifacts in Central repository and GitHub:


select version:

Add this snippet into pom.xml inside tag <project><build><plugins>:




Switch to artifact.
goals:
resources:copy-resources

Copy resources of the configured plugin attribute resources

resources:help

Display help information on maven-resources-plugin. Call mvn resources:help -Ddetail=true -Dgoal=<goal-name> to display parameter details.

resources:resources (phase: process-resources)

Copy resources for the main source code to the main output directory. Always uses the project.build.resources element to specify the resources to copy.

resources:testResources (phase: process-test-resources)

Copy resources for the test source code to the test output directory. Always uses the project.build.testResources element to specify the resources to copy.

Often used code snippets:

<plugin>
  <artifactId>maven-resources-plugin</artifactId>
  <version>2.6</version>
  <executions>
    <execution>
      <id>copy-resources</id>
      <phase>generate-resources</phase>
      <goals>
        <goal>copy-resources</goal>
      </goals>
      <configuration>
        <outputDirectory>src/main/resources</outputDirectory>
        <resources>
          <resource>
            <directory>resources</directory>
            <includes>
              <include>build.properties</include>
              <include>p2.inf</include>
            </includes>
          </resource>
        </resources>
      </configuration>
    </execution>
  </executions>
</plugin>
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-resources-plugin</artifactId>
  <version>2.6</version>
  <configuration>
    <encoding>UTF-8</encoding>
  </configuration>
</plugin>
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-resources-plugin</artifactId>
  <version>${maven-resources-plugin.version}</version>
  <executions>
    <execution>
      <id>default-resources</id>
      <phase>validate</phase>
      <goals>
        <goal>copy-resources</goal>
      </goals>
      <configuration>
        <outputDirectory>target/classes</outputDirectory>
        <useDefaultDelimiters>false</useDefaultDelimiters>
        <delimiters>
          <delimiter>#</delimiter>
        </delimiters>
        <resources>
          <resource>
            <directory>src/main/resources/</directory>
            <filtering>true</filtering>
            <includes>
              <include>config/*.yml</include>
            </includes>
          </resource>
          <resource>
            <directory>src/main/resources/</directory>
            <filtering>false</filtering>
            <excludes>
              <exclude>config/*.yml</exclude>
            </excludes>
          </resource>
        </resources>
      </configuration>
    </execution>
    <execution>
      <id>docker-resources</id>
      <phase>validate</phase>
      <goals>
        <goal>copy-resources</goal>
      </goals>
      <configuration>
        <outputDirectory>target/</outputDirectory>
        <resources>
          <resource>
            <directory>src/main/docker/</directory>
            <filtering>false</filtering>
            <excludes>
              <exclude>**/*.yml</exclude>
            </excludes>
          </resource>
        </resources>
      </configuration>
    </execution>
  </executions>
</plugin>
<plugin>
  <artifactId>maven-resources-plugin</artifactId>
  <executions>
    <execution>
      <id>copy-resources</id>
      <phase>generate-resources</phase>
      <goals>
        <goal>copy-resources</goal>
      </goals>
      <configuration>
        <outputDirectory>src/main/resources</outputDirectory>
        <resources>
          <resource>
            <directory>resources</directory>
            <includes>
              <include>build.properties</include>
              <include>p2.inf</include>
            </includes>
          </resource>
        </resources>
      </configuration>
    </execution>
  </executions>
</plugin>
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-resources-plugin</artifactId>
  <configuration>
    <encoding>UTF-8</encoding>
  </configuration>
</plugin>

© Jiri Pinkas 2015 - 2022. All rights reserved! Admin login To submit bugs / feature requests please use this github page
related: JavaVids | Top Java Blogs | Java školení
Apache and Apache Maven are trademarks of the Apache Software Foundation. The Central Repository is a service mark of Sonatype, Inc.