-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove Realm Plugin setting the bytecode target to 1.8 #1514
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM ... if CI is green.
Add support for Java 17 when using ktlintFormat.
# Conflicts: # buildSrc/src/main/kotlin/Config.kt
kotlinOptions.jvmTarget = Versions.jvmTarget | ||
} | ||
} | ||
jvm() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it getting the correct target default?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it is being set by https://github.com/realm/realm-kotlin/pull/1514/files#diff-5ea5ab9e6b701c3d35d3fd2fad81ff600102db520494994cc7448e7d3e032d9dR32 ... which now controls everything.
@@ -57,6 +57,7 @@ allprojects { | |||
|
|||
description = "Check Kotlin code style." | |||
classpath = ktlint | |||
jvmArgs = listOf("--add-opens=java.base/java.lang=ALL-UNNAMED") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need this? for refelction?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some APIs changed or modularized after Java 11, so if you are using Java 17, ktlint will crash. This will fix it.
From Kotlin 1.8.0 the minimum supported Java target is 1.8. This means there is no longer any reason we are setting this in our Realm Plugin. In fact, it might silently modify the behavior of people's compiled code if they are not setting the jvmTarget themselves: https://kotlinlang.org/docs/whatsnew18.html#updated-jvm-compilation-target
I tested this with various combinations of Java (11 and 17) and
build.gradle
settings and it doesn't seem to cause build failures.At the same time, I also unified how we are setting the Kotlin and Java bytecode versions, so they can now all be controlled through our buildSrc Config file.
Regarding the target version, I kept it at 1.8 since we don't know what version of the JVM people are running on the desktop. On Android the minimum the 11, but it didn't seem worth it to try to differentiate the two.
Since we are running Java 11 as a minimum on our developer machines and CI, we could probably set the
sourceCompatibility
to 11 as well, but the confusion didn't seem worth it. Also, we don't really have any Java sources to speak of anyway.