Skip to content
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

Stick with Java 17 on CI #2938

Merged
merged 6 commits into from Mar 30, 2023
Merged

Stick with Java 17 on CI #2938

merged 6 commits into from Mar 30, 2023

Conversation

Goooler
Copy link
Contributor

@Goooler Goooler commented Mar 22, 2023

Follow up #2918.

@Goooler Goooler mentioned this pull request Mar 22, 2023
4 tasks
@IgnatBeresnev IgnatBeresnev self-requested a review March 27, 2023 19:14
@IgnatBeresnev
Copy link
Member

Hi! What's the main motivation for using Java 17 everywhere?

It probably doesn't matter in check.yml and gh-pages.yml, but it does matter in the rest of the files for tests and examples. Kotlin can be run under Java 8, so as an official tool we have to support it as well, and so we have to test our changes against Java 8. Migrating all checks to Java 17 will mask some of the problems that I'm currently aware of when it comes to Java compatibility.

At the moment, Java 11 seems to be the default sweet spot between not too old and not too modern, and it's still supported, whereas Java 8 and Java 17 are checked additionally

@Goooler
Copy link
Contributor Author

Goooler commented Mar 28, 2023

We enabled Java 8 as the default in tests via toolchain in #2918, and Java 8 as the compatibility before, now we can bump the running JDK to 17, see #2918 (comment).

@IgnatBeresnev
Copy link
Member

IgnatBeresnev commented Mar 28, 2023

Oh, we have the toolchain now, right, completely forgot about it

So basically Java 17 will be used for setting things up and some non-build java executions, and then the toolchain versions will be used for running the actual tests and whatnot?

@Goooler
Copy link
Contributor Author

Goooler commented Mar 29, 2023

Yep. @aSemy WDYT?

@aSemy
Copy link
Contributor

aSemy commented Mar 29, 2023

The Java toolchain used to build Dokka projects is set in base-java.gradle.kts

java {
toolchain {
languageVersion.set(dokkaBuild.mainJavaVersion)
}
}

The actual value is set using the Gradle property org.jetbrains.dokka.javaToolchain.mainCompiler, and the default is 8

org.jetbrains.dokka.javaToolchain.mainCompiler=8

When Gradle tries to build Dokka it will realise it needs JDK 8, and try and auto-detect an installed version.

It's similar for the tests: they are configured to run using JDK 8, 11, or 17 via a toolchain, and so Gradle will try and auto-detect those versions too.

Gradle doesn't automatically download JDKs, so they need to be pre-installed, and that's what the setup-java step is for. However, it looks like the latest GitHub runners have JDK 8, 11, and 17 pre-installed, so technically the setup-java step isn't needed for building/testing all (I suspect that the setup-java step was needed in older GitHub runners).

However, Gradle itself is a JVM tool, so it needs Java installed and it the JAVA_HOME environment variable must be set - I guess that's why the setup-java step is needed? I couldn't find any reference to a default JAVA_HOME in the GitHub runners.

In summary:

  • Gradle Java Toolchains are used to set the version of Java used to build and test the project
  • JDKs 8/11/17 are pre-installed, and will be auto-detected by Gradle to use as Toolchain runners/builders
  • setup-java is required to set JAVA_HOME, which Gradle requires to launch itself, but this has no effect on the versions used to be build/test Dokka (they are determined by Java toolchains)

The setup-java action does some caching, but I'm not sure how much impact that has (if any).

If I've understood correctly, perhaps it would be good to add a small bit of docs in CONTRIBUTING.md (feel free to copy/paste/adapt this comment) and add a link next to the setup-java steps?

@Goooler
Copy link
Contributor Author

Goooler commented Mar 29, 2023

@IgnatBeresnev
Copy link
Member

@aSemy thank you for the detailed explanation, I'll indeed adapt it and add some other things to CONTRIBUTING.md in a separate PR, will tag you

@Goooler thanks for the contribution!

@IgnatBeresnev IgnatBeresnev merged commit f5789ed into Kotlin:master Mar 30, 2023
26 checks passed
@Goooler Goooler deleted the jdk_matrix branch March 30, 2023 12:55
@Goooler
Copy link
Contributor Author

Goooler commented Mar 31, 2023

@IgnatBeresnev There are JDK 8 and 11 used in TeamCity runners, can we bump them also?

https://scans.gradle.com/s/y4y6wdam2dtua#infrastructure
https://scans.gradle.com/s/yeysww53sshpi#infrastructure

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants