2

I working on MacOs on Eclipse Kepler.

I'm trying to run maven with UTF8 to be OS dependent.

I think I have tried a lot of solutions that seems to work for others not for me.

export JAVA _TOOL_OPTIONS -Dfile.encoding=UTF-8

When i Run in console :

mvn -version


Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
Apache Maven 3.0.4 (r1232337; 2012-01-17 09:44:56+0100)
Maven home: /usr/share/maven
Java version: 1.6.0_45, vendor: Apple Inc.
Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Default locale: fr_FR, platform encoding: UTF-8
OS name: "mac os x", version: "10.8.4", arch: "x86_64", family: "mac"

But i am running maven via Eclipse and Eclipse says platform encoding macRoman... When i run a

clean install

Apache Maven 3.0.4 (r1232337; 2012-01-17 09:44:56+0100)
Maven home: /Users/JP/git/CleanOmicsTracer/EMBEDDED
Java version: 1.6.0_45, vendor: Apple Inc.
Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Default locale: fr_FR, platform encoding: MacRoman
OS name: "mac os x", version: "10.8.4", arch: "x86_64", family: "mac"

In my pom.xml i have setted as this to set UTF-8:

     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
     <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
     <project.resources.sourceEncoding>UTF-8</project.resources.sourceEncoding>

    <plugin>
        <groupId>org.apache.tomcat.maven</groupId>
        <artifactId>tomcat7-maven-plugin</artifactId>
        <version>2.1</version>
        <configuration>
            <tag>${project.build.finalName}</tag>
            <url>http://localhost:8080/manager/text</url>
            <server>localhost</server>
            <charset>UTF-8</charset>
            <update>true</update>
            <path>/${project.build.finalName}</path>
            <username>jp</username>
            <password>camille</password>
        </configuration>
    </plugin>

     <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.1</version>
        <configuration>
        <source>${jdk.version}</source>
        <target>${jdk.version}</target>
        <encoding>${project.build.sourceEncoding}</encoding>
        <sourceEncoding>${project.build.sourceEncoding}</sourceEncoding>

        <fork>true</fork>
            <meminitial>128m</meminitial>
             <maxmem>1024m</maxmem>
            <url>http://localhost:8080/manager/text</url>
            <server>localhost</server>
            <path>/${project.build.finalName}</path>
        </configuration>
    </plugin>


     <plugin>
     <artifactId>maven-resources-plugin</artifactId>
     <version>2.6</version>
     <configuration>
     <encoding>${project.build.sourceEncoding}</encoding>
     <sourceEncoding>${project.build.sourceEncoding}</sourceEncoding>
     </configuration>
     </plugin>

It's not working, the é and è in my .java create an error :

When i change in maven-compile-plugin this line

macRoman

, it will be ok but no more Os Dependent and characters will be misunderstood in my other computer in linux.

When i clean install, the ouput is ok for ressources but nothing is done for the compiler :

[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ CleanOmicsTracer --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 36 resources [INFO]

[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ CleanOmicsTracer --- [INFO] Changes detected - recompiling the module! [INFO] Compiling 142 source files to /Users/JP/git/CleanOmicsTracer/target/classes [INFO]

[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ CleanOmicsTracer --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] skip non existing resourceDirectory /Users/JP/git/CleanOmicsTracer/src/test/resources

UPDATE : I change eclipse configuration to use /usr/share/maven and not the embeded version. I still have errors whereas this time the platform encoding is well set to UFT-8:

Apache Maven 3.0.4 (r1232337; 2012-01-17 09:44:56+0100)
Maven home: /usr/share/java/maven-3.0.4
Java version: 1.6.0_45, vendor: Apple Inc.
Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Default locale: fr_FR, platform encoding: UTF-8
OS name: "mac os x", version: "10.8.4", arch: "x86_64", family: "mac"

[ERROR] /com/clb/genomic/lyon/validator/ParticipantExistenceValidator.java:[101,93] unmappable character for encoding UTF-8
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: 
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project CleanOmicsTracer: Compilation failure
1
  • I remove the org.apache.maven.plugins, and now it's ok :) Commented Apr 29, 2014 at 9:31

1 Answer 1

2

If it works when the platform encoding is set to MacRoman but fails when it is set to UTF-8 then it means ParticipantExistenceValidator is not in UTF-8 encoding. You need to fix the file, not the configuration.

One easy way to do this is to use native2ascii twice, first to convert MacRoman to unicode escapes and then again with -reverse to convert the escapes back into UTF-8.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.