Search in sources :

Example 1 with TaskExecutionRequest

use of org.gradle.TaskExecutionRequest in project gradle by gradle.

the class DefaultTasksBuildExecutionAction method configure.

public void configure(BuildExecutionContext context) {
    StartParameter startParameter = context.getGradle().getStartParameter();
    for (TaskExecutionRequest request : startParameter.getTaskRequests()) {
        if (!request.getArgs().isEmpty()) {
            context.proceed();
            return;
        }
    }
    // Gather the default tasks from this first group project
    ProjectInternal project = context.getGradle().getDefaultProject();
    //so that we don't miss out default tasks
    projectConfigurer.configure(project);
    List<String> defaultTasks = project.getDefaultTasks();
    if (defaultTasks.size() == 0) {
        defaultTasks = Collections.singletonList(ProjectInternal.HELP_TASK);
        LOGGER.info("No tasks specified. Using default task {}", GUtil.toString(defaultTasks));
    } else {
        LOGGER.info("No tasks specified. Using project default tasks {}", GUtil.toString(defaultTasks));
    }
    startParameter.setTaskNames(defaultTasks);
    context.proceed();
}
Also used : StartParameter(org.gradle.StartParameter) TaskExecutionRequest(org.gradle.TaskExecutionRequest) ProjectInternal(org.gradle.api.internal.project.ProjectInternal)

Example 2 with TaskExecutionRequest

use of org.gradle.TaskExecutionRequest in project gradle by gradle.

the class ProviderStartParameterConverter method unpack.

private List<TaskExecutionRequest> unpack(final List<InternalLaunchable> launchables, File projectDir) {
    // Important that the launchables are unpacked on the client side, to avoid sending back any additional internal state that
    // the launchable may hold onto. For example, GradleTask implementations hold onto every task for every project in the build
    List<TaskExecutionRequest> requests = new ArrayList<TaskExecutionRequest>(launchables.size());
    for (InternalLaunchable launchable : launchables) {
        if (launchable instanceof TaskExecutionRequest) {
            TaskExecutionRequest originalLaunchable = (TaskExecutionRequest) launchable;
            TaskExecutionRequest launchableImpl = new DefaultTaskExecutionRequest(originalLaunchable.getArgs(), originalLaunchable.getProjectPath(), originalLaunchable.getRootDir());
            requests.add(launchableImpl);
        } else {
            throw new InternalUnsupportedBuildArgumentException("Problem with provided launchable arguments: " + launchables + ". " + "\nOnly objects from this provider can be built.");
        }
    }
    return requests;
}
Also used : DefaultTaskExecutionRequest(org.gradle.internal.DefaultTaskExecutionRequest) TaskExecutionRequest(org.gradle.TaskExecutionRequest) DefaultTaskExecutionRequest(org.gradle.internal.DefaultTaskExecutionRequest) ArrayList(java.util.ArrayList) InternalUnsupportedBuildArgumentException(org.gradle.tooling.internal.protocol.exceptions.InternalUnsupportedBuildArgumentException) InternalLaunchable(org.gradle.tooling.internal.protocol.InternalLaunchable)

Example 3 with TaskExecutionRequest

use of org.gradle.TaskExecutionRequest in project gradle by gradle.

the class TaskNameResolvingBuildConfigurationAction method configure.

public void configure(BuildExecutionContext context) {
    GradleInternal gradle = context.getGradle();
    TaskGraphExecuter executer = gradle.getTaskGraph();
    List<TaskExecutionRequest> taskParameters = gradle.getStartParameter().getTaskRequests();
    for (TaskExecutionRequest taskParameter : taskParameters) {
        List<TaskSelector.TaskSelection> taskSelections = commandLineTaskParser.parseTasks(taskParameter);
        for (TaskSelector.TaskSelection taskSelection : taskSelections) {
            LOGGER.info("Selected primary task '{}' from project {}", taskSelection.getTaskName(), taskSelection.getProjectPath());
            executer.addTasks(taskSelection.getTasks());
        }
    }
    context.proceed();
}
Also used : GradleInternal(org.gradle.api.internal.GradleInternal) TaskExecutionRequest(org.gradle.TaskExecutionRequest)

Aggregations

TaskExecutionRequest (org.gradle.TaskExecutionRequest)3 ArrayList (java.util.ArrayList)1 StartParameter (org.gradle.StartParameter)1 GradleInternal (org.gradle.api.internal.GradleInternal)1 ProjectInternal (org.gradle.api.internal.project.ProjectInternal)1 DefaultTaskExecutionRequest (org.gradle.internal.DefaultTaskExecutionRequest)1 InternalLaunchable (org.gradle.tooling.internal.protocol.InternalLaunchable)1 InternalUnsupportedBuildArgumentException (org.gradle.tooling.internal.protocol.exceptions.InternalUnsupportedBuildArgumentException)1