Maven Resources Plugin: Build Essentials Explained

Updated

Apache Maven logo

The Maven Resources Plugin copies files from src/main/resources into the build output and, on request, filters ${...} placeholders inside them. It has three goals (resources:resources, resources:testResources and resources:copy-resources), and its current version is 3.5.0, published 2026-03-02.

Dependency exclusions and dependency:tree are not Resources Plugin features

Excluding a transitive dependency with <exclusions>, setting a dependency <scope> and running dependency:tree to inspect the dependency graph are not Resources Plugin features. dependency:tree is a goal of the Maven Dependency Plugin: per the Dependency Plugin’s own page, its purpose is to “manipulate artifacts. It can copy and/or unpack artifacts from local or remote repositories to a specified location,” and dependency:tree, “displays the dependency tree for this project,” is one of its listed goals. As of 2026-10-06, the Dependency Plugin is at 3.11.0 (published 2026-05-24) and the Resources Plugin, this page’s actual subject, is at 3.5.0 (published 2026-03-02), per each plugin’s own site. Maven Central’s metadata, read on 2026-10-06, lists 3.11.0 as the Dependency Plugin’s latest release; for the Resources Plugin it also lists a 4.0.0-beta-1 pre-release.

Against the live pages on maven.apache.org, maven-resources-plugin.sh checks that the Resources Plugin page documents resources:resources and that the Dependency Plugin page documents dependency:tree and describes the plugin as manipulating artifacts. It does not check the version numbers or the changeDetection modes, and it skips the network checks when the pages cannot be fetched.

What the Maven Resources Plugin actually does

Three goals, per the plugin’s documentation:

  • resources:resources copies main resources to project.build.outputDirectory, bound to the process-resources lifecycle phase automatically.
  • resources:testResources does the same for test resources, bound to process-test-resources.
  • resources:copy-resources copies resources to an output directory you specify by hand, not bound to a phase.

Filtering, the placeholder-replacement feature, is enabled per resource directory in pom.xml:

<build>
  <resources>
    <resource>
      <directory>src/main/resources</directory>
      <filtering>true</filtering>
    </resource>
  </resources>
</build>

With that set, a resource file containing Hello ${name} gets ${name} replaced from project properties, system properties, the <properties> block, external <filters> files, and -D command-line overrides. Apache’s Maven Filtering documentation gives the load order for those values and says the last defined key wins: properties files passed in by the calling plugin, then the filters in the POM’s <build>/<filters> section, then the POM’s <properties> section, then the Maven session’s execution properties. Apache’s own example warns plainly: don’t filter binary files (images, PDFs): filtering treats content as text and will corrupt them. Route binary and filtered resources through separate <resource> entries.

Use changeDetection, not the deprecated overwrite

The resources:resources mojo’s own reference page documents overwrite (boolean, default false) as deprecated in favor of changeDetection, a parameter added in 3.5.0, the current version. It has five modes: content (the default, compares file content), timestamp, timestamp+content, always (equivalent to the old overwrite=true) and never (never overwrites an existing target file). If you’re configuring this plugin today, changeDetection is the current documented parameter: overwrite still works but the docs point you away from it.

What this page won’t do

Maven was not installed or run for this page, so there is no real mvn resources:resources output to paste here, and none is invented. Every claim above is a direct citation to an Apache page (the maven.apache.org plugin and filtering pages, and Maven Central), fetched 2026-10-06 and labelled as such; none of it is demonstrated execution. If you need Gradle-vs-Maven comparison ground (build speed claims, JDK compatibility, dependency scope syntax across both tools), that’s already covered, with a real dated JDK-compatibility check against JDK 26.0.2, in the Gradle vs Maven page; this page doesn’t repeat it.

Checked against Apache’s documentation, not executed

Checked on 2026-10-06 against each plugin’s own current documentation page and Maven Central: the three Resources Plugin goals, the filtering configuration and load order, the overwrite → changeDetection deprecation and its default, the Dependency Plugin’s stated purpose and its dependency:tree goal, and both plugins’ current version numbers and publish dates. Not verified: any actual build output, since Maven was not run for this page. Every code block above is either an XML/config example from Apache’s own docs or the literal quoted text of a documented default, never a paste presented as if it were executed.

Photo of author
Sudhir P. founded HeatWare.com in 1999 and has built and operated it full-stack ever since; it is now used by more than 88,000 people. He writes here about the PostgreSQL, MySQL, Linux and DevOps work that keeps it running. Articles are rewritten only after the commands in them have actually been run, and the verification scripts are published alongside them so anyone can check the claims. Reach him at blog@heatware.net.