dweiss commented on code in PR #16521:
URL: https://github.com/apache/lucene/pull/16521#discussion_r3820899316
##########
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:
I know what it does but I can't see how you're hitting a problem here - I
suspect you're modifying this in place:
```
distributionUrl=https\://services.gradle.org/distributions/gradle-9.7.0-bin.zip
```
and your corporate url doesn't match the pattern, right? Sorry for being
dim. Can you give me an example of when this pattern fails to work?
Anyway, this isn't a solution in the long term because this file is
versioned... It'll be a nightmare for you to have to adjust it everywhere.
I've gone through gradle's docs, issues and the wrapper code and I wonder
how anybody in a corporate environment is solving the problem of
auto-gradle-distro-installation (wrapper jar aside). There seem to be only two
options that I see:
1) use http proxy props and a proxy server to redirect gradle's "official"
URLs to another location; this is tricky with https certs,
2) store the binary distribution with the code (yes, it's possible). This
dodges the download problem entirely.
It's interesting to me that there seems to be no way of redirecting these
URLs "dynamically" -- seems like people behind firewalls need to install gradle
manually (?). I guess adding a property to download something from arbitrary
locations may be perceived as a security issue, don't know.
Looking at what's inside the gradle wrapper code, we may indeed try to
simulate the same runtime behavior (using much less code) but skipping
gradle-wrapper.jar entirely will break higher-level tools that depend on it
(like intellij) so I think it needs to be there.
--
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]