Search in sources :

Example 1 with FileTreeElement

use of org.gradle.api.file.FileTreeElement in project gradle by gradle.

the class DirectoryFileTree method visitFrom.

/**
     * Process the specified file or directory.  If it is a directory, then its contents
     * (but not the directory itself) will be checked with {@link #isAllowed(FileTreeElement, Spec)} and notified to
     * the listener.  If it is a file, the file will be checked and notified.
     */
public void visitFrom(FileVisitor visitor, File fileOrDirectory, RelativePath path) {
    AtomicBoolean stopFlag = new AtomicBoolean();
    Spec<FileTreeElement> spec = patternSet.getAsSpec();
    if (fileOrDirectory.exists()) {
        if (fileOrDirectory.isFile()) {
            processSingleFile(fileOrDirectory, visitor, spec, stopFlag);
        } else {
            walkDir(fileOrDirectory, path, visitor, spec, stopFlag);
        }
    } else {
        LOGGER.info("file or directory '{}', not found", fileOrDirectory);
    }
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) FileTreeElement(org.gradle.api.file.FileTreeElement)

Example 2 with FileTreeElement

use of org.gradle.api.file.FileTreeElement in project gradle by gradle.

the class ScalaBasePlugin method configureSourceSetDefaults.

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);
        }
    });
}
Also used : SourceSet(org.gradle.api.tasks.SourceSet) ScalaSourceSet(org.gradle.api.tasks.ScalaSourceSet) DefaultScalaSourceSet(org.gradle.api.internal.tasks.DefaultScalaSourceSet) JavaPluginConvention(org.gradle.api.plugins.JavaPluginConvention) Convention(org.gradle.api.plugins.Convention) FileTreeElement(org.gradle.api.file.FileTreeElement) JavaBasePlugin(org.gradle.api.plugins.JavaBasePlugin) DefaultScalaSourceSet(org.gradle.api.internal.tasks.DefaultScalaSourceSet) SourceDirectorySet(org.gradle.api.file.SourceDirectorySet) Spec(org.gradle.api.specs.Spec) Callable(java.util.concurrent.Callable)

Aggregations

FileTreeElement (org.gradle.api.file.FileTreeElement)2 Callable (java.util.concurrent.Callable)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 SourceDirectorySet (org.gradle.api.file.SourceDirectorySet)1 DefaultScalaSourceSet (org.gradle.api.internal.tasks.DefaultScalaSourceSet)1 Convention (org.gradle.api.plugins.Convention)1 JavaBasePlugin (org.gradle.api.plugins.JavaBasePlugin)1 JavaPluginConvention (org.gradle.api.plugins.JavaPluginConvention)1 Spec (org.gradle.api.specs.Spec)1 ScalaSourceSet (org.gradle.api.tasks.ScalaSourceSet)1 SourceSet (org.gradle.api.tasks.SourceSet)1