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

Property files not copied to target/classes when they contain umlauts #1571

Open
Frettman opened this issue Oct 5, 2023 · 2 comments
Open

Comments

@Frettman
Copy link

Frettman commented Oct 5, 2023

I have a few properties files (in ISO 8859-1), but when they contain e.g. an umlaut (öäüÖÄÜ), they are no longer copied to target/classes. If the file exists there already, it isn't touched. If it doesn't exist, an empty file is created. And once such a file is encountered, it completely stops further processing of other resources.
So far, this only seems to affect properties files. The error log didn't contain any related information.

It seems to work with a fresh Eclipse install and/or new minimal project, but I can reproduce this on several installations with actual projects. So there seems to be an additional factor besides the umlauts, but so far couldn't narrow it down further.

Tested with m2e 2.4.100.20230827-1557 (as contained in latest Spring STS 4.20.0) and some older versions.

@HannesWell
Copy link
Contributor

Can you provide a minimal reproducer for this issue, ideally as an PR for a test-case?
Maybe this is also related to #1511.

@Frettman
Copy link
Author

What did you have in mind? A project? An affected properties file? Also not sure how to package that as a test-case.

Anyway, I did some more testing and it seems related to the encoding of the properties file.
First some facts for context:

  • Regular properties files read by java.util.Properties are still expected to use ISO 8859-1 encoding (unless you provide your own Reader and take care of encoding yourself).
  • Resource bundles read by java.util.PropertyResourceBundle now are expected to have UTF-8. Though there is a fallback to ISO-8859-1 when encoding errors are detected. This was changed in Java 9, I believe?
  • In a current version of Eclipse/STS the default encoding for arbitrary properties files is UTF-8. This will be correct for resource bundle files, but wrong for regular properties files.
  • In a current version of Eclipse/STS the default encoding for recognized application.properties files is ISO 8859-1. This is never a resource bundle, so this seems always correct.

The issue only seems to be with properties files in the ISO 8859-1 encoding. So it seems that there is an assumption that every properties file is in UTF-8.
The deciding factor seems to be the actual encoding of the file; the "Text file encoding" setting from the Eclipse has no effect.

Is this related to the project.build.sourceEncoding which is UTF-8 in my (and probably most) cases, which is also used for the resource processing of the resource plug-in? Maybe the Maven plug-in handles resources with the "wrong" encoding just more gracefully?

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

No branches or pull requests

2 participants