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).
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).
Uh oh!
There was an error while loading. Please reload this page.