org.gradle.api.file.SourceDirectorySet Java Examples

The following examples show how to use org.gradle.api.file.SourceDirectorySet. 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 File: AndroidConfigAdaptor.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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 #2
Source File: DefaultSourceDirectorySet.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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 #3
Source File: GenerateSchemaTask.java    From gradle-plugins with Apache License 2.0 6 votes vote down vote up
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 File: Compile.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #5
Source File: ConfigureGeneratedSourceSets.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #6
Source File: CompilationSourceDirs.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #7
Source File: GenerateSchemaTask.java    From gradle-plugins with Apache License 2.0 5 votes vote down vote up
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 #8
Source File: CompilationSourceDirs.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public boolean areSourceDirsKnown() {
    for (Object s : source) {
        if (!(s instanceof SourceDirectorySet)) {
            return false;
        }
    }
    return true;
}
 
Example #9
Source File: Compile.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #10
Source File: CompilationSourceDirs.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #11
Source File: AbstractLanguageSourceSet.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void source(Action<? super SourceDirectorySet> config) {
    config.execute(getSource());
}
 
Example #12
Source File: DefaultGroovySourceSet.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public SourceDirectorySet getAllGroovy() {
    return allGroovy;
}
 
Example #13
Source File: AbstractHeaderExportingSourceSet.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public AbstractHeaderExportingSourceSet(String name, FunctionalSourceSet parent, ProjectInternal project, String typeName, SourceDirectorySet source) {
    super(name, parent, typeName, source);
    this.exportedHeaders = new DefaultSourceDirectorySet("exported headers", project.getFileResolver());
    this.implicitHeaders = new DefaultSourceDirectorySet("implicit headers", project.getFileResolver());
}
 
Example #14
Source File: AbstractHeaderExportingSourceSet.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public SourceDirectorySet getExportedHeaders() {
    return exportedHeaders;
}
 
Example #15
Source File: DefaultSourceSet.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public SourceDirectorySet getAllSource() {
    return allSource;
}
 
Example #16
Source File: AbstractHeaderExportingSourceSet.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public SourceDirectorySet getImplicitHeaders() {
    return implicitHeaders;
}
 
Example #17
Source File: PlayGeneratedSourcePlugin.java    From playframework with Apache License 2.0 4 votes vote down vote up
default Provider<Directory> getOutputDir(Project project, SourceDirectorySet sourceDirectorySet) {
    DirectoryProperty buildDir = project.getLayout().getBuildDirectory();
    return buildDir.dir(GENERATED_SOURCE_ROOT_DIR_PATH + "/" + sourceDirectorySet.getName());
}
 
Example #18
Source File: DefaultLatteSourceSet.java    From Latte-lang with MIT License 4 votes vote down vote up
@Override
public SourceDirectorySet getAllLatte() {
        return allLatte;
}
 
Example #19
Source File: DefaultTwirlSourceSet.java    From playframework with Apache License 2.0 4 votes vote down vote up
@Override
public TwirlSourceSet twirl(Action<? super SourceDirectorySet> configureAction) {
    configureAction.execute(getTwirl());
    return this;
}
 
Example #20
Source File: DefaultSourceSet.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public SourceDirectorySet getJava() {
    return javaSource;
}
 
Example #21
Source File: DefaultResourceSet.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DefaultResourceSet(String name, SourceDirectorySet source, FunctionalSourceSet parent) {
    super(name, parent, "resources", source);
}
 
Example #22
Source File: DefaultScalaSourceSet.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public SourceDirectorySet getAllScala() {
    return allScala;
}
 
Example #23
Source File: DefaultSourceSet.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public SourceDirectorySet getJava() {
    return javaSource;
}
 
Example #24
Source File: DefaultSourceSet.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public SourceDirectorySet getAllJava() {
    return allJavaSource;
}
 
Example #25
Source File: DefaultSourceSet.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public SourceDirectorySet getJava() {
    return javaSource;
}
 
Example #26
Source File: DefaultSourceDirectorySet.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public SourceDirectorySet setSrcDirs(Iterable<?> srcPaths) {
    source.clear();
    GUtil.addToCollection(source, srcPaths);
    return this;
}
 
Example #27
Source File: AntlrSourceVirtualDirectoryImpl.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public SourceDirectorySet getAntlr() {
    return antlr;
}
 
Example #28
Source File: AbstractLanguageSourceSet.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public SourceDirectorySet getSource() {
    return source;
}
 
Example #29
Source File: AbstractLanguageSourceSet.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public SourceDirectorySet getSource() {
    return source;
}
 
Example #30
Source File: ProtobufPlugin.java    From curiostack with MIT License 4 votes vote down vote up
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();
}