org.gradle.api.tasks.TaskDependency Java Examples

The following examples show how to use org.gradle.api.tasks.TaskDependency. 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: DefaultFileCollectionResolveContext.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void convertInto(Object element, Collection<? super FileCollection> result, FileResolver fileResolver) {
    if (element instanceof DefaultFileCollectionResolveContext) {
        DefaultFileCollectionResolveContext nestedContext = (DefaultFileCollectionResolveContext) element;
        result.addAll(nestedContext.resolveAsFileCollections());
    } else if (element instanceof FileCollection) {
        FileCollection fileCollection = (FileCollection) element;
        result.add(fileCollection);
    } else if (element instanceof MinimalFileTree) {
        MinimalFileTree fileTree = (MinimalFileTree) element;
        result.add(new FileTreeAdapter(fileTree));
    } else if (element instanceof MinimalFileSet) {
        MinimalFileSet fileSet = (MinimalFileSet) element;
        result.add(new FileCollectionAdapter(fileSet));
    } else if (element instanceof MinimalFileCollection) {
        throw new UnsupportedOperationException(String.format("Cannot convert instance of %s to FileTree", element.getClass().getSimpleName()));
    } else if (element instanceof TaskDependency) {
        // Ignore
        return;
    } else {
        result.add(new FileCollectionAdapter(new ListBackedFileSet(fileResolver.resolve(element))));
    }
}
 
Example #2
Source File: CachingTaskDependencyResolveContext.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void getNodeValues(Object node, Collection<? super Task> values, Collection<? super Object> connectedNodes) {
    if (node instanceof TaskDependencyInternal) {
        TaskDependencyInternal taskDependency = (TaskDependencyInternal) node;
        queue.clear();
        taskDependency.resolve(CachingTaskDependencyResolveContext.this);
        connectedNodes.addAll(queue);
    } else if (node instanceof Buildable) {
        Buildable buildable = (Buildable) node;
        connectedNodes.add(buildable.getBuildDependencies());
    } else if (node instanceof TaskDependency) {
        TaskDependency dependency = (TaskDependency) node;
        values.addAll(dependency.getDependencies(task));
    } else if (node instanceof Task) {
        values.add((Task) node);
    } else {
        throw new IllegalArgumentException(String.format("Cannot resolve object of unknown type %s to a Task.",
                node.getClass().getSimpleName()));
    }
}
 
Example #3
Source File: CompositeFileCollection.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public FileCollection filter(final Spec<? super File> filterSpec) {
    return new CompositeFileCollection() {
        @Override
        public void resolve(FileCollectionResolveContext context) {
            for (FileCollection collection : CompositeFileCollection.this.getSourceCollections()) {
                context.add(collection.filter(filterSpec));
            }
        }

        @Override
        public String getDisplayName() {
            return CompositeFileCollection.this.getDisplayName();
        }

        @Override
        public TaskDependency getBuildDependencies() {
            return CompositeFileCollection.this.getBuildDependencies();
        }
    };
}
 
Example #4
Source File: CachingTaskDependencyResolveContext.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void getNodeValues(Object node, Collection<? super Task> values, Collection<? super Object> connectedNodes) {
    if (node instanceof TaskDependencyInternal) {
        TaskDependencyInternal taskDependency = (TaskDependencyInternal) node;
        queue.clear();
        taskDependency.resolve(CachingTaskDependencyResolveContext.this);
        connectedNodes.addAll(queue);
    } else if (node instanceof Buildable) {
        Buildable buildable = (Buildable) node;
        connectedNodes.add(buildable.getBuildDependencies());
    } else if (node instanceof TaskDependency) {
        TaskDependency dependency = (TaskDependency) node;
        values.addAll(dependency.getDependencies(task));
    } else if (node instanceof Task) {
        values.add((Task) node);
    } else {
        throw new IllegalArgumentException(String.format("Cannot resolve object of unknown type %s to a Task.",
                node.getClass().getSimpleName()));
    }
}
 
