apache / apache/maven-remote-resources-plugin
useProjectFiles bypasses Velocity rendering for .vm overrides
- Dominant language
- Java
- Stars
- 17
- Forks
- 18
- Avg merge
- 6h 5m
- Merged PRs (30d)
- 5
Description
## 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`
```java
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
1. 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.
2. It only looks for `/`, ignoring `/.vm` — inconsistent with `copyResourceIfExists()` (`:614-664`) which checks both `` and `.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 `` and `.vm`, and when the `.vm` file is used, render it through `velocity.evaluate(...)` with the same encoding handling.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in src/main/java/org/apache/maven/plugin/resources/remote/AbstractProcessRemoteResourcesMojo.java, comparing copyProjectRootIfExists() at lines 666-679 with copyResourceIfExists() at lines 614-664. Verify the project-root override path handles both plain files and .vm files, renders Velocity templates with the appropriate encoding, and no longer emits raw template syntax.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100