Java 类org.gradle.api.file.SourceDirectorySet 实例源码

项目:Reer    文件:AntlrSpecFactory.java   
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());
}
项目:Reer    文件:SourceSetRenderer.java   
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);
        }
    }
}
项目:Reer    文件:CompilationSourceDirs.java   
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;
}
项目:Reer    文件:DefaultSourceDirectorySet.java   
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;
}
项目:Reer    文件:JavaBasePlugin.java   
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();
        }
    });
}
项目:intellij-ce-playground    文件:AndroidComponentModelSourceSet.java   
/**
 * 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());
                            }
                        }
                    });
        }
    });
}
项目:intellij-ce-playground    文件:AndroidConfigAdaptor.java   
/**
 * 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));
    }
}
项目:intellij-ce-playground    文件:AndroidConfigAdaptor.java   
/**
 * 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());
}
项目:Pushjet-Android    文件:DefaultSourceDirectorySet.java   
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;
}
项目:Pushjet-Android    文件:DefaultSourceDirectorySet.java   
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;
}
项目:gradle-pylizard    文件:SourceSetAnalyzer.java   
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;
}
项目:Reer    文件:ScalaBasePlugin.java   
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);
        }

    });
}
项目:Reer    文件:DefaultSourceDirectorySet.java   
@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));
        }
    }
}
项目:Reer    文件:JavaBasePlugin.java   
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);
}
项目:gradle-clojure    文件:ClojureCompile.java   
@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());
}
项目:event-impl-gen    文件:EventImplGenTask.java   
@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);
}
项目:Pushjet-Android    文件:AbstractLanguageSourceSet.java   
public AbstractLanguageSourceSet(String name, FunctionalSourceSet parent, String typeName, SourceDirectorySet source) {
    this.name = name;
    this.fullName = parent.getName() + StringUtils.capitalize(name);
    this.displayName = String.format("%s '%s:%s'", typeName, parent.getName(), name);
    this.source = source;
    super.builtBy(source.getBuildDependencies());
}
项目:Pushjet-Android    文件:CompilationSourceDirs.java   
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;
}
项目:Pushjet-Android    文件:CompilationSourceDirs.java   
public boolean areSourceDirsKnown() {
    for (Object s : source) {
        if (!(s instanceof SourceDirectorySet)) {
            return false;
        }
    }
    return true;
}
项目:Pushjet-Android    文件:AbstractLanguageSourceSet.java   
public AbstractLanguageSourceSet(String name, FunctionalSourceSet parent, String typeName, SourceDirectorySet source) {
    this.name = name;
    this.fullName = parent.getName() + StringUtils.capitalize(name);
    this.displayName = String.format("%s '%s:%s'", typeName, parent.getName(), name);
    this.source = source;
    super.builtBy(source.getBuildDependencies());
}
项目:Pushjet-Android    文件:ConfigureGeneratedSourceSets.java   
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);
    }
}
项目:Pushjet-Android    文件:Compile.java   
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;
}
项目:gradle-velocity-plugin    文件:VelocityTask.java   
private void collectUnknown(@Nonnull Collector collector, @Nonnull Iterable<Object> sources) {
    for (Object source : sources) {
        getLogger().info("Attepmting to collect " + source.getClass() + ":" + source);
        if (source instanceof File)
            collectDir(collector, (File) source);
        else if (source instanceof SourceDirectorySet)
            collectDirs(collector, ((SourceDirectorySet) source).getSrcDirs());
        // I wish we could introspect CompositeFileTree.
    }
}
项目:st-js-gradle-plugin    文件:StJsPlugin.java   
@Override
public void apply(final Project project) {
    boolean javaPlugin = project.getPlugins().hasPlugin(JavaPlugin.class);
    boolean warPlugin = project.getPlugins().hasPlugin(WarPlugin.class);

    final Logger logger = project.getLogger();
    if (!(javaPlugin && warPlugin)) {
        logger.error("st-js plugin can only be applied if jar or war plugin is applied, too!");
        throw new IllegalStateException("st-js plugin can only be applied if jar or war plugin is applied, too!");
    }

    final JavaPluginConvention javaPluginConvention = project.getConvention().getPlugin(JavaPluginConvention.class);
    final SourceSet main = javaPluginConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME);
    final SourceDirectorySet allJava = main.getAllJava();
    if (allJava.getSrcDirs().size() != 1) {
        throw new IllegalStateException("Only a single source directory is supported!");
    }

    final GenerateStJsTask task = project.getTasks().create("stjs", GenerateStJsTask.class);
    task.setClasspath(
        main.getCompileClasspath()
    );
    task.setWar(warPlugin);
    File generatedSourcesDirectory;
    if (warPlugin) {
        generatedSourcesDirectory = new File(project.getBuildDir(), "stjs");
        project.getTasks().getByPath(WarPlugin.WAR_TASK_NAME).dependsOn(task);
    } else {
        generatedSourcesDirectory = main.getOutput().getClassesDir();
        project.getTasks().getByPath(JavaPlugin.JAR_TASK_NAME).dependsOn(task);
    }
    task.setGeneratedSourcesDirectory(generatedSourcesDirectory);
    task.setCompileSourceRoots(allJava);
    task.setOutput(main.getOutput());
}
项目:Reer    文件:AbstractLanguageSourceSet.java   
public AbstractLanguageSourceSet(ComponentSpecIdentifier identifier, Class<? extends BuildableComponentSpec> publicType, SourceDirectorySet source) {
    super(identifier, publicType);
    this.source = source;
    this.languageName = guessLanguageName(getTypeName());
    super.builtBy(source.getBuildDependencies());
}
项目:Reer    文件:AbstractLanguageSourceSet.java   
@Override
public SourceDirectorySet getSource() {
    return source;
}
项目:Reer    文件:AntlrSourceVirtualDirectoryImpl.java   
public SourceDirectorySet getAntlr() {
    return antlr;
}
项目:Reer    文件:DefaultScalaSourceSet.java   
public SourceDirectorySet getScala() {
    return scala;
}
项目:Reer    文件:DefaultScalaSourceSet.java   
@Override
public ScalaSourceSet scala(Action<? super SourceDirectorySet> configureAction) {
    configureAction.execute(getScala());
    return this;
}
项目:Reer    文件:DefaultScalaSourceSet.java   
public SourceDirectorySet getAllScala() {
    return allScala;
}
项目:Reer    文件:DefaultPrebuiltLibrary.java   
@Override
public SourceDirectorySet getHeaders() {
    return headers;
}
项目:Reer    文件:NativeComponentModelPlugin.java   
private void maybeSetSourceDir(SourceDirectorySet sourceSet, Task task, String propertyName) {
    Object value = task.property(propertyName);
    if (value != null) {
        sourceSet.srcDir(value);
    }
}
项目:Reer    文件:CompilationSourceDirs.java   
private boolean isSourceDirectorySet(Object source) {
    return source instanceof SourceDirectorySet;
}
项目:Reer    文件:AbstractHeaderExportingSourceSet.java   
@Override
public SourceDirectorySet getExportedHeaders() {
    return exportedHeaders;
}
项目:Reer    文件:AbstractHeaderExportingSourceSet.java   
@Override
public SourceDirectorySet getImplicitHeaders() {
    return implicitHeaders;
}
项目:Reer    文件:DefaultSourceDirectorySet.java   
public SourceDirectorySet setSrcDirs(Iterable<?> srcPaths) {
    source.clear();
    GUtil.addToCollection(source, srcPaths);
    return this;
}
项目:Reer    文件:DefaultJvmResourceSet.java   
public DefaultJvmResourceSet(ComponentSpecIdentifier componentIdentifier, SourceDirectorySet source) {
    super(componentIdentifier, JvmResourceSet.class, source);
}
项目:Reer    文件:DefaultJavaSourceSet.java   
public DefaultJavaSourceSet(ComponentSpecIdentifier componentIdentifier, SourceDirectorySet source, Classpath compileClasspath) {
    super(componentIdentifier, JavaSourceSet.class, source);
    this.compileClasspath = compileClasspath;
}
项目:Reer    文件:DefaultGroovySourceSet.java   
public SourceDirectorySet getGroovy() {
    return groovy;
}
项目:Reer    文件:DefaultGroovySourceSet.java   
@Override
public GroovySourceSet groovy(Action<? super SourceDirectorySet> configureAction) {
    configureAction.execute(getGroovy());
    return this;
}