开发者

Maven: setup compiler plugin encoding without editing pom.xml

开发者 https://www.devze.com 2023-03-22 12:16 出处:网络
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 se

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&开发者_C百科gt;
    </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>


Ok, I solved the problem by adding

-Dfile.encoding=CP1252

to the global MAVEN_OPTS


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号