0

I'm trying to setup my installed maven 3.0.3 on Cp1252 encoding. Is it possible to change the encoding WITHOUT editing one of the pom.xml-files? maybe creating a profile for the compiler-plugin in settings.xml? If yes, how to do that? The following didn't work:

<settings>
...
 <profiles>
 <profile>
  <id>encoding</id>
    <activation>
      <activeByDefault>true</activeByDefault>
    </activation>
   <build>
     <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <encoding>Cp1252</encoding>
        </configuration>
      </plugin>
    </build>
 </profile>
  </profiles>
  <activeProfiles>
    <activeProfile>encoding</activeProfile>
  </activeProfiles>
</settings>

2 Answers 2

4

Ok, I solved the problem by adding

-Dfile.encoding=CP1252

to the global MAVEN_OPTS

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

2 Comments

this looks like setting a java vm property, are you sure it will not affect your resources? (ie trying to read a utf-8 xml file as cp1252).
The project setup forces me to do solve it this way, and this works atm. I don't know a better way, maybe you can help?
0

Put into your root pom of your project:

<properties>
    <project.build.sourceEncoding>cp1252</project.build.sourceEncoding>
</properties>

Which defines it for all sub-project which use this pom as parent. Otherwise your build is not reproduciable.

1 Comment

I Read the question. The problem is if the parent pom will not be changed and the encoding will be done by system property the build is not reproducible which is really worse.

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.