Example #5
Source File: CachingTaskDependencyResolveContext.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void getNodeValues(Object node, Collection<? super Task> values, Collection<? super Object> connectedNodes) {
    if (node instanceof TaskDependencyInternal) {
        TaskDependencyInternal taskDependency = (TaskDependencyInternal) node;
        queue.clear();
        taskDependency.resolve(CachingTaskDependencyResolveContext.this);
        connectedNodes.addAll(queue);
    } else if (node instanceof Buildable) {
        Buildable buildable = (Buildable) node;
        connectedNodes.add(buildable.getBuildDependencies());
    } else if (node instanceof TaskDependency) {
        TaskDependency dependency = (TaskDependency) node;
        values.addAll(dependency.getDependencies(task));
    } else if (node instanceof Task) {
        values.add((Task) node);
    } else {
        throw new IllegalArgumentException(String.format("Cannot resolve object of unknown type %s to a Task.",
                node.getClass().getSimpleName()));
    }
}
 
Example #6
Source File: DefaultFileCollectionResolveContext.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void convertInto(Object element, Collection<? super FileCollection> result, FileResolver fileResolver) {
    if (element instanceof DefaultFileCollectionResolveContext) {
        DefaultFileCollectionResolveContext nestedContext = (DefaultFileCollectionResolveContext) element;
        result.addAll(nestedContext.resolveAsFileCollections());
    } else if (element instanceof FileCollection) {
        FileCollection fileCollection = (FileCollection) element;
        result.add(fileCollection);
    } else if (element instanceof MinimalFileTree) {
        MinimalFileTree fileTree = (MinimalFileTree) element;
        result.add(new FileTreeAdapter(fileTree));
    } else if (element instanceof MinimalFileSet) {
        MinimalFileSet fileSet = (MinimalFileSet) element;
        result.add(new FileCollectionAdapter(fileSet));
    } else if (element instanceof MinimalFileCollection) {
        throw new UnsupportedOperationException(String.format("Cannot convert instance of %s to FileTree", element.getClass().getSimpleName()));
    } else if (element instanceof TaskDependency) {
        // Ignore
        return;
    } else {
        result.add(new FileCollectionAdapter(new ListBackedFileSet(fileResolver.resolve(element))));
    }
}
 
Example #7
Source File: FileCollectionBackedArchiveTextResource.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public FileCollectionBackedArchiveTextResource(final FileOperations fileOperations,
                                               final TemporaryFileProvider tempFileProvider,
                                               final FileCollection fileCollection,
                                               final String path, Charset charset) {
    super(tempFileProvider, new LazilyInitializedFileTree() {
        @Override
        public FileTree createDelegate() {
            File archiveFile = fileCollection.getSingleFile();
            String fileExtension = Files.getFileExtension(archiveFile.getName());
            FileTree archiveContents = fileExtension.equals("jar") || fileExtension.equals("zip")
                    ? fileOperations.zipTree(archiveFile) : fileOperations.tarTree(archiveFile);
            PatternSet patternSet = new PatternSet();
            patternSet.include(path);
            return archiveContents.matching(patternSet);
        }
        public TaskDependency getBuildDependencies() {
            return fileCollection.getBuildDependencies();
        }
    }, charset);
}
 
Example #8
Source File: AbstractFileCollection.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public FileCollection minus(final FileCollection collection) {
    return new AbstractFileCollection() {
        @Override
        public String getDisplayName() {
            return AbstractFileCollection.this.getDisplayName();
        }

        @Override
        public TaskDependency getBuildDependencies() {
            return AbstractFileCollection.this.getBuildDependencies();
        }

        public Set<File> getFiles() {
            Set<File> files = new LinkedHashSet<File>(AbstractFileCollection.this.getFiles());
            files.removeAll(collection.getFiles());
            return files;
        }
    };
}
 
Example #9
Source File: SourceSetNativeDependencyResolver.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public FileCollection getIncludeRoots() {
    return new AbstractFileCollection() {
        @Override
        public String getDisplayName() {
            return "Include roots of " + sourceSet.getName();
        }

        public Set<File> getFiles() {
            return sourceSet.getExportedHeaders().getSrcDirs();
        }

        @Override
        public TaskDependency getBuildDependencies() {
            return sourceSet.getBuildDependencies();
        }
    };
}
 
