I want to have the encoding of my project's file to be set to UTF-8.
Following mav开发者_JAVA百科en FAQ answer, I set the project.build.sourceEncoding
property to UTF-8. unfortunatly, it has no effect.
Then, by looking at a m2eclipse JIRA, I tried a workaround by defining compiler plugin sourceEncoding
, but it neither worked, as I try to do that in a separate module parent pom.
Then, what is the solution to ensure my files are all in UTF-8 from maven ?
Thanks.
(A bit late) Solution / workaround I'm using to avoid inheriting MacRoman.
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.9</version>
<configuration>
<additionalConfig>
<file>
<name>.settings/org.eclipse.core.resources.prefs</name>
<content>
<![CDATA[eclipse.preferences.version=1${line.separator}encoding/<project>=${project.build.sourceEncoding}${line.separator}]]>
</content>
</file>
</additionalConfig>
</configuration>
</plugin>
</plugins>
</build>
Execute the command below :
mvn eclipse:eclipse
Credits to Steven Cummings.
Just specifying
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
will do it.
It didn't use to work - hence the other answers - but this was fixed already back in 2011. For more details, see eclipse bug entry 343927.
Define Eclipse project encoding as UTF-8 from Maven
I don't know if you saw MNGECLIPSE-1782 but this is currently not supported, m2eclipse doesn't derive the project encoding from your POM. You'll have to set up the encoding manually under Eclipse (which can be done globally for the workspace via Preferences > General > Workspace).
精彩评论