How to specify source and target compatibility in Java module?

后端 未结 3 949
说谎
说谎 2020-12-11 01:20

I have a Gradle project consisting of an Android module (the com.android.library plugin is applied in the build.gradle file) and a Java module (the

3条回答
  •  既然无缘
    2020-12-11 02:03

    Compatibility needs to be specified inside the compileJava block

    compileJava   {
      sourceCompatibility = '1.8'
      targetCompatibility = '1.8'
    }
    

    IntelliJ gives this warning

    Access to 'sourceCompatibility' exceeds its access rights

    if you use a double parameter.

    When you make the value a string (e.g. quoted) the warning will disappear.

    --edit--

    the warning only appears using 1.8 in IntelliJ 2016. In 2017 the warning is gone using either 1.8 or '1.8'

提交回复
热议问题