[GRADLE-3374] Jar manifests content should be encoded using UTF-8 Created: 29/Dec/15 Updated: 23/May/16 Resolved: 18/May/16 |
|
Status: | Resolved |
Project: | Gradle |
Affects Version/s: | None |
Fix Version/s: | 2.14-rc-2 |
Type: | Bug | ||
Reporter: | Mark Vieira (Inactive) | Assignee: | Paul Merlin |
Resolution: | Fixed | Votes: | 1 |
Attachments: | mf-test.7z |
Description |
Currently Jar manifests use the platform default encoding. Perhaps instead a default of UTF-8 should be used or provide the option for explicitly setting the file encoding. https://discuss.gradle.org/t/manifest-encoding-broken/13477 |
Comments |
Comment by guai [ 31/Dec/15 ] |
Netbeans developers think UTF-8 is mandatory in manifest too. here |
Comment by guai [ 22/Apr/16 ] |
There is more to this. |
Comment by guai [ 22/Apr/16 ] |
In fact modern java loads manifests with lines greater than 72 bytes ok. |
Comment by guai [ 22/Apr/16 ] |
Sorry. I was wrong. In fact java.util.jar.Manifest can make split-chars, but it can read them back as well. I hit error in Netbeans, maybe they use nonstandard reader, I don't know... Or maybe it's something else. cr-lf/lf maybe |
Comment by Paul Merlin [ 23/Apr/16 ] |
Under the hood, Gradle uses Ant Manifest class that does the right thing wrt. line length and encoding. |
Comment by guai [ 23/Apr/16 ] |
I saw manifests generated by gradle with 72-bytes-split inside of a multibyte char. And I then hit some problems loading this modules with Netbeans. |
Comment by guai [ 25/Apr/16 ] |
That's crazy but manifest.mf extracted from target jar and generated-manifest.mf which I think is what should have been packaged - they differs. |
Comment by guai [ 25/Apr/16 ] |
Or maybe the problem is in gradle's jar task |
Comment by guai [ 25/Apr/16 ] |
Here is simple reproducing script. run gradle netbeans and then mf-test.groovy |
Comment by guai [ 25/Apr/16 ] |
It definitely is a gradle bug. org.gradle.api.java.archives.internal.DefaultManifest#attributes already contains broken chars. |
Comment by guai [ 18/May/16 ] |
Manifests still not in UTF-8 unless set GRADLE_OPTS=-Dfile.encoding=UTF-8 is set. |
Comment by guai [ 18/May/16 ] |
Reproducible on the same attached test project. Both issues still there. Manifest is not in UTF-8 unless -Dfile.encoding=UTF-8. And symbols being corrupted after split-join on 72-bytes line length limit when it's inside multibyte characters.
|
Comment by Paul Merlin [ 18/May/16 ] |
Thanks for your feedback! First, try this sample build that demonstrate how charsets are chosen when dealing with manifests: https://github.com/eskatos/gradle-3374 You can play with it. For example, remove the contentCharset used to read the merged manifest so that the default platform charset will be used. In your sample I think the nbm plugin reads some generated manifest from disk using the default platform charset and things starts to break. We changed Gradle's code so that, by default, it generates manifests using UTF-8 but read merged manifests using the platform charset. This decision was taken with backward compatibility in mind but it looks like it wasn't a good idea. Will get back to you shortly. If you have any more feedback, keep it coming! |
Comment by guai [ 19/May/16 ] |
Paul, I could break your example |
Comment by Paul Merlin [ 19/May/16 ] |
> Paul, I could break your example |
Comment by Paul Merlin [ 19/May/16 ] |
Thanks to your feedback I dug a bit more and I'm close to a proper fix. To be continued |
Comment by Paul Merlin [ 20/May/16 ] |
Hi, In case you need it, here is the incantation that installs Gradle from sources: |
Comment by guai [ 23/May/16 ] |
ok, I'll try |
Comment by guai [ 23/May/16 ] |
Everything is fine. I couldn't break anything. |
Comment by Paul Merlin [ 23/May/16 ] |
Great. Thanks! |