Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MRESOURCES-268] - Report path of offending file on copy/filter error. #15

Closed
wants to merge 1 commit into from
Closed

Conversation

sebthom
Copy link
Contributor

@sebthom sebthom commented Jan 12, 2021

Changes DefaultMavenFileFilter#copyFile to contain the path to the offending file as part of the thrown MavenFilteringException.

Without this change end-users won't see which file caused the error.

@sebthom sebthom changed the title MRESOURCES-268 Report path of offending file on copy/filter error. [MRESOURCES-268] - Report path of offending file on copy/filter error. Jan 12, 2021
@@ -110,7 +110,8 @@ public void copyFile( File from, File to, boolean filtering, List<FileUtils.Filt
}
catch ( IOException e )
{
throw new MavenFilteringException( e.getMessage(), e );
throw new MavenFilteringException( ( filtering ? "filtering " : "copying " ) + from.getPath() + " to "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose to duplicate information like here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean with duplicate information? When maven-resources-plugin currently fails, it only displays a cryptic error message like [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources) on project test: Input length = 1 -> [Help 1] without any context information. Even when using mvn -e the displayed stacktrace does not show any information about the file that failed during the operation.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The the root cause does not bubble up, then this is crap. Likely the log message is not ok. You should not try for this the symptom here. Please look in MRESOURCES where this exception is handled.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The maven resources plugin is delegating the iteration over files to MavenResourcesFiltering, thus is not aware of the file for which filtering fails and therefore cannot report the file path.

Adding the file paths to the error message here has the advantage that all potential code paths to DefaultMavenFileFilter will be covered.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To illustrate the effect of this PR some screenshots:

  1. error message before this PR

image

  1. error message with this PR

image

@sebthom
Copy link
Contributor Author

sebthom commented Jan 24, 2021

@khmarbaise @hboutemy any thoughts?

@michael-o
Copy link
Member

I starred this, will pick up when I can unless someone else beats me in.

Changes DefaultMavenFileFilter#copyFile to contain the path to the
offending file as part of the thrown MavenFilteringException.
Without this change end-users won't see which file caused the error.
@sebthom
Copy link
Contributor Author

sebthom commented Feb 5, 2021

I pushed a change since apparently not only checked IOExceptions but also intenral runtime exceptions (e.g. IllegalArgumentExcpetion) are thrown since version 3.2.0 of the maven-resource-plugin when a filtered file has an unexpected encoding.

Here is real world example. A submodule of a very large multi-artifact/module enterprise application. Without this PR it have would been very laborious (and maybe impossible for the average developer) to discover the root cause.

Before this PR:
image

After this PR:
image

slachiewicz pushed a commit that referenced this pull request Dec 6, 2021
Changes DefaultMavenFileFilter#copyFile to contain the path to the
offending file as part of the thrown MavenFilteringException.
Without this change end-users won't see which file caused the error.

Closes #15
@tommai78101
Copy link

tommai78101 commented Dec 16, 2022

I see this pull request being referenced from the Apache Maven Resource Plugins changelog:

https://blogs.apache.org/maven/entry/apache-maven-resources-plugin-version1

I would like to know if this fixes the Input length = 1 error seen in Maven build console logs? Or there was no fix at all?

What is the current status of the issue right now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants