use of org.gradle.api.tasks.TaskDependency in project gradle by gradle.
the class DefaultConfigurableFileCollectionTest method taskDependenciesContainsUnionOfDependenciesOfNestedFileCollectionsPlusOwnDependencies.
@Test
public void taskDependenciesContainsUnionOfDependenciesOfNestedFileCollectionsPlusOwnDependencies() {
final FileCollectionInternal fileCollectionMock = context.mock(FileCollectionInternal.class);
collection.from(fileCollectionMock);
collection.from("f");
collection.builtBy("b");
final Task taskA = context.mock(Task.class, "a");
final Task taskB = context.mock(Task.class, "b");
context.checking(new Expectations() {
{
allowing(resolverMock).resolve("f");
will(returnValue(new File("f")));
TaskDependency dependency = context.mock(TaskDependency.class);
allowing(fileCollectionMock).getBuildDependencies();
will(returnValue(dependency));
allowing(dependency).getDependencies(null);
will(returnValue(toSet(taskA)));
allowing(taskResolverStub).resolveTask("b");
will(returnValue(taskB));
}
});
assertThat(collection.getBuildDependencies().getDependencies(null), equalTo((Set) toSet(taskA, taskB)));
}
use of org.gradle.api.tasks.TaskDependency in project gradle by gradle.
the class TaskReportTaskTest method task.
private Task task(final String name, final String taskGroup, final Task... dependencies) {
final Task task = context.mock(Task.class);
context.checking(new Expectations() {
{
allowing(task).getName();
will(returnValue(name));
allowing(task).getPath();
will(returnValue(':' + name));
allowing(task).getProject();
will(returnValue(project));
allowing(project).relativeProjectPath(':' + name);
will(returnValue(name));
allowing(task).getGroup();
will(returnValue(taskGroup));
allowing(task).compareTo(with(Matchers.notNullValue(Task.class)));
will(new Action() {
public Object invoke(Invocation invocation) throws Throwable {
Task other = (Task) invocation.getParameter(0);
return name.compareTo(other.getName());
}
public void describeTo(Description description) {
description.appendText("compare to");
}
});
TaskDependency dependency = context.mock(TaskDependency.class);
allowing(task).getTaskDependencies();
will(returnValue(dependency));
allowing(dependency).getDependencies(task);
will(returnValue(toSet(dependencies)));
}
});
return task;
}
use of org.gradle.api.tasks.TaskDependency in project spring-boot by spring-projects.
the class RepackagePluginFeatures method addRepackageTask.
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);
}
use of org.gradle.api.tasks.TaskDependency in project gradle by gradle.
the class AbstractTask method dependsOnTaskDidWork.
@Override
public boolean dependsOnTaskDidWork() {
DeprecationLogger.nagUserOfDiscontinuedMethod("Task.dependsOnTaskDidWork()", "Instead, check the value of \"didWork()\" for each task, or declare the task inputs and outputs and let Gradle decide what needs to be run.");
TaskDependency dependency = getTaskDependencies();
for (Task depTask : dependency.getDependencies(this)) {
if (depTask.getDidWork()) {
return true;
}
}
return false;
}
use of org.gradle.api.tasks.TaskDependency in project gradle by gradle.
the class ArtifactTransformingVisitor method visitArtifact.
@Override
public void visitArtifact(String variantName, AttributeContainer variantAttributes, ResolvableArtifact artifact) {
TransformArtifactOperation operation = artifactResults.get(artifact);
if (operation.getFailure() != null) {
visitor.visitFailure(operation.getFailure());
return;
}
ResolvedArtifact sourceArtifact = artifact.toPublicView();
List<File> transformedFiles = operation.getResult();
TaskDependency buildDependencies = ((Buildable) artifact).getBuildDependencies();
for (File output : transformedFiles) {
IvyArtifactName artifactName = DefaultIvyArtifactName.forFile(output, sourceArtifact.getClassifier());
ComponentArtifactIdentifier newId = new ComponentFileArtifactIdentifier(sourceArtifact.getId().getComponentIdentifier(), artifactName);
DefaultResolvedArtifact resolvedArtifact = new DefaultResolvedArtifact(sourceArtifact.getModuleVersion().getId(), artifactName, newId, buildDependencies, output);
visitor.visitArtifact(variantName, target, resolvedArtifact);
}
}
Aggregations