String (@Nullable String gradleHome) { if (gradleHome == null) return null; File libs = new File(gradleHome, "lib"); if (!libs.isDirectory()) return null; File[] files = libs.listFiles(); if (files != null) { for (File file : files) { final Matcher matcher = GRADLE_JAR_FILE_PATTERN.matcher(file.getName()); if (matcher.matches()) { return matcher.group(2); } } } return null; }