dweiss commented on code in PR #16521:
URL: https://github.com/apache/lucene/pull/16521#discussion_r3815753405
##########
build-tools/build-infra/src/main/java/org/apache/lucene/gradle/WrapperDownloader.java:
##########
@@ -81,70 +78,19 @@ public static void checkVersion() {
}
public void run(Path destination) throws IOException,
NoSuchAlgorithmException {
- var expectedFileName = destination.getFileName().toString();
- Path checksumPath = destination.resolveSibling(expectedFileName +
".sha256");
- if (!Files.exists(checksumPath)) {
- throw new IOException("Checksum file not found: " + checksumPath);
- }
-
- String expectedChecksum;
- try (var lines = Files.lines(checksumPath, StandardCharsets.UTF_8)) {
- expectedChecksum =
- lines
- .map(
- line -> {
- // "The default mode is to print a line with: checksum, a
space,
- // a character indicating input mode ('*' for binary, ' '
for text
- // or where binary is insignificant), and name for each
FILE."
- var spaceIndex = line.indexOf(" ");
- if (spaceIndex != -1 && spaceIndex + 2 < line.length()) {
- var mode = line.charAt(spaceIndex + 1);
- String fileName = line.substring(spaceIndex + 2);
- if (mode == '*' && fileName.equals(expectedFileName)) {
- return line.substring(0, spaceIndex);
- }
- }
-
- Logger.getLogger(WrapperDownloader.class.getName())
- .warning(
- "Something is wrong with the checksum file.
Regenerate with "
- + "'sha256sum -b gradle-wrapper.jar >
gradle-wrapper.jar.sha256'");
- return null;
- })
- .filter(Objects::nonNull)
- .findFirst()
- .orElse(null);
-
- if (expectedChecksum == null) {
- throw new IOException(
- "The checksum file did not contain the expected checksum for '"
- + expectedFileName
- + "'?");
- }
- }
-
Path wrapperProperties =
destination.resolveSibling(
destination.getFileName().toString().replace(".jar",
".properties"));
if (!Files.exists(wrapperProperties)) {
throw new IOException("Wrapper property file not found: " +
wrapperProperties);
}
- Pattern versionPattern = Pattern.compile("gradle-(?<version>.+?)-bin.zip");
Review Comment:
Hmm.... What do you mean? It doesn't have a DOTALL flag, it should work just
fine?
##########
gradlew:
##########
Review Comment:
The sha checking code is there because if you're switching branches (for
example, the wrapper version changes), you want to update the wrapper jar too.
It is a stricter check than just file timestamps.
##########
gradle/wrapper/gradle-wrapper.properties:
##########
@@ -7,3 +7,8 @@ retryBackOffMs=500
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
+
+# Read by Lucene's WrapperDownloader (not by the actual wrapper) to bootstrap
gradle-wrapper.jar.
+wrapperSha256=497c8c2a7e5031f6aa847f88104aa80a93532ec32ee17bdb8d1d2f67a194a9c7
+wrapperUrl=https\://raw.githubusercontent.com/gradle/gradle/v9.6.1/gradle/wrapper/gradle-wrapper.jar
+# To self download, try %> curl -Lo gradle/wrapper/gradle-wrapper.jar
<wrapperUrl> (from the repo root)
Review Comment:
I wouldn't put anything in here. This is controlled by gradle - when you
update the wrapper, it'll likely get overwritten and people use llms more and
more for such stuff... Likely to break in my opinion.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]