My compilation environment is jdk1.8 and the runtime is jdk1.6. java gradle plugin has sourceCompatibility attribute. It is valid for java project.
For example: when sourceCompatibility=1.6 , the compiler will report an error if I use api, for example Paths , which is located in jdk1.7.
Attribute
but sourceCompatibility does not work for kotlin project. I understand that this is from the scope of the java extension. But I am strange that the kotlin gradle plugin does not have a similar attribute. ( jvmTarget default attribute 1.6, this does not stop me from using jdk1.7 api)
=== my code ===
kotlin code:
fun main(args: Array<String>) { val pp = Paths.get("/tmp") ... ... }
I want the kotlin compiler to report errors, but the compilation was successful,
parent build.gradle :
buildscript { repositories { jcenter() } dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.1.0" } } subprojects { apply plugin: "java" compileJava.sourceCompatibility=1.6 compileJava.targetCompatibility=1.6 compileJava.options.encoding = 'UTF-8' // For ubuntu compileJava.options.bootClasspath = '/usr/lib/jvm/java-6-oracle/jre/lib/rt.jar' }
child project of kotlin build.gradle :
apply plugin: 'application' apply plugin: 'kotlin' mainClassName = 'net.cat.ApplictionKt' version='1.0' jar { manifest { attributes 'Implementation-Title': 'xxxx', 'Implementation-Version': version, 'Main-Class': mainClassName } } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib:1.1.0" compile "org.jetbrains.kotlin:kotlin-reflect:1.1.0" ... ... }
source share