Allow to configure the version file encoding#408
Allow to configure the version file encoding#408Vampire wants to merge 1 commit intoresearchgate:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces a configurable encoding property for version property files to prevent corruption of non-ASCII characters when using Java 18+ (which defaults to UTF-8 encoding). The new versionPropertyFileEncoding property defaults to 'ISO-8859-1', the standard encoding for Java properties files.
Key Changes:
- Added
versionPropertyFileEncodingproperty toReleaseExtensionwith ISO-8859-1 as the default - Updated all file read and write operations to use the configured encoding
- Documented the new configuration option in README
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| ReleaseExtension.groovy | Adds new versionPropertyFileEncoding property with ISO-8859-1 default |
| UnSnapshotVersion.groovy | Updates properties file reading to use configured encoding |
| PrepareVersions.groovy | Updates version writing to pass encoding parameter |
| BaseReleaseTask.groovy | Updates writeVersion method signature and calls to use encoding parameter |
| PluginHelper.groovy | Updates writeVersion method signature and all calls to use encoding parameter |
| README.md | Documents the new configuration option with default value |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
I thought java uses the encoding that is configured in the system via env variables for example but falls back to the ISO default in case there is nothing configured. If someone would have that configured we might break their files I guess?!? |
b4fe46a to
1bbbb40
Compare
|
Ah, sorry, missed your question.
Java uses the default encoding. In newer Java versions the default changed to always be UTF-8 to fix that mess you always get by just running somewhere different and it suddenly behaves totally different. WIth Gradle in specific it additionally depends on how you run Gradle iirc. The encoding of a Also if you use some other file as version file, it most probably should also not follow the system encoding but have a fixedly defined encoding to not behave differently depending on where it is read. In the - imho - quite unlikely case that someone for example has a |
Without this setting, the JVM default encoding is used. This can easily break files if they contain non-ASCII characters. A properties file for example by definintion is ISO-8859-1 encoded. Java 18+ use UTF-8 as default encoding if nothing else is configured. If you now manipulate the version file using UTF-8, it gets crippled if it contains non-ASCII characters. With this new setting the encoding can be configured, with the appropriate default setting according to the default for the file.
1bbbb40 to
bf1c18d
Compare

Without this setting, the JVM default encoding is used. This can easily break files if they contain non-ASCII characters. A properties file for example by definintion is ISO-8859-1 encoded. Java 18+ use UTF-8 as default encoding if nothing else is configured. If you now manipulate the version file using UTF-8, it gets crippled if it contains non-ASCII characters.
With this new setting the encoding can be configured, with the appropriate default setting according to the default for the file.