eclipse-m2e/m2e-core

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

Frettman opened this issue · 2 comments

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.

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

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?