本文整理汇总了Java中org.gradle.api.file.SourceDirectorySet类的典型用法代码示例。如果您正苦于以下问题:Java SourceDirectorySet类的具体用法?Java SourceDirectorySet怎么用?Java SourceDirectorySet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SourceDirectorySet类属于org.gradle.api.file包,在下文中一共展示了SourceDirectorySet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: create
import org.gradle.api.file.SourceDirectorySet; //导入依赖的package包/类
public AntlrSpec create(AntlrTask antlrTask, Set<File> grammarFiles, SourceDirectorySet sourceDirectorySet) {
List<String> arguments = Lists.newLinkedList(antlrTask.getArguments());
if (antlrTask.isTrace() && !arguments.contains("-trace")) {
arguments.add("-trace");
}
if (antlrTask.isTraceLexer() && !arguments.contains("-traceLexer")) {
arguments.add("-traceLexer");
}
if (antlrTask.isTraceParser() && !arguments.contains("-traceParser")) {
arguments.add("-traceParser");
}
if (antlrTask.isTraceTreeWalker() && !arguments.contains("-traceTreeWalker")) {
arguments.add("-traceTreeWalker");
}
return new AntlrSpec(arguments, grammarFiles, sourceDirectorySet.getSrcDirs(), antlrTask.getOutputDirectory(), antlrTask.getMaxHeapSize());
}
示例2: renderSourceSetDirectories
import org.gradle.api.file.SourceDirectorySet; //导入依赖的package包/类
private void renderSourceSetDirectories(LanguageSourceSet sourceSet, TextReportBuilder builder) {
Set<File> srcDirs = sourceSet.getSource().getSrcDirs();
if (srcDirs.isEmpty()) {
builder.item("No source directories");
} else {
for (File file : srcDirs) {
builder.item("srcDir", file);
}
SourceDirectorySet source = sourceSet.getSource();
Set<String> includes = source.getIncludes();
if (!includes.isEmpty()) {
builder.item("includes", includes);
}
Set<String> excludes = source.getExcludes();
if (!excludes.isEmpty()) {
builder.item("excludes", excludes);
}
Set<String> filterIncludes = source.getFilter().getIncludes();
if (!filterIncludes.isEmpty()) {
builder.item("limit to", filterIncludes);
}
}
}
示例3: getSourceRoots
import org.gradle.api.file.SourceDirectorySet; //导入依赖的package包/类
List<File> getSourceRoots() {
if (sourceRoots == null) {
sourceRoots = Lists.newArrayList();
for (Object source : sources) {
if (isDirectory(source)) {
sourceRoots.add((File) source);
} else if (isDirectoryTree(source)) {
sourceRoots.add(((DirectoryTree) source).getDir());
} else if (isSourceDirectorySet(source)) {
sourceRoots.addAll(((SourceDirectorySet) source).getSrcDirs());
} else {
throw new UnsupportedOperationException();
}
}
}
return sourceRoots;
}
示例4: doGetSrcDirTrees
import org.gradle.api.file.SourceDirectorySet; //导入依赖的package包/类
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 {
for (File srcDir : fileResolver.resolveFiles(path)) {
if (srcDir.exists() && !srcDir.isDirectory()) {
throw new InvalidUserDataException(String.format("Source directory '%s' is not a directory.", srcDir));
}
result.add(directoryFileTreeFactory.create(srcDir, patterns));
}
}
}
return result;
}
示例5: createCompileJavaTaskForBinary
import org.gradle.api.file.SourceDirectorySet; //导入依赖的package包/类
private void createCompileJavaTaskForBinary(final SourceSet sourceSet, SourceDirectorySet javaSourceSet, Project target) {
JavaCompile compileTask = target.getTasks().create(sourceSet.getCompileJavaTaskName(), JavaCompile.class);
compileTask.setDescription("Compiles " + javaSourceSet + ".");
compileTask.setSource(javaSourceSet);
ConventionMapping conventionMapping = compileTask.getConventionMapping();
conventionMapping.map("classpath", new Callable<Object>() {
public Object call() throws Exception {
return sourceSet.getCompileClasspath();
}
});
conventionMapping.map("destinationDir", new Callable<Object>() {
public Object call() throws Exception {
return sourceSet.getOutput().getClassesDir();
}
});
}
示例6: setDefaultSrcDir
import org.gradle.api.file.SourceDirectorySet; //导入依赖的package包/类
/**
* Set the default directory for each source sets if it is empty.
*/
public void setDefaultSrcDir() {
all(new Action<FunctionalSourceSet>() {
@Override
public void execute(final FunctionalSourceSet functionalSourceSet) {
functionalSourceSet.all(
new Action<LanguageSourceSet>() {
@Override
public void execute(LanguageSourceSet languageSourceSet) {
SourceDirectorySet source = languageSourceSet.getSource();
if (source.getSrcDirs().isEmpty()) {
source.srcDir("src/" + functionalSourceSet.getName() + "/" + languageSourceSet.getName());
}
}
});
}
});
}
示例7: convertSourceFile
import org.gradle.api.file.SourceDirectorySet; //导入依赖的package包/类
/**
* Convert a FunctionalSourceSet to an AndroidSourceFile.
*/
private static void convertSourceFile(
AndroidSourceFile androidFile,
FunctionalSourceSet source,
String sourceName) {
LanguageSourceSet languageSourceSet = source.findByName(sourceName);
if (languageSourceSet == null) {
return;
}
SourceDirectorySet dir = languageSourceSet.getSource();
if (dir == null) {
return;
}
// We use the first file in the file tree until Gradle has a way to specify one source file
// instead of an entire source set.
Set<File> files = dir.getAsFileTree().getFiles();
if (!files.isEmpty()) {
androidFile.srcFile(Iterables.getOnlyElement(files));
}
}
示例8: convertSourceSet
import org.gradle.api.file.SourceDirectorySet; //导入依赖的package包/类
/**
* Convert a FunctionalSourceSet to an AndroidSourceDirectorySet.
*/
private static void convertSourceSet(
AndroidSourceDirectorySet androidDir,
FunctionalSourceSet source,
String sourceName) {
LanguageSourceSet languageSourceSet = source.findByName(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());
}
示例9: doGetSrcDirTrees
import org.gradle.api.file.SourceDirectorySet; //导入依赖的package包/类
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;
}
示例10: tryToGetSourceDirectoriesFromSourceSet
import org.gradle.api.file.SourceDirectorySet; //导入依赖的package包/类
private Collection<File> tryToGetSourceDirectoriesFromSourceSet(final Object sourceSet) {
if (sourceSet == null) {
return null;
}
if (sourceSet instanceof SourceDirectorySet) {
final SourceDirectorySet set = (SourceDirectorySet) sourceSet;
return set.getSrcDirs();
}
final String methodName = "getSrcDirs";
final Object srcDirs = tryToInvokeMethod(sourceSet, methodName);
if (srcDirs instanceof Collection<?>) {
try {
return (Collection<File>) srcDirs;
} catch (ClassCastException e) {
LOGGER.debug("Can not cast result of '" + methodName + "' to Collection<File>");
}
}
return null;
}
示例11: configureSourceSetDefaults
import org.gradle.api.file.SourceDirectorySet; //导入依赖的package包/类
private static void configureSourceSetDefaults(final Project project, final SourceDirectorySetFactory sourceDirectorySetFactory) {
final JavaBasePlugin javaPlugin = project.getPlugins().getPlugin(JavaBasePlugin.class);
project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().all(new Action<SourceSet>() {
@Override
public void execute(final SourceSet sourceSet) {
String displayName = (String) InvokerHelper.invokeMethod(sourceSet, "getDisplayName", null);
Convention sourceSetConvention = (Convention) InvokerHelper.getProperty(sourceSet, "convention");
DefaultScalaSourceSet scalaSourceSet = new DefaultScalaSourceSet(displayName, sourceDirectorySetFactory);
sourceSetConvention.getPlugins().put("scala", scalaSourceSet);
final SourceDirectorySet scalaDirectorySet = scalaSourceSet.getScala();
scalaDirectorySet.srcDir(new Callable<File>() {
@Override
public File call() throws Exception {
return project.file("src/" + sourceSet.getName() + "/scala");
}
});
sourceSet.getAllJava().source(scalaDirectorySet);
sourceSet.getAllSource().source(scalaDirectorySet);
sourceSet.getResources().getFilter().exclude(new Spec<FileTreeElement>() {
@Override
public boolean isSatisfiedBy(FileTreeElement element) {
return scalaDirectorySet.contains(element.getFile());
}
});
configureScalaCompile(project, javaPlugin, sourceSet);
}
});
}
示例12: visitDependencies
import org.gradle.api.file.SourceDirectorySet; //导入依赖的package包/类
@Override
public void visitDependencies(TaskDependencyResolveContext context) {
for (Object path : source) {
if (path instanceof SourceDirectorySet) {
context.add(((SourceDirectorySet) path).getBuildDependencies());
} else {
context.add(fileResolver.resolveFiles(path));
}
}
}
示例13: createProcessResourcesTaskForBinary
import org.gradle.api.file.SourceDirectorySet; //导入依赖的package包/类
private void createProcessResourcesTaskForBinary(final SourceSet sourceSet, SourceDirectorySet resourceSet, final Project target) {
Copy resourcesTask = target.getTasks().create(sourceSet.getProcessResourcesTaskName(), ProcessResources.class);
resourcesTask.setDescription("Processes " + resourceSet + ".");
new DslObject(resourcesTask).getConventionMapping().map("destinationDir", new Callable<File>() {
public File call() throws Exception {
return sourceSet.getOutput().getResourcesDir();
}
});
resourcesTask.from(resourceSet);
}
示例14: getSourceRootsFiles
import org.gradle.api.file.SourceDirectorySet; //导入依赖的package包/类
@Internal
private List<File> getSourceRootsFiles() {
// accessing the List<Object> field not the FileTree from getSource
return source.stream()
.filter(it -> it instanceof SourceDirectorySet)
.flatMap(it -> ((SourceDirectorySet) it).getSrcDirs().stream())
.collect(Collectors.toList());
}
示例15: generateClasses
import org.gradle.api.file.SourceDirectorySet; //导入依赖的package包/类
@TaskAction
public void generateClasses() throws IOException {
// Clean the destination directory
getProject().delete(getDestinationDir());
// Initialize spoon
SpoonAPI spoon = new Launcher();
spoon.addProcessor(EVENT_CLASS_PROCESSOR);
final Environment environment = spoon.getEnvironment();
environment.setComplianceLevel(Integer.parseInt(JavaVersion.toVersion(getSourceCompatibility()).getMajorVersion()));
environment.setNoClasspath(!this.validateCode);
// Configure AST generator
final SpoonModelBuilder compiler = spoon.createCompiler();
compiler.setSourceClasspath(toPathArray(getClasspath().getFiles()));
for (Object source : this.source) {
if (!(source instanceof SourceDirectorySet)) {
throw new UnsupportedOperationException("Source of type " + source.getClass() + " is not supported.");
}
((SourceDirectorySet) source).getSrcDirs().forEach(compiler::addInputSource);
}
this.factory = compiler.getFactory();
// Generate AST
compiler.build();
// Analyse AST
final EventInterfaceProcessor processor = new EventInterfaceProcessor(getSource());
compiler.process(Collections.singletonList(processor));
final Map<CtType<?>, List<Property>> foundProperties = processor.getFoundProperties();
this.sorter = new PropertySorter(this.sortPriorityPrefix, this.groupingPrefixes);
dumpClasses(foundProperties);
}