if I set java 11 as the target of kotlin, will jav...
# announcements
x
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
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
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
yes, sure, Kotlin doesn’t compile Java code itself
x
thanks
g
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
right
a
If you're using JDK9+, then it's more convenient to set
--release
flag to 8/11/etc
x
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