2

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

Community
  • 1
  • 1
K. Siva Prasad Reddy
  • 11,786
  • 12
  • 68
  • 95

2 Answers2

4

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.

khmarbaise
  • 92,914
  • 28
  • 189
  • 235
  • So there is no such an option. Either I should have a parent pom with this configuration or copy-paste the maven-compiler-plugin config(very bad option :-)) for every project. – K. Siva Prasad Reddy Mar 16 '12 at 12:12
  • 4
    The best is to have a parent pom in particular a company or project-group pom which contains such configurations. – khmarbaise Mar 16 '12 at 12:58
0

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>
Yankai Zhang
  • 161
  • 3
  • 9