Example #10
Source File: SourceSetNativeDependencyResolver.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public FileCollection getIncludeRoots() {
    return new AbstractFileCollection() {
        @Override
        public String getDisplayName() {
            return "Include roots of " + sourceSet.getName();
        }

        public Set<File> getFiles() {
            return sourceSet.getExportedHeaders().getSrcDirs();
        }

        @Override
        public TaskDependency getBuildDependencies() {
            return sourceSet.getBuildDependencies();
        }
    };
}
 
Example #11
Source File: CompositeFileCollection.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public FileCollection filter(final Spec<? super File> filterSpec) {
    return new CompositeFileCollection() {
        @Override
        public void resolve(FileCollectionResolveContext context) {
            for (FileCollection collection : CompositeFileCollection.this.getSourceCollections()) {
                context.add(collection.filter(filterSpec));
            }
        }

        @Override
        public String getDisplayName() {
            return CompositeFileCollection.this.getDisplayName();
        }

        @Override
        public TaskDependency getBuildDependencies() {
            return CompositeFileCollection.this.getBuildDependencies();
        }
    };
}
 
Example #12
Source File: DefaultFileCollectionResolveContext.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void convertInto(Object element, Collection<? super MinimalFileCollection> result, FileResolver resolver) {
    if (element instanceof DefaultFileCollectionResolveContext) {
        DefaultFileCollectionResolveContext nestedContext = (DefaultFileCollectionResolveContext) element;
        result.addAll(nestedContext.resolveAsMinimalFileCollections());
    } else if (element instanceof MinimalFileCollection) {
        MinimalFileCollection collection = (MinimalFileCollection) element;
        result.add(collection);
    } else if (element instanceof FileCollection) {
        throw new UnsupportedOperationException(String.format("Cannot convert instance of %s to MinimalFileCollection", element.getClass().getSimpleName()));
    } else if (element instanceof TaskDependency) {
        // Ignore
        return;
    } else {
        result.add(new ListBackedFileSet(resolver.resolve(element)));
    }
}
 
Example #13
Source File: DefaultJavaSourceSet.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public TaskDependency getBuildDependencies() {
    return new TaskDependency() {
        public Set<? extends Task> getDependencies(Task task) {
            Set<Task> dependencies = new HashSet<Task>();
            dependencies.addAll(compileClasspath.getBuildDependencies().getDependencies(task));
            dependencies.addAll(getSource().getBuildDependencies().getDependencies(task));
            return dependencies;
        }
    };
}
 
Example #14
Source File: DefaultJavaSourceSet.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public TaskDependency getBuildDependencies() {
    return new TaskDependency() {
        public Set<? extends Task> getDependencies(Task task) {
            Set<Task> dependencies = new HashSet<Task>();
            dependencies.addAll(compileClasspath.getBuildDependencies().getDependencies(task));
            dependencies.addAll(getSource().getBuildDependencies().getDependencies(task));
            return dependencies;
        }
    };
}
 
Example #15
Source File: FileCollectionAdapter.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public TaskDependency getBuildDependencies() {
    if (fileCollection instanceof Buildable) {
        Buildable buildable = (Buildable) fileCollection;
        return buildable.getBuildDependencies();
    }
    return super.getBuildDependencies();
}
 
Example #16
Source File: BuildDependenciesOnlyFileCollectionResolveContext.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void convertInto(Object element, Collection<? super FileTree> result, FileResolver resolver) {
    if (element instanceof DefaultFileCollectionResolveContext) {
        DefaultFileCollectionResolveContext nestedContext = (DefaultFileCollectionResolveContext) element;
        result.addAll(nestedContext.resolveAsFileTrees());
    } else if (element instanceof Buildable) {
        Buildable buildable = (Buildable) element;
        result.add(new FileTreeAdapter(new EmptyFileTree(buildable.getBuildDependencies())));
    } else if (element instanceof TaskDependency) {
        TaskDependency dependency = (TaskDependency) element;
        result.add(new FileTreeAdapter(new EmptyFileTree(dependency)));
    }
}
 
