Summary
copyProjectRootIfExists() copies a project file over a remote bundle resource with a plain, un-rendered copy — no Velocity processing. When a local file overrides a remote .vm template, the raw Velocity syntax is emitted into the output.
src/main/java/org/apache/maven/plugin/resources/remote/AbstractProcessRemoteResourcesMojo.java:666-679
private boolean copyProjectRootIfExists(File outputFile, String bundleResourceName) throws IOException {
if (!useProjectFiles) {
return false;
}
File source = new File(project.getBasedir(), bundleResourceName);
if (source.exists()) {
getLog().debug("Use project file + source + as resource");
FilteringUtils.copyFile(source, outputFile, null, null);
return true;
}
return false;
}
Problems
- The copy uses
FilteringUtils.copyFile(source, outputFile, null, null) — no Velocity mergeTemplate/evaluate. A remote .vm template (foo.txt.vm) overridden by a local foo.txt will be copied verbatim, leaving $project.name etc. unexpanded in the output.
- It only looks for
<basedir>/<name>, ignoring <basedir>/<name>.vm — inconsistent with copyResourceIfExists() (:614-664) which checks both <name> and <name>.vm and renders the .vm variant via Velocity.
This feature is new in 3.3.0, so the inconsistency vs. the established resource-directory override path is surprising.
Suggested fix
Mirror the logic of copyResourceIfExists(): check for both <name> and <name>.vm, and when the .vm file is used, render it through velocity.evaluate(...) with the same encoding handling.
Summary
copyProjectRootIfExists()copies a project file over a remote bundle resource with a plain, un-rendered copy — no Velocity processing. When a local file overrides a remote.vmtemplate, the raw Velocity syntax is emitted into the output.src/main/java/org/apache/maven/plugin/resources/remote/AbstractProcessRemoteResourcesMojo.java:666-679Problems
FilteringUtils.copyFile(source, outputFile, null, null)— no VelocitymergeTemplate/evaluate. A remote.vmtemplate (foo.txt.vm) overridden by a localfoo.txtwill be copied verbatim, leaving$project.nameetc. unexpanded in the output.<basedir>/<name>, ignoring<basedir>/<name>.vm— inconsistent withcopyResourceIfExists()(:614-664) which checks both<name>and<name>.vmand renders the.vmvariant via Velocity.This feature is new in 3.3.0, so the inconsistency vs. the established resource-directory override path is surprising.
Suggested fix
Mirror the logic of
copyResourceIfExists(): check for both<name>and<name>.vm, and when the.vmfile is used, render it throughvelocity.evaluate(...)with the same encoding handling.