Question

Per Jar specification manifest encoding has to be UTF-8. In some scenario (eg merge), manifests produced by ant's jar task got corrupted and special chars would be double encoded.

Original manifest (utf-8):

...
Application-Name: spécial
...

Final manifest (utf-8) after beeing processed by ant's jar task:

...
Application-Name: spécial
...
Était-ce utile?

La solution

Jar tasks beeing able to process file-sets allows the developper to specify the original manifest character encoding.

Unfortunately, although the mandatory (final) encoding is utf-8 there is no default in ant's jar task and then the original manifest processing is relying on the platform default... Windows-1252 in my case where the original manifest (coming from another jar) is truly in utf-8

Solution : specify the encoding in the task attribute

    <jar destfile="final.jar" filesetmanifest="merge" manifestencoding="UTF-8">
        <zipfileset src="original.jar">
    [...]
        </zipfileset>
    </jar>

Autres conseils

I've just found my old bugreport about this for NetBeans.

As a workaround, I added manifestEncoding="${source.encoding}" attribute to the copylibs tag in build-impl.xml

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top