Various JDK source and test sources for the maven project in IntelliJ IDEA

I have a maven project imported into IDEA. There is a submodule that uses different versions of java for regular and test sources - it uses java 1.4 for regular sources and java 7 for test sources, for example:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.1</version>
    <configuration>
        <source>1.4</source>
        <target>1.4</target>
        <testSource>1.7</testSource>
        <testTarget>1.7</testTarget>
        <useIncrementalCompilation>false</useIncrementalCompilation>
    </configuration>
</plugin>

The project compiles when using maven, but does not compile in IDEA. When I open the Project Structure → module settings, I see that the module is imported with a language level of 1.4. Because of this, compilation of test classes fails because they use functions not available in 1.4.

As a workaround, I manually change the java version in pom.xml. Is there a way to do this without changing the maven configuration?

. , IDEA, :

Information:3/20/2015 5:29 PM - Compilation completed with 1 error and 0 warnings in 5 sec
Error:java: javacTask: source release 1.7 requires target release 1.7
+4
1

, Idea. Tracker JetBrains 2012 : https://youtrack.jetbrains.com/issue/IDEA-85478

(.. pom.xml) maven Idea:

  • Project Structure (Ctrl + Alt + Shift + S), 1.7
  • Idea settings (Ctrl + Alt + S), Java compiler ang, - 1.7

, Idea , 1.4 , Java 1.5+

Maven ( Idea Idea) , testSource lvel 1.7 ,

+1

All Articles