How do I specify (or "force") the maven jar plugin to use my spe开发者_运维知识库cific encoding (UTF-8) ?
My build plugin :
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<executions>
<execution>
<phase>package</phase>
<id>configurations-test</id>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classesDirectory>target/test</classesDirectory>
<forceCreation>true</forceCreation>
<finalName>${artifactId}-test</finalName>
</excludes>
</configuration>
</execution>
</executions></plugin>
I set the encoding in the parent pom and every copies is executed with the right encoding
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
I controled the files just before the Jar is created, these are well formated.
Note, I did many tried addind specific encoding to the configuration but it still won't work, in my packaged Jars I found unwell formatted characters (like é, which should be é)
The unzipped files (html, xml, properties etc.) contains such characters like é instead of é.
jar doesn't mess with your files. It just copies the bytes. On the other hand, the resource plugin might.
You need to set ${project.build.sourceEncoding}
.
See http://maven.apache.org/plugins/maven-resources-plugin/copy-resources-mojo.html.
specify UTF encoding property:
<properties> <project.build.sourceEncoding>UTF</project.build.sourceEncoding> </properties>
be warned, i've experienced the following error when I use UTF encoding deploying to wls 10.3.6, not sure others.
java.lang.UnsupportedOperationException: unsupported archive type: zip:/oracle/fmwhome/user_projects/domains/dev_soa_osb/servers/AdminServer/tmp/_WL_user/myicarus-201609261658/131q4y/war/WEB-INF/lib/dummybean-spring-1.0.0.jar!/.
not sure how to configure wls to read utf zips
so now i'm using ASCII as the encoding, and wls doesn't complain
精彩评论