Repository navigation
Conversation
As I understand it: Under the current approach, if we run even `JAVA_VERSION=26 ./gradlew clean javadoc`, Gradle can reuse results from any previous run of `./gradlew clean javadoc`, even one with a different `JAVA_VERSION`. By using [`providers.environmentVariable`](https://docs.gradle.org/current/kotlin-dsl/gradle/org.gradle.api.provider/-provider-factory/environment-variable.html) instead of directly accessing `System.env`, we tell Gradle that `JAVA_VERSION` is part of the inputs—and thus that it can't reuse outputs from a run with a different value. This solves a problem I saw when I accidentally built Javadoc with the default `JAVA_VERSION` (11) and then tried to rebuild with a newer version, only to see no changes. (previously in the Gradle configuration cache: #769)
Collaborator
Author
|
(In the meantime, the workaround, as before, is to pass |
This was referenced Jul 7, 2026
cpovirk
added a commit
that referenced
this pull request
Jul 9, 2026
…l testing under 9). This PR applies 26 for javadoc, javac, and one run of our integration tests. It applies Java 9 for an additional run of our integration tests, and it keeps the existing run under Java 8. We could consider additional testing of releases between the endpoints of Java 9 and Java 26, presumably on LTS releases 11+17+21+25, but I'm guessing it wouldn't buy us much. Then, make the CI run Gradle under (and only 26) and stop setting `JAVA_VERSION`. That should matter little, since the other changes of this PR make us ignore the `JAVA_VERSION` environment variable (which contributed to #812) and the fallback default of "whichever Java version the user used to run Gradle." We do still need to keep this Java version compatible with the Gradle version that we use, but broadly, I hope to keep on the newest version of each. This PR does let us advance our toolchain version (javadoc+javac+testing) ahead of the version we use to run Gradle if we find that useful at some point. We should bump the "26" in both `build.gradle` and `.github/workflows/build.yml` whenever we [bump the Java version elsewhere](#815). As noted above, we can bump one before the other if necessary. (I notice that we don't have any [required status checks](https://github.com/jspecify/jspecify/settings/branch_protection_rules/34801738), even though we have "Require status checks to pass before merging" checked. Maybe I'll register at least the new One True "Build" check after I merge this PR.) If I remember, I will wait to merge this PR until after #812: That way, if we ever choose to go back to a `JAVA_VERSION`-based approach (or to copy that approach for another project), we'll have a corrected version to refer back to.) - Fixes #271 (by following https://jakewharton.com/build-on-latest-java-test-through-lowest-java/) - Fixes #813 - Fixes #812 (if I didn't remember to merge that one first) - Slightly simplifies #305
wmdietl
approved these changes
Jul 9, 2026
wmdietl
left a comment
Collaborator
There was a problem hiding this comment.
My searching around Gradle docs says this is the recommended way for accessing environment variables.
cpovirk
added a commit
that referenced
this pull request
Jul 10, 2026
cpovirk
added a commit
that referenced
this pull request
Jul 15, 2026
…l testing under 9). (#818) This PR applies 26 for javadoc, javac, and one run of our integration tests. It applies Java 9 for an additional run of our integration tests, and it keeps the existing run under Java 8. We could consider additional testing of releases between the endpoints of Java 9 and Java 26, presumably on LTS releases 11+17+21+25, but I'm guessing it wouldn't buy us much. Then, make the CI run Gradle under (and only 26) and stop setting `JAVA_VERSION`. That should matter little, since the other changes of this PR make us ignore the `JAVA_VERSION` environment variable (which contributed to #812) and the fallback default of "whichever Java version the user used to run Gradle." We do still need to keep this Java version compatible with the Gradle version that we use, but broadly, I hope to keep on the newest version of each. This PR does let us advance our toolchain version (javadoc+javac+testing) ahead of the version we use to run Gradle if we find that useful at some point. We should bump the "26" in both `build.gradle` and `.github/workflows/build.yml` whenever we [bump the Java version elsewhere](#815). As noted above, we can bump one before the other if necessary. (I notice that we don't have any [required status checks](https://github.com/jspecify/jspecify/settings/branch_protection_rules/34801738), even though we have "Require status checks to pass before merging" checked. Maybe I'll register at least the new One True "Build" check after I merge this PR.) If I remember, I will wait to merge this PR until after #812: That way, if we ever choose to go back to a `JAVA_VERSION`-based approach (or to copy that approach for another project), we'll have a corrected version to refer back to.) - Fixes #271 (by following https://jakewharton.com/build-on-latest-java-test-through-lowest-java/) - Fixes #813 - Fixes #812 (if I didn't remember to merge that one first) - Slightly simplifies #305
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As I understand it:
Under the current approach, if we run even
JAVA_VERSION=26 ./gradlew clean javadoc, Gradle can reuse results from any previous run of./gradlew clean javadoc, even one with a differentJAVA_VERSION.By using
providers.environmentVariableinstead of directly accessingSystem.env, we tell Gradle thatJAVA_VERSIONis part of the inputs—and thus that it can't reuse outputs from a run with a different value.This solves a problem I saw when I accidentally built Javadoc with the default
JAVA_VERSION(11) and then tried to rebuild with a newer version, only to see no changes.(previously in the Gradle configuration cache: #769)