Different maven compiler versions for test and main

前端 未结 3 1986
-上瘾入骨i
-上瘾入骨i 2020-12-13 13:49

How can I configure the maven compiler to use java 5 for my test code and java 1.4 for my main code?

3条回答
  •  青春惊慌失措
    2020-12-13 14:18

    I had no luck with the accepted answer compiling java 7 source and java 8 test sources using the maven-compiler-plugin, version 3.5.1. Because the compile plugin used the source / target parameter for both, main and test sources.

    But I found out, there are separate configuration parameters for the test source and target.

    So for me the solution that worked was

     
        
            
                org.apache.maven.plugins
                maven-compiler-plugin
                3.5.1
                
                    1.7
                    1.7
                    1.8
                    1.8
                
            
        
    
    

提交回复
热议问题