Collection<File> (@Nullable File gradleHome) { if (gradleHome == null || !gradleHome.isDirectory()) { return null; } List<File> result = new ArrayList<>(); File libs = new File(gradleHome, "lib"); File[] files = libs.listFiles(); if (files != null) { for (File file : files) { if (file.getName().endsWith(".jar")) { result.add(file); } } } File plugins = new File(libs, "plugins"); files = plugins.listFiles(); if (files != null) { for (File file : files) { if (file.getName().endsWith(".jar")) { result.add(file); } } } return result.isEmpty() ? null : result; }