Java_Waldi
Java_Waldi

Reputation: 934

Maven: setup compiler plugin encoding without editing pom.xml

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>

Upvotes: 0

Views: 3834

Answers (2)

khmarbaise
khmarbaise

Reputation: 97409

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.

Upvotes: 0

Java_Waldi
Java_Waldi

Reputation: 934

Ok, I solved the problem by adding

-Dfile.encoding=CP1252

to the global MAVEN_OPTS

Upvotes: 4

Related Questions