Skip to content

FilteringUtils always copies file while comment says otherwise #321

@schwarfl

Description

@schwarfl

Affected version

3.3.2, 3.4.0, master

Bug description

Starting with https://issues.apache.org/jira/browse/MSHARED-1216, the method
public static void copyFile(Path from, Path to, String encoding, FilterWrapper[] wrappers, boolean overwrite)
in FilteringUtils always copies the file, while the javadoc comment states "If wrappers is null or empty, the file will be copy only if to.lastModified() < from.lastModified() or if overwrite is true".
I'm not sure if it is a bug or a feature, but I would like to explain the problem a bit more:
the maven-resources-plugin in version 3.3.1 is using maven-filtering in version 3.3.1, the new version 3.4.0 (from November 2025) is using maven-filtering 3.4.0. In our project are two test resources directories, T1 and T2. Another plugin copies files from T1 to T2 and modifies them. With the maven-resources-plugin in version 3.3.1 always the newest version from T2 was copied then into the target/test-classes folder. With the new version 3.4.0 of the maven-resources-plugin, suddenly the order of test resources matters. If T2 occurs before T1, the target folder will contain the wrong files from T1 (because the maven-filtering copies first the T2 files and overwrites them afterwards with the T1 files). Because the comment of FilteringUtils still states that the file will only be copied if the target file is older than the source file, I am not sure if this change was intended or not.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions