private String sourceDirsPath() { final JavaPluginConvention javaPlugin = project.getConvention().getPlugin(JavaPluginConvention.class); final SourceSetContainer sourceSets = javaPlugin.getSourceSets(); return sourceSets.stream() .filter(ss -> "test".equals(ss.getName())) .peek(sourceSet -> LOGGER.debug("finding source dir for sourceSet " + sourceSet.getName())) .map(SourceSet::getJava) .map(SourceDirectorySet::getSrcDirs) .flatMap(Set::stream) .map(srcDir -> srcDir.toPath().toAbsolutePath().toString()) .collect(Collectors.joining(":")); }
private String testOutputDirsPath() { final JavaPluginConvention javaPlugin = project.getConvention().getPlugin(JavaPluginConvention.class); final SourceSetContainer sourceSets = javaPlugin.getSourceSets(); return sourceSets.stream() .filter(ss -> "test".equals(ss.getName())) .peek(sourceSet -> LOGGER.debug("finding output dir for sourceSet " + sourceSet.getName())) .map(SourceSet::getJava) .map(SourceDirectorySet::getOutputDir) .map(outputDir -> outputDir.toPath().toAbsolutePath().toString()) .collect(Collectors.joining(":")); } @Override
private List<String> mainOutputDirsPath() { final JavaPluginConvention javaPlugin = project.getConvention().getPlugin(JavaPluginConvention.class); final SourceSetContainer sourceSets = javaPlugin.getSourceSets(); return sourceSets.stream() .filter(ss -> "main".equals(ss.getName())) .peek(sourceSet -> LOGGER.debug("finding output dir for sourceSet " + sourceSet.getName())) .map(SourceSet::getJava) .map(SourceDirectorySet::getOutputDir) .map(outputDir -> outputDir.toPath().toAbsolutePath().toString()) .collect(Collectors.toList()); }
private List<String> outputDirsPath() { final JavaPluginConvention javaPlugin = project.getConvention().getPlugin(JavaPluginConvention.class); final SourceSetContainer sourceSets = javaPlugin.getSourceSets(); return sourceSets.stream() .filter(ss -> "main".equals(ss.getName())) .peek(sourceSet -> LOGGER.debug("finding output dir for sourceSet " + sourceSet.getName())) .map(SourceSet::getJava) .map(SourceDirectorySet::getOutputDir) .map(outputDir -> outputDir.toPath().toAbsolutePath().toString()) .collect(Collectors.toList()); } @Override
/** * get gradle main source set */ private static Set< SourceSet > sourceSetMain( Project project ) { JavaPluginConvention convention = project.getConvention().findPlugin( JavaPluginConvention.class ); Set< SourceSet > sourceSets = convention.getSourceSets().stream().filter( sourceSet -> sourceSet.getName().equals( SourceSet.MAIN_SOURCE_SET_NAME ) ).collect( Collectors.toSet() ); return sourceSets; }
private ImmutableBiMap<String, String> getModuleNameIbiTaskName(final Project project, final SourceSetContainer sourceSets) { return sourceSets.stream() .flatMap(ss -> stream(ss.getAllJava().matching(pattern -> pattern.include("**/" + MODULE_INFO_JAVA))) .map(moduleInfoJavaFile -> immutableEntry( ss.getCompileJavaTaskName(), parseModuleName(moduleInfoJavaFile.toPath(), newJavaParser((JavaCompile) project.getTasks().getByName(ss.getCompileJavaTaskName()))) ) ) ) .collect(toImmutableBiMap( Entry::getKey, Entry::getValue )) ; }
private void configureJavaCompileTasks(final Project project, final ImmutableBiMap<String, String> moduleNameIbiTaskName) { final ImmutableSet<File> outputDirFileIset = getSourceSets(project).stream().flatMap(ss -> stream(ss.getOutput())).collect(toImmutableSet()); project.getTasks().withType(JavaCompile.class).forEach(javaCompile -> configureJavaCompileTask(javaCompile, outputDirFileIset, moduleNameIbiTaskName.get(javaCompile.getName()))); }