Example #17
Source File: BuildDependenciesOnlyFileCollectionResolveContext.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void convertInto(Object element, Collection<? super FileTree> result, FileResolver resolver) {
    if (element instanceof DefaultFileCollectionResolveContext) {
        DefaultFileCollectionResolveContext nestedContext = (DefaultFileCollectionResolveContext) element;
        result.addAll(nestedContext.resolveAsFileTrees());
    } else if (element instanceof Buildable) {
        Buildable buildable = (Buildable) element;
        result.add(new FileTreeAdapter(new EmptyFileTree(buildable.getBuildDependencies())));
    } else if (element instanceof TaskDependency) {
        TaskDependency dependency = (TaskDependency) element;
        result.add(new FileTreeAdapter(new EmptyFileTree(dependency)));
    }
}
 
Example #18
Source File: FileCollectionAdapter.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public TaskDependency getBuildDependencies() {
    if (fileCollection instanceof Buildable) {
        Buildable buildable = (Buildable) fileCollection;
        return buildable.getBuildDependencies();
    }
    return super.getBuildDependencies();
}
 
Example #19
Source File: AbstractBuildableModelElement.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public TaskDependency getBuildDependencies() {
    return new TaskDependency() {
        public Set<? extends Task> getDependencies(Task other) {
            if (lifecycleTask == null) {
                return buildDependencies.getDependencies(other);
            }
            return Collections.singleton(lifecycleTask);
        }
    };
}
 
Example #20
Source File: BuildDependenciesOnlyFileCollectionResolveContext.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void convertInto(Object element, Collection<? super FileTree> result, FileResolver resolver) {
    if (element instanceof DefaultFileCollectionResolveContext) {
        DefaultFileCollectionResolveContext nestedContext = (DefaultFileCollectionResolveContext) element;
        result.addAll(nestedContext.resolveAsFileTrees());
    } else if (element instanceof Buildable) {
        Buildable buildable = (Buildable) element;
        result.add(new FileTreeAdapter(new EmptyFileTree(buildable.getBuildDependencies())));
    } else if (element instanceof TaskDependency) {
        TaskDependency dependency = (TaskDependency) element;
        result.add(new FileTreeAdapter(new EmptyFileTree(dependency)));
    }
}
 
Example #21
Source File: DefaultConfiguration.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public TaskDependency getTaskDependencyFromProjectDependency(final boolean useDependedOn, final String taskName) {
    if (useDependedOn) {
        return new TasksFromProjectDependencies(taskName, getAllDependencies());
    } else {
        return new TasksFromDependentProjects(taskName, getName());
    }
}
 
Example #22
Source File: AbstractTask.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public boolean dependsOnTaskDidWork() {
    TaskDependency dependency = getTaskDependencies();
    for (Task depTask : dependency.getDependencies(this)) {
        if (depTask.getDidWork()) {
            return true;
        }
    }
    return false;
}
 
Example #23
Source File: AntTarget.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public AntTarget() {
    dependsOn(new TaskDependency() {
        public Set<? extends Task> getDependencies(Task task) {
            return getAntTargetDependencies();
        }
    });
}
 
Example #24
Source File: AbstractBuildableModelElement.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public TaskDependency getBuildDependencies() {
    return new TaskDependency() {
        public Set<? extends Task> getDependencies(Task other) {
            if (lifecycleTask == null) {
                return buildDependencies.getDependencies(other);
            }
            return Collections.singleton(lifecycleTask);
        }
    };
}
 
Example #25
Source File: FileCollectionAdapter.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public TaskDependency getBuildDependencies() {
    if (fileCollection instanceof Buildable) {
        Buildable buildable = (Buildable) fileCollection;
        return buildable.getBuildDependencies();
    }
    return super.getBuildDependencies();
}
 
Example #26
Source File: AbstractFileCollection.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public TaskDependency getBuildDependencies() {
    return new DefaultTaskDependency();
}
 
Example #27
Source File: DefaultClasspath.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public TaskDependency getBuildDependencies() {
    return files.getBuildDependencies();
}
 
Example #28
Source File: DefaultMavenArtifactSet.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public TaskDependency getBuildDependencies() {
    return builtBy;
}
 
Example #29
Source File: AbstractTask.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public TaskDependency getShouldRunAfter() {
    return shouldRunAfter;
}
 
Example #30
Source File: AbstractPublishArtifact.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public TaskDependency getBuildDependencies() {
    return taskDependency;
}