[
https://issues.apache.org/jira/browse/MSHARED-1285?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17788310#comment-17788310
]
ASF GitHub Bot commented on MSHARED-1285:
-----------------------------------------
laeubi commented on PR #77:
URL: https://github.com/apache/maven-filtering/pull/77#issuecomment-1820426240
> @laeubi would it be possible to add a unit test that showcases the issue
and the proposed fix?
It should be possible to reproduce the problem a testcase should be setup
like this:
1. `BuildContext` reports an incremental build
2. There should be resource `A` + `B`
3. The resource target folder is empty
4. `BuildContext` only contains a change for `A`
Result is only `A` is copied (as it has a change) but `B` is missing because
the Mojo assumes that a file in resource target can never vanish and do assume
it will get a change event for that, what can not be guaranteed as a file can
always be deleted out of the control of maven / IDE /...
Another case is that you *modify* the target file (but not the source) then
the mojo will never update that file as long as one do not modify the source
file.
> DefaultMavenResourcesFiltering uses BuildContext in a way that fails sometimes
> ------------------------------------------------------------------------------
>
> Key: MSHARED-1285
> URL: https://issues.apache.org/jira/browse/MSHARED-1285
> Project: Maven Shared Components
> Issue Type: Bug
> Reporter: Christoph Läubrich
> Priority: Major
>
> The maven resources plugin uses
> [https://github.com/apache/maven-filtering/blob/master/src/main/java/org/apache/maven/shared/filtering/DefaultMavenResourcesFiltering.java]
> to copy resources, but that component has some subtile flaws reported here:
> [https://github.com/eclipse-m2e/m2e-core/discussions/1468]
> The problematic part is the usage of BuildContext#newScanner that already
> mentions in the javadoc that passing ignoreDelta to neScanner might not
> reveal all required items +*for copy-resources*+ form A -> B and instead
> BuildContext#isUpTodate should be used.
> Just from a quick look I assume that part of code actually wants to use
> something like this:
> {code:java}
> DirectoryScanner ds = new DirectoryScanner() {
> @Override
> protected boolean isSelected(String name, File file) {
> if (file.isFile() && buildContext.isUptodate(getTargetFile(file), file))
> {
> return false;
> }
> return true;
> }
> };
> ds.setBasedir(basedir); {code}
> That way all the code that currently checks for if output directory existed
> before can also be removed what is another issue because it leads to a full
> resources copy even if source+target are already even if a single class file
> is changed while the idea seems more that if the output was not there it
> should not try to be incremental!
--
This message was sent by Atlassian Jira
(v8.20.10#820010)