extract getMainSourceSet
@@ -13,16 +13,19 @@ public class PluginUtil {
static final String DOT_PROPERTIES = ".properties";
static Set<File> discoverGradlePluginPropertyFiles(Project project) {
- final JavaPluginConvention java = project.getConvention().getPlugin(JavaPluginConvention.class);
- FileTree resources = java.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME).getResources();
+ FileTree resources = getMainSourceSet(project).getResources();
FileTree plugins = resources.matching(new PatternSet().include("META-INF/gradle-plugins/*" + DOT_PROPERTIES));
return plugins.getFiles();
}
static Set<File> discoverGradlePlugins(Project project) {
- final JavaPluginConvention java = project.getConvention().getPlugin(JavaPluginConvention.class);
- FileTree resources = java.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME).getAllJava();
- FileTree plugins = resources.matching(new PatternSet().include("**/*Plugin.java").include("**/*Plugin.groovy"));
+ FileTree allJava = getMainSourceSet(project).getAllJava();
+ FileTree plugins = allJava.matching(new PatternSet().include("**/*Plugin.java").include("**/*Plugin.groovy"));
return plugins.getFiles();
}
+
+ private static SourceSet getMainSourceSet(Project project) {
+ final JavaPluginConvention java = project.getConvention().getPlugin(JavaPluginConvention.class);
+ return java.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME);
+ }
}
