Problem running tests with enabled preview features in surefire and failsafe

前端 未结 2 819
失恋的感觉
失恋的感觉 2021-01-04 04:52

I\'m trying to migrate a project to Java 12, with --enable-preview.

I added --enable-preview in compiler settings:

                 


        
2条回答
  •  死守一世寂寞
    2021-01-04 05:27

    This works for me:

    • mvn clean install works (with junit tests)
    • IDEA recognizes module language level correctly as 12 (Preview) - Switch expressions
    • junit tests in IDEA work
        
            org.apache.maven.plugins
            maven-compiler-plugin
            3.8.1
            
                12
                
                    --enable-preview
                
            
        
        
            org.apache.maven.plugins
            maven-surefire-plugin
            2.22.2
            
                --enable-preview
            
        
    

    Environment:

    • Ubuntu 18.04.3 x64
    • IDEA 2019.2.1
    • Maven 3.6.0
    • jdk:

      IMPLEMENTOR="Oracle Corporation"
      JAVA_VERSION="12"
      JAVA_VERSION_DATE="2019-03-19"
      

    ADDITION: Similarly this approach works for java 13.

提交回复
热议问题