Configure compiler using maven 3.3 toolchain

Answered

Hi!

I am working on a project currently running with jdk 1.6. We recently upgraded to maven 3.3 (which will only run on jdk 1.7 or later), so the compiler configuration was removed from the main pom.xml and we are using toolchain (located in MAVEN_HOME/conf/toolchain.xml)

This works well on builds with maven. However, in IntelliJ, even though the project structure is configured to use jdk 1.6 and project language level 6 (@Overrides in interfaces), all modules in the project gets language level 5.0 ('enum' keywords, generics, autoboxing, etc. )

On compiler errors in the idea, (using @Overrides on inplementations of interfaces) and pressing ALT + Enter to enable for fixup, IntelliJ inserts the compiler configuration in the pom once more...

How can I get IntelliJ to read the tool chaining used by maven without extra configuration in pom.xml. ...or how can change language level for all my modules in a project without having to open every single one in the project structure (I have over 100 modules...)

I am using the ultimate edition version 2016.2.2.

1
8 comments

i cannot see how this issue is relevant for me (other than the workaround)...

the major change in maven 3.3 is that it needs at least jdk 1.7 runtime and use toolchain to configure compiling and testing. toolchain is optional if you are compiling and testing in a jdk later than 1.7, but this must be used when project to build needs a jdk prior to 1.7...

should i creatte a new bug issue?

0

Yes, please submit a new bug at https://youtrack.jetbrains.com/issues/IDEA with the references to Maven documentation that outline this change in behavior.

0

I tried a workaround for this issue, replacing LANGUAGE_LEVEL="JDK_1_5" with LANGUAGE_LEVEL="JDK_1_6" in every *.iml file in my project.

The on-screen compiler error in the editor is removed afterwords, but when trying to run some unit tests, I get this:

Error: java: javacTask: source release 1.6 requires target release 1.6

The project settings is using 1.6 as Project SDK, and Project language level is SDK default (6 - @Overrides in interfaces)

I need help to resolve this problem...

0

The compiler error on my workaround is a pain in the ***. I find this error very strange and would like some help to find a workaround. When I set the language level back to jdk 1_5 (project SDK is still sdk 1.6), everything will compile without errors, but @Overrides annotation is marked as a compiler error in the editor...

0

Please create a support ticket and attach a sample project to reproduce the problem.

0

Sorry for not creating a sample project. Here is the ticket: https://intellij-support.jetbrains.com/hc/en-us/requests/763175

 

0

Please sign in to leave a comment.