airlift / airbase

Base POM for Airlift
Apache License 2.0
48 stars 87 forks source link

Use ISO-8859-1 when filtering properties files #329

Closed findepi closed 1 year ago

findepi commented 1 year ago

Properties files are standardized to be encoded with ISO-8859-1. maven-resources-plug now allows setting a specific encoding for properties files and even generates a build-time message when this configuration is not used.

This can be e.g. observed in a Trino build

[INFO] --- maven-resources-plugin:3.2.0:resources (default-resources) @ trino-testing-services ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] Copying 1 resource
[INFO] Copying 1 resource
[INFO] The encoding used to copy filtered properties files have not
been set. This means that the same encoding will be used to copy
filtered properties files as when copying other filtered resources. This
might not be what you want! Run your build with --debug to see which
files might be affected. Read more at
https://maven.apache.org/plugins/maven-resources-plugin/examples/filtering-properties-files.html
martint commented 1 year ago

I don't think we want this. We should standardize on UTF-8 instead.

Since Java 9, resource bundles for internationalization (which are also properties files) are expected to be UTF-8 by default (see https://openjdk.org/jeps/226). Incidentally, this change would make it hard to use property resource bundles in an airlift-based project.

findepi commented 1 year ago

Since Java 9, resource bundles for internationalization (which are also properties files) are expected to be UTF-8 by default

Noticed that. Projects like Trino don't use resource bundles though Should i move this change to Trino?

Also, even if we say "i want my properties files to be treated as latin1 by maven" will editors / IDEs listen? IntelliJ opens .properties files using ISO-8859-1 by default.

martint commented 1 year ago

IntelliJ docs say:

[...] Alternatively, you can define the default encoding for properties files on the project level and use a different API that can read properties files in the encoding you have defined.

https://www.jetbrains.com/help/idea/properties-files.html#encoding

I wonder if there's a way to make it adopt that setting from observing something in the pom, similar to how it handles the JDK version to use for the project.

findepi commented 1 year ago

in theory, this should already do it

https://github.com/trinodb/trino/blob/70d02427402818528cf8e76f0f760d54ed64df1c/.editorconfig#L4-L5

findepi commented 1 year ago

rebased and resolved conflict in CHANGES.

note that this addresses build-time warning from maven.

findepi commented 1 year ago

maven prints this warning-like message at INFO, so i will just ignore it