Path (@Nullable String gradleProjectPath) { if (gradleProjectPath == null) { return null; } Path file = Path.of(gradleProjectPath); // There is a possible case that given path points to a gradle script (*.gradle) but it's also possible that // it references script's directory. We want to provide flexibility here. Path gradleDir = Files.isRegularFile(file) ? file.resolveSibling("gradle") : file.resolve("gradle"); if (!Files.isDirectory(gradleDir)) { return null; } Path wrapperDir = gradleDir.resolve("wrapper"); if (!Files.isDirectory(wrapperDir)) { return null; } try (Stream<Path> pathsStream = Files.list(wrapperDir)) { List<Path> candidates = pathsStream .filter(path -> FileUtilRt.extensionEquals(path.getFileName().toString(), "properties") && Files.isRegularFile(path)) .toList(); if (candidates.isEmpty()) { GradleLog.LOG.warn("No *.properties file is found at the gradle wrapper directory " + wrapperDir); return null; } if (candidates.size() != 1) { GradleLog.LOG.warn(String.format("%d *.properties files instead of one have been found at the wrapper directory (%s): %s", candidates.size(), wrapperDir, join(candidates, ", ") )); return null; } return candidates.get(0); } catch (IOException e) { GradleLog.LOG.warn("Couldn't list gradle wrapper directory " + wrapperDir, e); return null; } }