Skip to content

Always check gradle wrapper sha checksum and download if necessary #14608

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

Merged
merged 3 commits into from
May 4, 2025

Conversation

dweiss
Copy link
Contributor

@dweiss dweiss commented May 4, 2025

Fixes #14598

Comment on lines +86 to +89
@rem Read the expected hash from .sha256 file
for /f "tokens=1" %%A in (%GRADLE_WRAPPER_CHECKSUM%) do (
set "EXPECTED=%%A"
)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the assumption here is that the sha file only contains the gradle-wrapper.jar checksum and it's sane. If anything doesn't match/ work here, we fall back to the Java version in WrapperDownloader anyway, where things are checked in depth.

Comment on lines +91 to +93
for /f "tokens=* delims=" %%H in ('certutil -hashfile "%GRADLE_WRAPPER_JAR%" SHA256 ^| findstr /R /B /I /X "[0-9a-f]*"') do (
set "ACTUAL=%%H"
)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this computes sha256 using certutil, then tries to pick a line that looks like an sha256 checksum. Again - if something fails, we rely on the Java version to tell us what's wrong.

@dweiss
Copy link
Contributor Author

dweiss commented May 4, 2025

I've verified this works on Windows, Linux (ubuntu) and Mac.

Copy link
Member

@rmuir rmuir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

working for me.

still haven't figured out why eclipse whines about sha every time i open vim, but that's another issue (I don't want it invoking gradle in any way and try to disable that, but it still obviously has its own priorities)

Screen_Shot_2025-05-04_at_13 09 26

@dweiss
Copy link
Contributor Author

dweiss commented May 4, 2025

Interesting. I've got no idea, to be honest. Here is a list of shas for all releases -
https://gradle.org/release-checksums/

v8.14 is there and consistent with what we have.

@dweiss dweiss merged commit 73aca0c into apache:main May 4, 2025
9 checks passed
@dweiss dweiss deleted the 14598-gradle-wrapper-sha branch May 4, 2025 21:00
@vigyasharma
Copy link
Contributor

Thanks for fixing this!

I ran into the same problem. My old gradle-wrapper.jar was not getting updated and I kept hitting:

% ./gradlew clean
no main manifest attribute, in /Users/vigyas/repos/lucene/gradle/wrapper/gradle-wrapper.jar

My workaround till last night was to delete the gradle-wrapper.jar. Verified that this change fixes it by putting back the old jar and having gradle find checksum mismatch and redownload.

% ./gradlew clean
Checksum mismatch, will attempt to re-download gradle-wrapper.jar
/Users/vigyas/repos/lucene/gradle/wrapper/gradle-wrapper.jar
Downloading gradle-wrapper.jar from https://raw.githubusercontent.com/gradle/gradle/v8.14.0/gradle/wrapper/gradle-wrapper.jar
Starting a Gradle Daemon (subsequent builds will be faster)

@uschindler
Copy link
Contributor

There is a small problem in windows with whitespace in path (missing escapes):

C:\Users\Uwe Schindler\Projects\lucene\lucene>gradlew :lucene:core:generateJdkApiJar24
Die Datei "C:\Users\Uwe" kann nicht gefunden werden.
"Checking gradle shas."

Can you fix this?

@mikemccand
Copy link
Member

This also delayed nightly benchy a couple days ... thanks for fixing!

@dweiss
Copy link
Contributor Author

dweiss commented May 5, 2025

As a (former) windows user... Uwe, you're asking for trouble if you have a whitespace in your home dir... I'll take a look.

dweiss added a commit that referenced this pull request May 5, 2025
dweiss added a commit that referenced this pull request May 5, 2025
@dweiss
Copy link
Contributor Author

dweiss commented May 5, 2025

Should work now, @uschindler

@uschindler
Copy link
Contributor

Works, thanks!

@uschindler
Copy link
Contributor

As a (former) windows user... Uwe, you're asking for trouble if you have a whitespace in your home dir... I'll take a look.

That's why I am doing this!

@uschindler
Copy link
Contributor

You know what I am doing? --> stay tuned, almost working!

There is a small problem in windows with whitespace in path (missing escapes):

C:\Users\Uwe Schindler\Projects\lucene\lucene>gradlew :lucene:core:generateJdkApiJar24
Die Datei "C:\Users\Uwe" kann nicht gefunden werden.
"Checking gradle shas."

Can you fix this?

weizijun added a commit to weizijun/lucene that referenced this pull request May 7, 2025
* main: (27 commits)
  deps(java): bump com.github.luben:zstd-jni from 1.5.7-2 to 1.5.7-3 (apache#14621)
  Improve user-facing docs for geo package (apache#14534)
  Enabling histogram collection for PointRangeQuery (apache#14560)
  Move sloppySin into SloppyMath from GeoUtils (apache#14516)
  Rewrite APIJAR extractor to use Java 24 classfile API and kill ASM dependency also for build system (apache#14613)
  CHANGES entry for apache#14226 (optimistic KNN Query)
  OptimisticKnnVectorQuery (apache#14226)
  Fix for Windows (spaces in paths) apache#14608
  Update jdk requirements in README to OpenJDK 24 (apache#14610)
  Always check gradle wrapper sha checksum and download if necessary (apache#14608)
  Fix changelog verifier (apache#14606)
  MultiRange query for SortedNumeric DocValues (apache#14404)
  Remove RANDOM_PRELOAD read advice, which is not actually used (apache#14593)
  Remove duplicate test (apache#14602)
  Refactor the expressions compiler to use official ClassData BSM with indexed lookup (apache#14602)
  Disallow EA versions to run Gradle (apache#14601)
  Add back-compat indices for 10.2.1
  Add Lucene 10.2.1 version constant
  DOAP changes for release 10.2.1
  Revert "An attempt to make jenkins pass with the currently installed jdk24-ea. To be reverted later. apache#14600"
  ...
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.

gradle-wrapper.jar will not be updated when its sha/version changes
5 participants