use of org.gradle.api.tasks.TaskDependency in project gradle by gradle.
the class IdeaPlugin method allImlArtifactsInComposite.
private List<TaskDependency> allImlArtifactsInComposite(ProjectInternal project, IdeaProject ideaProject) {
List<TaskDependency> dependencies = Lists.newArrayList();
ProjectComponentIdentifier thisProjectId = projectPathRegistry.getProjectComponentIdentifier(project.getIdentityPath());
for (IdeArtifactRegistry.Reference<IdeaModuleMetadata> reference : artifactRegistry.getIdeArtifactMetadata(IdeaModuleMetadata.class)) {
BuildIdentifier otherBuildId = reference.getOwningProject().getBuild();
if (thisProjectId.getBuild().equals(otherBuildId)) {
// IDEA Module for project in current build: don't include any module that has been excluded from project
boolean found = false;
for (IdeaModule ideaModule : ideaProject.getModules()) {
if (reference.get().getFile().equals(ideaModule.getOutputFile())) {
found = true;
break;
}
}
if (!found) {
continue;
}
}
dependencies.add(reference.getBuildDependencies());
}
return dependencies;
}
use of org.gradle.api.tasks.TaskDependency in project gradle by gradle.
the class DefaultTaskDependency method visitDependencies.
@Override
public void visitDependencies(final TaskDependencyResolveContext context) {
Set<Object> mutableValues = getMutableValues();
if (mutableValues.isEmpty() && immutableValues.isEmpty()) {
return;
}
final Deque<Object> queue = new ArrayDeque<Object>(mutableValues.size() + immutableValues.size());
queue.addAll(immutableValues);
queue.addAll(mutableValues);
while (!queue.isEmpty()) {
Object dependency = queue.removeFirst();
if (dependency instanceof Buildable) {
context.add(dependency);
} else if (dependency instanceof Task) {
context.add(dependency);
} else if (dependency instanceof TaskDependency) {
context.add(dependency);
} else if (dependency instanceof ProviderInternal) {
// When a Provider is used as a task dependency (rather than as a task input), need to unpack the value
ProviderInternal<?> provider = (ProviderInternal<?>) dependency;
ValueSupplier.ValueProducer producer = provider.getProducer();
if (producer.isKnown()) {
producer.visitProducerTasks(context);
} else {
// The provider does not know how to produce the value, so use the value instead
queue.addFirst(provider.get());
}
} else if (dependency instanceof TaskDependencyContainer) {
((TaskDependencyContainer) dependency).visitDependencies(context);
} else if (dependency instanceof Closure) {
Closure closure = (Closure) dependency;
Object closureResult = closure.call(context.getTask());
if (closureResult != null) {
queue.addFirst(closureResult);
}
} else if (dependency instanceof List) {
List<?> list = (List) dependency;
if (list instanceof RandomAccess) {
for (int i = list.size() - 1; i >= 0; i--) {
queue.addFirst(list.get(i));
}
} else {
ListIterator<?> iterator = list.listIterator(list.size());
while (iterator.hasPrevious()) {
Object item = iterator.previous();
queue.addFirst(item);
}
}
} else if (dependency instanceof Iterable && !(dependency instanceof Path)) {
// Path is Iterable, but we don't want to unpack it
Iterable<?> iterable = Cast.uncheckedNonnullCast(dependency);
addAllFirst(queue, toArray(iterable, Object.class));
} else if (dependency instanceof Map) {
Map<?, ?> map = Cast.uncheckedNonnullCast(dependency);
addAllFirst(queue, map.values().toArray());
} else if (dependency instanceof Object[]) {
Object[] array = (Object[]) dependency;
addAllFirst(queue, array);
} else if (dependency instanceof Callable) {
Callable<?> callable = Cast.uncheckedNonnullCast(dependency);
Object callableResult = uncheckedCall(Cast.uncheckedNonnullCast(callable));
if (callableResult != null) {
queue.addFirst(callableResult);
}
} else if (resolver != null && dependency instanceof CharSequence) {
context.add(resolver.resolveTask(dependency.toString()));
} else {
List<String> formats = new ArrayList<String>();
if (resolver != null) {
formats.add("A String or CharSequence task name or path");
}
formats.add("A Task instance");
formats.add("A TaskReference instance");
formats.add("A Buildable instance");
formats.add("A TaskDependency instance");
formats.add("A Provider that represents a task output");
formats.add("A Provider instance that returns any of these types");
formats.add("A Closure instance that returns any of these types");
formats.add("A Callable instance that returns any of these types");
formats.add("An Iterable, Collection, Map or array instance that contains any of these types");
throw new UnsupportedNotationException(dependency, String.format("Cannot convert %s to a task.", dependency), null, formats);
}
}
}
use of org.gradle.api.tasks.TaskDependency in project gradle by gradle.
the class RunBuildDependenciesTaskBuilder method populate.
private List<TaskDependency> populate(Project project) {
project.getPluginManager().apply(EclipsePlugin.class);
EclipseModel eclipseModel = project.getExtensions().getByType(EclipseModel.class);
EclipseClasspath eclipseClasspath = eclipseModel.getClasspath();
EclipseModelBuilder.ClasspathElements elements = EclipseModelBuilder.gatherClasspathElements(projectOpenStatus, eclipseClasspath, false);
List<TaskDependency> buildDependencies = new ArrayList<>(elements.getBuildDependencies());
for (Project childProject : project.getChildProjects().values()) {
buildDependencies.addAll(populate(childProject));
}
return buildDependencies;
}
use of org.gradle.api.tasks.TaskDependency in project gradle by gradle.
the class RunBuildDependenciesTaskBuilder method buildAll.
@Override
public RunClosedProjectBuildDependencies buildAll(String modelName, EclipseRuntime eclipseRuntime, Project project) {
this.projectOpenStatus = eclipseRuntime.getWorkspace().getProjects().stream().collect(Collectors.toMap(EclipseWorkspaceProject::getName, EclipseModelBuilder::isProjectOpen, (a, b) -> a | b));
List<TaskDependency> buildDependencies = populate(project.getRootProject());
if (!buildDependencies.isEmpty()) {
Gradle rootGradle = getRootGradle(project.getGradle());
Project rootProject = rootGradle.getRootProject();
StartParameter startParameter = rootGradle.getStartParameter();
List<String> taskPaths = new ArrayList<>(startParameter.getTaskNames());
String parentTaskName = parentTaskName(rootProject, "eclipseClosedDependencies");
Task task = rootProject.task(parentTaskName);
task.dependsOn(buildDependencies.toArray(new Object[0]));
taskPaths.add(parentTaskName);
startParameter.setTaskNames(taskPaths);
}
return DefaultRunClosedProjectBuildDependencies.INSTANCE;
}
use of org.gradle.api.tasks.TaskDependency in project gradle by gradle.
the class DefaultSelfResolvingDependencyTest method usesSourceFileCollectionToDetermineBuildDependencies.
@Test
public void usesSourceFileCollectionToDetermineBuildDependencies() {
final TaskDependency taskDependency = context.mock(TaskDependency.class);
context.checking(new Expectations() {
{
allowing(source).getBuildDependencies();
will(returnValue(taskDependency));
}
});
assertThat(dependency.getBuildDependencies(), sameInstance(taskDependency));
}
Aggregations