https://kotlinlang.org logo
#announcements
Title
# announcements
x

xenoterracide

10/31/2019, 7:06 AM
if I set java 11 as the target of kotlin, will java files also be able to use things like
var
(from java 10)?
g

gildor

10/31/2019, 7:09 AM
To use Java 10 features you should set sourceCompatibility and targetCompatibility to Java plugin, not to Kotlin (for Kotlin it will just change target bytecode version) Something like:
Copy code
java {
   sourceCompatibility = JavaVersion.VERSION_11
    targetCompatibility = JavaVersion.VERSION_11
}
x

xenoterracide

10/31/2019, 7:11 AM
ah, ok wasn’t sure how this worked when using the kotlin plugin
so it’s just using the JavaCompile task under the hood
g

gildor

10/31/2019, 7:12 AM
yes, sure, Kotlin doesn’t compile Java code itself
x

xenoterracide

10/31/2019, 7:13 AM
thanks
g

gildor

10/31/2019, 7:13 AM
also it wouldn’t be flexible enough, you may want target version of Kotlin bytecode to be Java 6, but source and target of Java to be Java 11
x

xenoterracide

10/31/2019, 7:13 AM
right
a

alex

10/31/2019, 8:15 AM
If you're using JDK9+, then it's more convenient to set
--release
flag to 8/11/etc
x

xenoterracide

10/31/2019, 6:07 PM
hmm
Copy code
Could not determine the dependencies of task ':compileJava'.
> Could not resolve all task dependencies for configuration ':compileClasspath'.
   > Could not resolve com.potreromed.phg:phg-emr:0.1.0-SNAPSHOT.
     Required by:
         project :
      > Unable to find a matching variant of project :phg-emr:
          - Variant 'apiElements' capability com.potreromed.phg:phg-emr:0.1.0-SNAPSHOT:
              - Incompatible attribute:
                  - Required org.gradle.jvm.version '8' and found incompatible value '11'.
              - Other attributes:
                  - Found org.gradle.category 'library' but wasn't required.
                  - Required org.gradle.dependency.bundling 'external' and found compatible value 'external'.
                  - Required org.gradle.libraryelements 'classes' and found compatible value 'jar'.
                  - Required org.gradle.usage 'java-api' and found compatible value 'java-api'.
                  - Required org.jetbrains.kotlin.platform.type 'jvm' but no value provided.
only seems to happen in my composite build, when running outside of the idea composite build things are fine
ah, figured it out, my idea gradle setting was still pointing to jdk 8
12 Views