for ( File classesDir: sourceSet.getOutput().getClassesDirs() ) { final FileTree fileTree = project.fileTree( classesDir ); for ( File file : fileTree ) {
@Override public File call() throws Exception { SourceSetOutput sourceSetOutput = sourceSet.getOutput(); return new File( sourceSetOutput.getResourcesDir(), "META-INF/resources"); }
List<String> getOutputDirs() { List<String> list = new ArrayList<>(); FileCollection classesDirs = this.sourceSet.getOutput().getClassesDirs(); classesDirs.forEach(classesDir -> list.add(classesDir.getPath())); return list; }
private static void configureOutputDirectoryForSourceSet(final SourceSet sourceSet, final SourceDirectorySet sourceDirectorySet, AbstractCompile compile, final Project target) { final String sourceSetChildPath = "classes/" + sourceDirectorySet.getName() + "/" + sourceSet.getName(); sourceDirectorySet.setOutputDir(target.provider(() -> { if (sourceSet.getOutput().isLegacyLayout()) { return sourceSet.getOutput().getClassesDir(); } return new File(target.getBuildDir(), sourceSetChildPath); })); ((ConfigurableFileCollection) sourceSet.getOutput().getClassesDirs()).from(target.provider( sourceDirectorySet::getOutputDir)); compile.setDestinationDir(target.provider(sourceDirectorySet::getOutputDir)); }
private static Collection<File> getOutputDirs(SourceSet sourceSet) { Collection<File> result; if (GradleVersion.version("4.0").compareTo(GradleVersion.current()) <= 0) { result = sourceSet.getOutput().getClassesDirs().getFiles(); } else { result = Collections.singletonList(sourceSet.getOutput().getClassesDir()); } return exists(result); }
private static Collection<File> getOutputDirs(SourceSet sourceSet) { Collection<File> result; if (GradleVersion.version("4.0").compareTo(GradleVersion.current()) <= 0) { result = sourceSet.getOutput().getClassesDirs().getFiles(); } else { result = Collections.singletonList(sourceSet.getOutput().getClassesDir()); } return exists(result); }
@InputFiles private FileCollection getInputFiles() { // todo : inclusions/exclusions FileCollection files = signatures; for ( SourceSet sourceSet : config.getSourceSets() ) { files = files.plus( sourceSet.getOutput() ); } return files; }
@Override public FileCollection call() { ConfigurableFileTree fileTree = StreamSupport.stream(sourceSet.getOutput().getClassesDirs().spliterator(), false) .map(project::fileTree) .reduce((lhs, rhs) -> { lhs.plus(rhs); return lhs; }).orElseThrow(() -> new InvalidUserDataException("No classes dir configured for source set " + sourceSet.getName()) ); return fileTree.builtBy(sourceSet.getClassesTaskName()); } });
private static Path outputManifest(Jar jarTask) { JavaPluginConvention javaConvention = jarTask.getProject().getConvention().getPlugin(JavaPluginConvention.class); SourceSet main = javaConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME); return main.getOutput().getResourcesDir().toPath().resolve("META-INF/MANIFEST.MF"); }
private SourceSetOutput getMainOutput(Project project) { JavaPluginConvention javaConvention = project.getConvention().getPlugin(JavaPluginConvention.class); return javaConvention.getSourceSets().getByName("main").getOutput(); }
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()))); }
private FileCollection getOutputClassDir(Project project) { return project.getConvention() .getPlugin(JavaPluginConvention.class) .getSourceSets() .getByName("main") .getOutput() .getClassesDirs(); }
private void configureLibPropertiesTask(PropertiesTask thin, Project project) { thin.setConfiguration(findRuntimeClasspath(project)); SourceSetContainer sourceSets = project.getConvention() .getPlugin(JavaPluginConvention.class).getSourceSets(); File resourcesDir = sourceSets.getByName("main").getOutput().getResourcesDir(); thin.setOutput(new File(resourcesDir, "META-INF")); }
public ServiceLoaderTask() throws IOException { super.setDescription("Generate META-INF/services manifests for use with ServiceLoaders"); super.setGroup("Source Generation"); javaConvention = project.getConvention().getPlugin(JavaPluginConvention.class); this.main = javaConvention.getSourceSets().findByName(SourceSet.MAIN_SOURCE_SET_NAME); SourceSetOutput mainOutput = main.getOutput(); classesOutput = mainOutput.getClassesDirs(); outputDirectory = new File(mainOutput.getResourcesDir(), "META-INF/services"); }
@Override public FileCollection call() throws Exception { final SourceSet mainSourceSet = getMainSourceSet(); return project.files(mainSourceSet.getAllJava().getSrcDirs()).plus(project.files(mainSourceSet.getOutput().getResourcesDir())); }});
private void addSourceSet(ConfigurableFileCollection sources, Project project, String sourceSet) { JavaPluginConvention javaConvention = project.getConvention().findPlugin(JavaPluginConvention.class); if (javaConvention != null) { SourceSet mainSourceSet = javaConvention.getSourceSets().getByName(sourceSet); sources .from(project.files(mainSourceSet.getOutput().getResourcesDir())) .from(project.files(mainSourceSet.getOutput().getClassesDirs())) .from(project.files(mainSourceSet.getAllSource().getSrcDirs())); } }
private void configureGosuDoc( final Project project ) { GosuDoc gosuDoc = project.getTasks().create(GOSUDOC_TASK_NAME, GosuDoc.class); gosuDoc.setDescription("Generates Gosudoc API documentation for the main source code."); gosuDoc.setGroup(JavaBasePlugin.DOCUMENTATION_GROUP); JavaPluginConvention convention = project.getConvention().getPlugin(JavaPluginConvention.class); SourceSet sourceSet = convention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME); gosuDoc.setClasspath(sourceSet.getOutput().plus(sourceSet.getCompileClasspath())); Convention sourceSetConvention = (Convention) InvokerHelper.getProperty(sourceSet, "convention"); GosuSourceSet gosuSourceSet = sourceSetConvention.getPlugin(GosuSourceSet.class); gosuDoc.setSource((Object) gosuSourceSet.getGosu()); // Gradle 4.0 overloads setSource; must upcast to Object for backwards compatibility }
private void addSourceSet(FileCollection sources, Project project, String sourceSet) { JavaPluginConvention javaConvention = project.getConvention().getPlugin(JavaPluginConvention.class); SourceSet mainSourceSet = javaConvention.getSourceSets().getByName(sourceSet); sources.add(project.files(mainSourceSet.getOutput().getResourcesDir())) .plus(project.files(mainSourceSet.getOutput().getClassesDirs())) .plus(project.files(mainSourceSet.getAllSource().getSrcDirs())); }
private void prepareSourceSet(Project project) { ConfigurationContainer confs = project.getConfigurations(); JavaPluginConvention javaConvention = project.getConvention().getPlugin(JavaPluginConvention.class); azureTestSourceSet = javaConvention.getSourceSets().create(AZURE_TEST_SOURCE_SET); azureTestSourceSet.java(x -> { }); azureTestSourceSet.resources(x -> { }); azureTestSourceSet.setCompileClasspath(project.files(confs.getByName(AZURE_TEST_COMPILE_CONF))); azureTestSourceSet.setRuntimeClasspath( project.files(azureTestSourceSet.getOutput(), azureTestSourceSet.getCompileClasspath(), confs.getByName(AZURE_TEST_RUNTIME_CONF))); }