gh-152785: Upgrade Java from 17 to 21 in GHA Android#152783
Conversation
|
@mhsmith: Would you mind reviewing this change? I tried upgrading Java to Java 25, but Gradle 8 is not compatible with Java 25 and fails with a surprising error: This change is not needed to upgrade Ubuntu 24.04 to 26.04. It's just that I think that it's a good idea to use newer Java version in our workflow :-) Android/README.md only mentions a dependency to Java without specifying a version. Should I also update this document to mention that Java 25 and newer is not supported? Another option would be to upgrade to Gradle and use Java 25. So far, I didn't understand where the Gradle version is specified :-) |
Ah, it seems like the Gradle version comes from the |
| persist-credentials: false | ||
| - name: Build and test | ||
| run: python3 Platforms/Android ci --fast-ci ${{ matrix.arch }}-linux-android | ||
| run: JAVA_HOME="${JAVA_HOME_21_X64:-$JAVA_HOME_21_arm64}" python3 Platforms/Android ci --fast-ci ${{ matrix.arch }}-linux-android |
There was a problem hiding this comment.
In my tests, Gradle only needs JAVA_HOME.
But would it be more consistent/safer to also set the PATH env var?
| run: JAVA_HOME="${JAVA_HOME_21_X64:-$JAVA_HOME_21_arm64}" python3 Platforms/Android ci --fast-ci ${{ matrix.arch }}-linux-android | |
| run: JAVA_HOME="${JAVA_HOME_21_X64:-$JAVA_HOME_21_arm64}" PATH="$JAVA_HOME/bin:$PATH" python3 Platforms/Android ci --fast-ci ${{ matrix.arch }}-linux-android |
There was a problem hiding this comment.
My understanding is that JAVA_HOME should be all that is needed (or, more strictly: either will work; both is redundant but won't break anything; setting JAVA_HOME is a little cleaner because it only affects the Java configuration).
There was a problem hiding this comment.
I agree with only using JAVA_HOME, but according to the runner documentation, the environment variable ends with _X64 even on the ARM64 runners.
There was a problem hiding this comment.
Oh, I see it's different on the macOS runner. In that case, I'm fine with this PR as long as the README is updated as mentioned below.
freakboy3742
left a comment
There was a problem hiding this comment.
My underlying question about this is the motivation for the change.
I'll defer to @mhsmith on the details here: but I'm not aware of any particular problems with running Gradle with an older (but still LTS-supported) Java; but as you've noted, there are some compatibility issues with using newer Java versions.
Java 21 passes CI, which is the most important criterion here; but it also requires explicitly defining a Java version in the configuration. On the one hand, being explicit about the Java version means we remove an ambiguity about the build environment; but it also means another version that we need to bump/coordinate at some point in the future, rather than accepting the "default java" that the GHA image provides (which skews to the conservative side AFAICT). I'm not sure which is the better option here.
| persist-credentials: false | ||
| - name: Build and test | ||
| run: python3 Platforms/Android ci --fast-ci ${{ matrix.arch }}-linux-android | ||
| run: JAVA_HOME="${JAVA_HOME_21_X64:-$JAVA_HOME_21_arm64}" python3 Platforms/Android ci --fast-ci ${{ matrix.arch }}-linux-android |
There was a problem hiding this comment.
My understanding is that JAVA_HOME should be all that is needed (or, more strictly: either will work; both is redundant but won't break anything; setting JAVA_HOME is a little cleaner because it only affects the Java configuration).
mhsmith
left a comment
There was a problem hiding this comment.
I prefer to use the following things only in one of the known combinations that have been used by Android Studio:
- Java version
- Gradle version (in gradle-wrapper.properties)
- Android Gradle plugin (AGP) version ("com.android.application" in testbed/build.gradle.kts)
I track these combinations in the Chaquopy integration tests. Each subdirectory is named after an AGP version, and it contains a gradle-wrapper.properties with the Gradle version, and a gradle.properties with the Java version.
In this case, the AGP version is 8.10, so we should actually have been on Java 21 already. The gradle.properties mechanism used by the Chaquopy integration tests can't easily be copied to CPython, so I agree setting JAVA_HOME is the way to go.
Let's specifically say that versions 17 and 21 are supported. At least one of the buildbots will remain on version 17, so we'll find out if that stops working in the future. |
Ok. I updated the README.md file to add:
|
Uh oh!
There was an error while loading. Please reload this page.