Java Code Examples for org.gradle.api.file.SourceDirectorySet
The following examples show how to use
org.gradle.api.file.SourceDirectorySet. These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: pushfish-android Source File: DefaultSourceDirectorySet.java License: BSD 2-Clause "Simplified" License | 6 votes |
private Set<DirectoryTree> doGetSrcDirTrees() { Set<DirectoryTree> result = new LinkedHashSet<DirectoryTree>(); for (Object path : source) { if (path instanceof SourceDirectorySet) { SourceDirectorySet nested = (SourceDirectorySet) path; result.addAll(nested.getSrcDirTrees()); } else { File srcDir = fileResolver.resolve(path); if (srcDir.exists() && !srcDir.isDirectory()) { throw new InvalidUserDataException(String.format("Source directory '%s' is not a directory.", srcDir)); } result.add(new DirectoryFileTree(srcDir, patterns)); } } return result; }
Example 2
Source Project: javaide Source File: AndroidConfigAdaptor.java License: GNU General Public License v3.0 | 6 votes |
/** * Convert a FunctionalSourceSet to an AndroidSourceDirectorySet. */ private static void convertSourceSet( AndroidSourceDirectorySet androidDir, FunctionalSourceSet source, String sourceName) { LanguageSourceSet languageSourceSet = source.get(sourceName); if (languageSourceSet == null) { return; } SourceDirectorySet dir = languageSourceSet.getSource(); if (dir == null) { return; } androidDir.setSrcDirs(dir.getSrcDirs()); androidDir.include(dir.getIncludes()); androidDir.exclude(dir.getExcludes()); }
Example 3
Source Project: gradle-plugins Source File: GenerateSchemaTask.java License: Apache License 2.0 | 6 votes |
private void copyResource(String name, boolean optional) { SourceSet sourceSet = getMainSourceSet(); SourceDirectorySet resources = sourceSet.getResources(); File outputDir = sourceSet.getOutput().getResourcesDir(); File outputResourceFile = new File(outputDir, name); File inputResourceFile = getInputResource(resources, name); if (optional && inputResourceFile == null) { throw new IllegalStateException("no " + name + " found in " + resources.getSrcDirs()); } else if (inputResourceFile != null && hasChanged(inputResourceFile, outputResourceFile)) { outputResourceFile.getParentFile().mkdirs(); Project project = getProject(); project.copy(copySpec -> { copySpec.from(inputResourceFile); copySpec.into(outputResourceFile.getParentFile()); }); } }
Example 4
Source Project: pushfish-android Source File: CompilationSourceDirs.java License: BSD 2-Clause "Simplified" License | 5 votes |
List<File> getSourceDirs() { List<File> sourceDirs = new LinkedList<File>(); for (Object s : source) { if (s instanceof SourceDirectorySet) { sourceDirs.addAll(((SourceDirectorySet) s).getSrcDirs()); } else { throw new UnsupportedOperationException(); } } return sourceDirs; }
Example 5
Source Project: pushfish-android Source File: CompilationSourceDirs.java License: BSD 2-Clause "Simplified" License | 5 votes |
public boolean areSourceDirsKnown() { for (Object s : source) { if (!(s instanceof SourceDirectorySet)) { return false; } } return true; }
Example 6
Source Project: Pushjet-Android Source File: Compile.java License: BSD 2-Clause "Simplified" License | 5 votes |
private List<File> getSourceDirs() { List<File> sourceDirs = new LinkedList<File>(); for (Object s : source) { if (s instanceof SourceDirectorySet) { sourceDirs.addAll(((SourceDirectorySet) s).getSrcDirs()); } else { return emptyList(); } } return sourceDirs; }
Example 7
Source Project: Pushjet-Android Source File: CompilationSourceDirs.java License: BSD 2-Clause "Simplified" License | 5 votes |
List<File> getSourceDirs() { List<File> sourceDirs = new LinkedList<File>(); for (Object s : source) { if (s instanceof SourceDirectorySet) { sourceDirs.addAll(((SourceDirectorySet) s).getSrcDirs()); } else { throw new UnsupportedOperationException(); } } return sourceDirs; }
Example 8
Source Project: pushfish-android Source File: ConfigureGeneratedSourceSets.java License: BSD 2-Clause "Simplified" License | 5 votes |
private void maybeSetSourceDir(SourceDirectorySet sourceSet, Task task, String propertyName) { // TODO:DAZ Handle multiple output directories Object value = task.property(propertyName); if (value != null) { sourceSet.srcDir(value); } }
Example 9
Source Project: gradle-plugins Source File: GenerateSchemaTask.java License: Apache License 2.0 | 5 votes |
private static File getInputResource(SourceDirectorySet resources, String name) { File inputResourceFile = null; for (File resourceDir : resources.getSrcDirs()) { File candidateFile = new File(resourceDir, name); boolean exists = candidateFile.exists(); if (exists && inputResourceFile == null) { inputResourceFile = candidateFile; } else if (exists) { throw new IllegalStateException( "duplicate " + name + ": " + candidateFile.getAbsolutePath() + " vs " + inputResourceFile .getAbsolutePath()); } } return inputResourceFile; }
Example 10
Source Project: pushfish-android Source File: Compile.java License: BSD 2-Clause "Simplified" License | 5 votes |
private List<File> getSourceDirs() { List<File> sourceDirs = new LinkedList<File>(); for (Object s : source) { if (s instanceof SourceDirectorySet) { sourceDirs.addAll(((SourceDirectorySet) s).getSrcDirs()); } else { return emptyList(); } } return sourceDirs; }
Example 11
Source Project: curiostack Source File: ProtobufPlugin.java License: MIT License | 4 votes |
private static SourceSetTasks configureSourceSet( String sourceSetName, Project project, ProtobufExtension extension) { NamedDomainObjectProvider<SourceDirectorySet> sources = extension.getSources().register(sourceSetName); Configuration protobufConfiguration = project .getConfigurations() .create( SourceSetUtils.getConfigName(sourceSetName, "protobuf"), c -> { c.setVisible(false); c.setTransitive(true); c.setExtendsFrom(ImmutableList.of()); }); TaskProvider<ExtractProtosTask> extract = project .getTasks() .register( "extract" + SourceSetUtils.getTaskSuffix(sourceSetName) + "Proto", ExtractProtosTask.class, t -> { t.getFiles().from(protobufConfiguration); t.setDestDir(project.file("build/extracted-protos/" + sourceSetName)); }); TaskProvider<ExtractProtosTask> extractInclude = project .getTasks() .register( "extractInclude" + SourceSetUtils.getTaskSuffix(sourceSetName) + "Proto", ExtractProtosTask.class, t -> t.setDestDir(project.file("build/extracted-include-protos/" + sourceSetName))); TaskProvider<GenerateProtoTask> generateProto = project .getTasks() .register( "generate" + SourceSetUtils.getTaskSuffix(sourceSetName) + "Proto", GenerateProtoTask.class, sourceSetName, extension); // To ensure languages are added in order, we have to make sure this is hooked up eagerly. var languages = project.getObjects().listProperty(LanguageSettings.class).empty(); extension.getLanguages().all(languages::add); generateProto.configure( t -> { t.dependsOn(extract, extractInclude); t.getSources().source(sources.get()).srcDir(extract.get().getDestDir()); t.include(extractInclude.get().getDestDir()); t.setLanguages(languages); }); return ImmutableSourceSetTasks.builder() .extractProtos(extract) .extractIncludeProtos(extractInclude) .generateProto(generateProto) .build(); }
Example 12
Source Project: Pushjet-Android Source File: AbstractHeaderExportingSourceSet.java License: BSD 2-Clause "Simplified" License | 4 votes |
public SourceDirectorySet getExportedHeaders() { return exportedHeaders; }
Example 13
Source Project: gradle-plugins Source File: DefaultAspectjSourceSet.java License: MIT License | 4 votes |
@Override public AspectjSourceSet aspectj(Action<? super SourceDirectorySet> configureAction) { configureAction.execute(getAspectj()); return this; }
Example 14
Source Project: pushfish-android Source File: AbstractLanguageSourceSet.java License: BSD 2-Clause "Simplified" License | 4 votes |
public void source(Action<? super SourceDirectorySet> config) { config.execute(getSource()); }
Example 15
Source Project: pushfish-android Source File: AbstractLanguageSourceSet.java License: BSD 2-Clause "Simplified" License | 4 votes |
public SourceDirectorySet getSource() { return source; }
Example 16
Source Project: Pushjet-Android Source File: DefaultJavaSourceSet.java License: BSD 2-Clause "Simplified" License | 4 votes |
public DefaultJavaSourceSet(String name, SourceDirectorySet source, Classpath compileClasspath, FunctionalSourceSet parent) { super(name, parent, "Java source", source); this.compileClasspath = compileClasspath; }
Example 17
Source Project: Pushjet-Android Source File: DefaultSourceSet.java License: BSD 2-Clause "Simplified" License | 4 votes |
public SourceDirectorySet getJava() { return javaSource; }
Example 18
Source Project: pushfish-android Source File: DefaultScalaSourceSet.java License: BSD 2-Clause "Simplified" License | 4 votes |
public SourceDirectorySet getScala() { return scala; }
Example 19
Source Project: playframework Source File: PlayIdeaPlugin.java License: Apache License 2.0 | 4 votes |
@Override public void apply(Project project) { project.getTasks().named("ideaModule", GenerateIdeaModule.class, ideaModuleTask -> { IdeaModule module = ideaModuleTask.getModule(); ConventionMapping conventionMapping = conventionMappingFor(module); TaskProvider<Task> classesTask = project.getTasks().named(CLASSES_TASK_NAME); TaskProvider<JavaScriptMinify> javaScriptMinifyTask = project.getTasks().named(PlayJavaScriptPlugin.JS_MINIFY_TASK_NAME, JavaScriptMinify.class); conventionMapping.map("sourceDirs", (Callable<Set<File>>) () -> { // TODO: Assets should probably be a source set too Set<File> sourceDirs = new HashSet<>(); sourceDirs.add(new File(project.getProjectDir(), "public")); SourceDirectorySet scalaSourceDirectorySet = getMainScalaSourceDirectorySet(project); sourceDirs.addAll(scalaSourceDirectorySet.getSrcDirs()); sourceDirs.add(javaScriptMinifyTask.get().getDestinationDir().get().getAsFile()); return sourceDirs; }); conventionMapping.map("singleEntryLibraries", (Callable<Map<String, Iterable<File>>>) () -> { SourceSet mainSourceSet = getMainJavaSourceSet(project); SourceSet testSourceSet = getTestJavaSourceSet(project); Map<String, Iterable<File>> libs = new HashMap<>(); libs.put("COMPILE", mainSourceSet.getOutput().getClassesDirs()); libs.put("RUNTIME", Collections.singleton(mainSourceSet.getOutput().getResourcesDir())); libs.put("TEST", testSourceSet.getOutput().getClassesDirs()); return Collections.unmodifiableMap(libs); }); PlayExtension playExtension = (PlayExtension) project.getExtensions().getByName(PLAY_EXTENSION_NAME); module.setScalaPlatform(new DefaultScalaPlatform(playExtension.getPlatform().getScalaVersion().get())); conventionMapping.map("targetBytecodeVersion", (Callable<JavaVersion>) () -> getTargetJavaVersion(playExtension.getPlatform())); conventionMapping.map("languageLevel", (Callable<IdeaLanguageLevel>) () -> new IdeaLanguageLevel(getTargetJavaVersion(playExtension.getPlatform()))); module.getIml().withXml(xml -> { NodeList sourceFolders = xml.asNode().getAt(QName.valueOf("component")).getAt(QName.valueOf("content")).getAt(QName.valueOf("sourceFolder")); sourceFolders.forEach(sourceFolder -> { Node node = (Node) sourceFolder; if (node.get("@url").equals("file://$MODULE_DIR$/conf")) { node.attributes().put("type", "java-resource"); } }); }); ideaModuleTask.dependsOn(classesTask); ideaModuleTask.dependsOn(javaScriptMinifyTask); }); }
Example 20
Source Project: Pushjet-Android Source File: DefaultGroovySourceSet.java License: BSD 2-Clause "Simplified" License | 4 votes |
public SourceDirectorySet getGroovy() { return groovy; }
Example 21
Source Project: pushfish-android Source File: NativeComponentModelPlugin.java License: BSD 2-Clause "Simplified" License | 4 votes |
private void maybeSetSourceDir(SourceDirectorySet sourceSet, Task task, String propertyName) { Object value = task.property(propertyName); if (value != null) { sourceSet.srcDir(value); } }
Example 22
Source Project: playframework Source File: PlayPluginHelper.java License: Apache License 2.0 | 4 votes |
public static SourceDirectorySet getMainScalaSourceDirectorySet(Project project) { return getScalaSourceDirectorySet(getMainJavaSourceSet(project)); }
Example 23
Source Project: clojurephant Source File: DefaultClojureScriptSourceSet.java License: Apache License 2.0 | 4 votes |
@Override public ClojureScriptSourceSet clojurescript(Action<? super SourceDirectorySet> configureAction) { configureAction.execute(clojurescript); return this; }
Example 24
Source Project: pushfish-android Source File: DefaultJavaSourceSet.java License: BSD 2-Clause "Simplified" License | 4 votes |
public DefaultJavaSourceSet(String name, SourceDirectorySet source, Classpath compileClasspath, FunctionalSourceSet parent) { super(name, parent, "Java source", source); this.compileClasspath = compileClasspath; }
Example 25
Source Project: Pushjet-Android Source File: DefaultScalaSourceSet.java License: BSD 2-Clause "Simplified" License | 4 votes |
public SourceDirectorySet getAllScala() { return allScala; }
Example 26
Source Project: pushfish-android Source File: AbstractHeaderExportingSourceSet.java License: BSD 2-Clause "Simplified" License | 4 votes |
public void exportedHeaders(Action<? super SourceDirectorySet> config) { config.execute(getExportedHeaders()); }
Example 27
Source Project: pushfish-android Source File: AbstractHeaderExportingSourceSet.java License: BSD 2-Clause "Simplified" License | 4 votes |
public SourceDirectorySet getImplicitHeaders() { return implicitHeaders; }
Example 28
Source Project: curiostack Source File: GenerateProtoTask.java License: MIT License | 4 votes |
@InputFiles @PathSensitive(PathSensitivity.RELATIVE) public SourceDirectorySet getIncludes() { return includeDirs; }
Example 29
Source Project: Pushjet-Android Source File: DefaultSourceSet.java License: BSD 2-Clause "Simplified" License | 4 votes |
public SourceDirectorySet getAllSource() { return allSource; }
Example 30
Source Project: javaide Source File: AbstractLanguageSourceSet.java License: GNU General Public License v3.0 | 4 votes |
public AbstractLanguageSourceSet(ComponentSpecIdentifier identifier, Class<? extends BuildableComponentSpec> publicType, SourceDirectorySet source) { super(identifier, publicType); this.source = source; this.languageName = guessLanguageName(getTypeName()); super.builtBy(source.getBuildDependencies()); }