简体   繁体   中英

How to configure compiler level (1.6) in maven settings.xml?

I am familiar with configuring maven-compiler-plugin to use java 1.6 in pom.xml and using parent pom file.

Is there a way to configure java compiler level to java 1.6 in the settings.xml level (so that all my maven projects will use java 1.6)?

In this thread default maven compiler setting somebody told there is a way to configure it in settings.xml. Can someone please explain how to configure?

PS: Another way to specify Java compiler level:

<properties>
       <maven.compiler.source>1.6</maven.compiler.source>
       <maven.compiler.target>1.6</maven.compiler.target>
</properties>

-Siva

Simple answer No. In the settings file you don't configure things like this, cause it doesn't make sense and would make your builds not reproducible. The information about configuring the compiler plugin in settings.xml is rubbish.

source/target level can be configured in settings.xml, like this:

<profiles>
    <profile>
      <id>jdk-1.6</id>
      <activation>
          // can be replaced with other conditions
          <jdk>1.6</jdk>
      </activation>
      <properties>
          <maven.compiler.source>1.6</maven.compiler.source>
          <maven.compiler.target>1.6</maven.compiler.target>
          <maven.compiler.compilerVersion>1.6</maven.compiler.compilerVersion>
      </properties>
    </profile>
</profiles>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM