apache / apache/maven-filtering

File name filtering does not work when the escapeString is the same as the file separator

Open
#289 5 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Java
Stars
9
Forks
36
Avg merge
8h 47m
Merged PRs (30d)
4

Description

### Affected version

3.3.1

### Bug description

On Windows, configure the maven-resources-plugin with `fileNameFiltering=true` and `escapeString=\`. Attempt to copy a resource from a subfolder of a resource directory, where the filename begins with a maven property. For example, use the following pom.xml:


4.0.0

com.test
FileNameFiltering
0.0.1-SNAPSHOT

FileNameFiltering
Reproduction of file name filtering bug


myFileName





maven-resources-plugin
3.3.1





maven-resources-plugin


copy-resources-filter-filename
process-resources

copy-resources


${project.build.outputDirectory}
true
\


${project.basedir}/src/main/custom-resources
false








and create empty file `src\main\custom-resources\folder\${file.name}.txt`. Expected result is the file `target\classes\folder\myFileName.txt` is created. Instead, `target\classes\folder${file.name}.txt` is created, where the subdirectory is lost and becomes part of the file name, which is not filtered.

It appears the filtering is applied to the relative path name as a whole, `folder\${file.name}.txt`, and the file separator is treated as an escape. The filtering should be applied to each file component separately, to remove the conflict with the file separator.

Presumably this can also be reproduced on linux/mac by setting `escapeString=/`, tho this is more likely to be an issue on Windows, since using `escapeString=\` is a common practice.

See the reproduction in this [GitHub repo](https://github.com/pbarnes-tibco/maven-resources-plugin-issue)

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the reproduction repository and its pom.xml, then run the Windows case using fileNameFiltering=true and escapeString=\. Inspect how the relative path folder\${file.name}.txt is filtered; done means the output is target\classes\folder\myFileName.txt without losing the subdirectory.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.