Search in sources :

Example 1 with DefaultBuildIdentifier

use of org.gradle.api.internal.artifacts.DefaultBuildIdentifier in project gradle by gradle.

the class IncludedBuildTaskReferenceResolver method constructTask.

@Override
public Task constructTask(final TaskReference reference, TaskContainer tasks) {
    if (!(reference instanceof IncludedBuildTaskReference)) {
        return null;
    }
    final IncludedBuildTaskReference ref = (IncludedBuildTaskReference) reference;
    final BuildIdentifier sourceBuild = buildIdentity.getCurrentBuild();
    final BuildIdentifier targetBuild = new DefaultBuildIdentifier(ref.getBuildName());
    includedBuilds.addTask(sourceBuild, targetBuild, ref.getTaskPath());
    String delegateTaskName = ref.getName();
    Task task = tasks.findByName(delegateTaskName);
    if (task == null) {
        return tasks.create(delegateTaskName, CompositeBuildTaskDelegate.class, new Action<CompositeBuildTaskDelegate>() {

            @Override
            public void execute(CompositeBuildTaskDelegate compositeBuildTaskDelegate) {
                compositeBuildTaskDelegate.setBuild(targetBuild);
                compositeBuildTaskDelegate.setTaskPath(ref.getTaskPath());
            }
        });
    }
    if (task instanceof CompositeBuildTaskDelegate) {
        return task;
    }
    throw new TaskInstantiationException("Cannot create delegating task '" + delegateTaskName + "' as task with same name already exists.");
}
Also used : Task(org.gradle.api.Task) DefaultBuildIdentifier(org.gradle.api.internal.artifacts.DefaultBuildIdentifier) BuildIdentifier(org.gradle.api.artifacts.component.BuildIdentifier) DefaultBuildIdentifier(org.gradle.api.internal.artifacts.DefaultBuildIdentifier) TaskInstantiationException(org.gradle.api.tasks.TaskInstantiationException)

Example 2 with DefaultBuildIdentifier

use of org.gradle.api.internal.artifacts.DefaultBuildIdentifier in project gradle by gradle.

the class DefaultIncludedBuildRegistry method registerProjects.

private void registerProjects(Iterable<IncludedBuildInternal> includedBuilds, boolean isImplicitBuild) {
    for (IncludedBuildInternal includedBuild : includedBuilds) {
        Path rootProjectPath = Path.ROOT.child(includedBuild.getName());
        BuildIdentifier buildIdentifier = new DefaultBuildIdentifier(includedBuild.getName());
        Set<DefaultProjectDescriptor> allProjects = includedBuild.getLoadedSettings().getProjectRegistry().getAllProjects();
        registerProjects(rootProjectPath, buildIdentifier, allProjects, isImplicitBuild);
    }
}
Also used : Path(org.gradle.util.Path) DefaultBuildIdentifier(org.gradle.api.internal.artifacts.DefaultBuildIdentifier) BuildIdentifier(org.gradle.api.artifacts.component.BuildIdentifier) DefaultBuildIdentifier(org.gradle.api.internal.artifacts.DefaultBuildIdentifier) DefaultProjectDescriptor(org.gradle.initialization.DefaultProjectDescriptor)

Aggregations

BuildIdentifier (org.gradle.api.artifacts.component.BuildIdentifier)2 DefaultBuildIdentifier (org.gradle.api.internal.artifacts.DefaultBuildIdentifier)2 Task (org.gradle.api.Task)1 TaskInstantiationException (org.gradle.api.tasks.TaskInstantiationException)1 DefaultProjectDescriptor (org.gradle.initialization.DefaultProjectDescriptor)1 Path (org.gradle.util.Path)1