private TaskDependency doGetTaskDependency(Spec<? super Dependency> dependencySpec, AttributeContainerInternal requestedAttributes) { synchronized (resolutionLock) { if (resolutionStrategy.resolveGraphToDetermineTaskDependencies()) { // Force graph resolution as this is required to calculate build dependencies resolveToStateOrLater(GRAPH_RESOLVED); } ResolverResults results; if (getState() == State.UNRESOLVED) { // Traverse graph results = new DefaultResolverResults(); resolver.resolveBuildDependencies(this, results); } else { // Otherwise, already have a result, so reuse it results = cachedResolverResults; } List<Object> buildDependencies = new ArrayList<Object>(); results.getVisitedArtifacts().select(dependencySpec, requestedAttributes).collectBuildDependencies(buildDependencies); return TaskDependencies.of(buildDependencies); } }
public void getNodeValues(Object node, Collection<? super Task> values, Collection<? super Object> connectedNodes) { if (node instanceof TaskDependencyContainer) { TaskDependencyContainer taskDependency = (TaskDependencyContainer) node; queue.clear(); taskDependency.visitDependencies(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())); } }
public void convertInto(Object element, Collection<? super FileCollectionInternal> result, PathToFileResolver fileResolver) { if (element instanceof DefaultFileCollectionResolveContext) { DefaultFileCollectionResolveContext nestedContext = (DefaultFileCollectionResolveContext) element; result.addAll(nestedContext.resolveAsFileCollections()); } else if (element instanceof FileCollection) { FileCollection fileCollection = (FileCollection) element; result.add(Cast.cast(FileCollectionInternal.class, 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)))); } }
public void convertInto(Object element, Collection<? super MinimalFileCollection> result, PathToFileResolver 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))); } }
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; } }; }
public FileCollection filter(final Spec<? super File> filterSpec) { return new AbstractFileCollection() { @Override public String getDisplayName() { return AbstractFileCollection.this.getDisplayName(); } @Override public TaskDependency getBuildDependencies() { return AbstractFileCollection.this.getBuildDependencies(); } public Set<File> getFiles() { return CollectionUtils.filter(AbstractFileCollection.this, new LinkedHashSet<File>(), filterSpec); } }; }
private void addRepackageTask(Project project) { RepackageTask task = project.getTasks().create(REPACKAGE_TASK_NAME, RepackageTask.class); task.setDescription("Repackage existing JAR and WAR " + "archives so that they can be executed from the command " + "line using 'java -jar'"); task.setGroup(BasePlugin.BUILD_GROUP); Configuration runtimeConfiguration = project.getConfigurations() .getByName(JavaPlugin.RUNTIME_CONFIGURATION_NAME); TaskDependency runtimeProjectDependencyJarTasks = runtimeConfiguration .getTaskDependencyFromProjectDependency(true, JavaPlugin.JAR_TASK_NAME); task.dependsOn( project.getConfigurations().getByName(Dependency.ARCHIVES_CONFIGURATION) .getAllArtifacts().getBuildDependencies(), runtimeProjectDependencyJarTasks); registerOutput(project, task); ensureTaskRunsOnAssembly(project, task); ensureMainClassHasBeenFound(project, task); }
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(); } }; }
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())); } }
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); }
@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(); } }; }
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)))); } }
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))); } }
@Override public TaskDependency getBuildDependencies() { ensureResolved(false); List<TaskDependency> taskDependencies = new ArrayList<TaskDependency>(); resolveResult.artifactsResults.getArtifacts().collectBuildDependencies(taskDependencies); return TaskDependencies.of(taskDependencies); }
@Override public TaskDependency getBuildDependencies() { return new TaskDependency() { public Set<? extends Task> getDependencies(Task other) { if (buildTask == null) { return buildTaskDependencies.getDependencies(other); } return Collections.singleton(buildTask); } }; }
public DefaultResolvedArtifact(ModuleVersionIdentifier owner, IvyArtifactName artifact, ComponentArtifactIdentifier artifactId, TaskDependency buildDependencies, Factory<File> artifactSource) { this.owner = owner; this.artifact = artifact; this.artifactId = artifactId; this.buildDependencies = buildDependencies; this.artifactSource = artifactSource; this.attributes = DefaultArtifactAttributes.forIvyArtifactName(artifact); }
public DefaultResolvedArtifact(ModuleVersionIdentifier owner, IvyArtifactName artifact, ComponentArtifactIdentifier artifactId, TaskDependency buildDependencies, File artifactFile) { this.owner = owner; this.artifact = artifact; this.artifactId = artifactId; this.buildDependencies = buildDependencies; this.attributes = DefaultArtifactAttributes.forIvyArtifactName(artifact); this.file = artifactFile; }
/** * {@inheritDoc} */ public TaskDependency getTaskDependencyFromProjectDependency(final boolean useDependedOn, final String taskName) { if (useDependedOn) { return new TasksFromProjectDependencies(taskName, getAllDependencies(), projectAccessListener); } else { return new TasksFromDependentProjects(taskName, getName()); } }
@Override public final TaskDependency getBuildDependencies() { if (hasOutputs()) { return AbstractNativeLibraryBinarySpec.this.getBuildDependencies(); } return TaskDependencies.EMPTY; }
@Override public TaskDependency getBuildDependencies() { DefaultTaskDependency dependency = new DefaultTaskDependency(); for (HeaderExportingSourceSet sourceSet : getInputs().withType(HeaderExportingSourceSet.class)) { dependency.add(sourceSet.getBuildDependencies()); } return dependency; }
@Override public TaskDependency getBuildDependencies() { return new TaskDependency() { @Override public Set<? extends Task> getDependencies(Task task) { return Collections.emptySet(); } }; }
public boolean dependsOnTaskDidWork() { TaskDependency dependency = getTaskDependencies(); for (Task depTask : dependency.getDependencies(this)) { if (depTask.getDidWork()) { return true; } } return false; }
public TaskDependency shouldRunAfter(final Object... paths) { taskMutator.mutate("Task.shouldRunAfter(Object...)", new Runnable() { public void run() { shouldRunAfter.add(paths); } }); return shouldRunAfter; }
@Override public final TaskDependency getBuildDependencies() { return new AbstractTaskDependency() { @Override public String toString() { return CompositeFileCollection.this.toString() + " dependencies"; } public void visitDependencies(TaskDependencyResolveContext context) { CompositeFileCollection.this.visitDependencies(context); } }; }
@Override public TaskDependency getBuildDependencies() { if (tree instanceof Buildable) { Buildable buildable = (Buildable) tree; return buildable.getBuildDependencies(); } return super.getBuildDependencies(); }
@Override public TaskDependency getBuildDependencies() { if (fileCollection instanceof Buildable) { Buildable buildable = (Buildable) fileCollection; return buildable.getBuildDependencies(); } return super.getBuildDependencies(); }
@Override public FileCollection create(final TaskDependency builtBy, MinimalFileSet contents) { if (contents instanceof Buildable) { throw new UnsupportedOperationException("Not implemented yet."); } return new FileCollectionAdapter(contents) { @Override public TaskDependency getBuildDependencies() { return builtBy; } }; }
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; } }; }
/** * {@inheritDoc} */ public TaskDependency getTaskDependencyFromProjectDependency(final boolean useDependedOn, final String taskName) { if (useDependedOn) { return new TasksFromProjectDependencies(taskName, getAllDependencies()); } else { return new TasksFromDependentProjects(taskName, getName()); } }