org.gradle.api.internal.tasks.TaskExecutionContext Java Examples

The following examples show how to use org.gradle.api.internal.tasks.TaskExecutionContext. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ValidatingTaskExecuter.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void execute(TaskInternal task, TaskStateInternal state, TaskExecutionContext context) {
    List<String> messages = new ArrayList<String>();
    for (TaskValidator validator : task.getValidators()) {
        validator.validate(task, messages);
    }
    if (!messages.isEmpty()) {
        List<InvalidUserDataException> causes = new ArrayList<InvalidUserDataException>();
        messages = messages.subList(0, Math.min(5, messages.size()));
        for (String message : messages) {
            causes.add(new InvalidUserDataException(message));
        }
        String errorMessage;
        if (messages.size() == 1) {
            errorMessage = String.format("A problem was found with the configuration of %s.", task);
        } else {
            errorMessage = String.format("Some problems were found with the configuration of %s.", task);
        }
        state.executed(new TaskValidationException(errorMessage, causes));
        return;
    }
    executer.execute(task, state, context);
}
 
Example #2
Source File: SkipOnlyIfTaskExecuter.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void execute(TaskInternal task, TaskStateInternal state, TaskExecutionContext context) {
    boolean skip;
    try {
        skip = !task.getOnlyIf().isSatisfiedBy(task);
    } catch (Throwable t) {
        state.executed(new GradleException(String.format("Could not evaluate onlyIf predicate for %s.", task), t));
        return;
    }

    if (skip) {
        LOGGER.info("Skipping {} as task onlyIf is false.", task);
        state.skipped("SKIPPED");
        return;
    }

    executer.execute(task, state, context);
}
 
Example #3
Source File: SkipTaskWithNoActionsExecuter.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void execute(TaskInternal task, TaskStateInternal state, TaskExecutionContext context) {
    if (task.getActions().isEmpty()) {
        LOGGER.info("Skipping {} as it has no actions.", task);
        boolean upToDate = true;
        for (Task dependency : task.getTaskDependencies().getDependencies(task)) {
            if (!dependency.getState().getSkipped()) {
                upToDate = false;
                break;
            }
        }
        if (upToDate) {
            state.upToDate();
        }
        return;
    }
    executer.execute(task, state, context);
}
 
Example #4
Source File: ValidatingTaskExecuter.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void execute(TaskInternal task, TaskStateInternal state, TaskExecutionContext context) {
    List<String> messages = new ArrayList<String>();
    for (TaskValidator validator : task.getValidators()) {
        validator.validate(task, messages);
    }
    if (!messages.isEmpty()) {
        List<InvalidUserDataException> causes = new ArrayList<InvalidUserDataException>();
        messages = messages.subList(0, Math.min(5, messages.size()));
        for (String message : messages) {
            causes.add(new InvalidUserDataException(message));
        }
        String errorMessage;
        if (messages.size() == 1) {
            errorMessage = String.format("A problem was found with the configuration of %s.", task);
        } else {
            errorMessage = String.format("Some problems were found with the configuration of %s.", task);
        }
        state.executed(new TaskValidationException(errorMessage, causes));
        return;
    }
    executer.execute(task, state, context);
}
 
Example #5
Source File: SkipOnlyIfTaskExecuter.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void execute(TaskInternal task, TaskStateInternal state, TaskExecutionContext context) {
    boolean skip;
    try {
        skip = !task.getOnlyIf().isSatisfiedBy(task);
    } catch (Throwable t) {
        state.executed(new GradleException(String.format("Could not evaluate onlyIf predicate for %s.", task), t));
        return;
    }

    if (skip) {
        LOGGER.info("Skipping {} as task onlyIf is false.", task);
        state.skipped("SKIPPED");
        return;
    }

    executer.execute(task, state, context);
}
 
Example #6
Source File: ValidatingTaskExecuter.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void execute(TaskInternal task, TaskStateInternal state, TaskExecutionContext context) {
    List<String> messages = new ArrayList<String>();
    for (TaskValidator validator : task.getValidators()) {
        validator.validate(task, messages);
    }
    if (!messages.isEmpty()) {
        List<InvalidUserDataException> causes = new ArrayList<InvalidUserDataException>();
        messages = messages.subList(0, Math.min(5, messages.size()));
        for (String message : messages) {
            causes.add(new InvalidUserDataException(message));
        }
        String errorMessage;
        if (messages.size() == 1) {
            errorMessage = String.format("A problem was found with the configuration of %s.", task);
        } else {
            errorMessage = String.format("Some problems were found with the configuration of %s.", task);
        }
        state.executed(new TaskValidationException(errorMessage, causes));
        return;
    }
    executer.execute(task, state, context);
}
 
Example #7
Source File: SkipTaskWithNoActionsExecuter.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void execute(TaskInternal task, TaskStateInternal state, TaskExecutionContext context) {
    if (task.getActions().isEmpty()) {
        LOGGER.info("Skipping {} as it has no actions.", task);
        boolean upToDate = true;
        for (Task dependency : task.getTaskDependencies().getDependencies(task)) {
            if (!dependency.getState().getSkipped()) {
                upToDate = false;
                break;
            }
        }
        if (upToDate) {
            state.upToDate();
        }
        return;
    }
    executer.execute(task, state, context);
}
 
Example #8
Source File: SkipOnlyIfTaskExecuter.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void execute(TaskInternal task, TaskStateInternal state, TaskExecutionContext context) {
    boolean skip;
    try {
        skip = !task.getOnlyIf().isSatisfiedBy(task);
    } catch (Throwable t) {
        state.executed(new GradleException(String.format("Could not evaluate onlyIf predicate for %s.", task), t));
        return;
    }

    if (skip) {
        LOGGER.info("Skipping {} as task onlyIf is false.", task);
        state.skipped("SKIPPED");
        return;
    }

    executer.execute(task, state, context);
}
 
Example #9
Source File: SkipOnlyIfTaskExecuter.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void execute(TaskInternal task, TaskStateInternal state, TaskExecutionContext context) {
    boolean skip;
    try {
        skip = !task.getOnlyIf().isSatisfiedBy(task);
    } catch (Throwable t) {
        state.executed(new GradleException(String.format("Could not evaluate onlyIf predicate for %s.", task), t));
        return;
    }

    if (skip) {
        LOGGER.info("Skipping {} as task onlyIf is false.", task);
        state.skipped("SKIPPED");
        return;
    }

    executer.execute(task, state, context);
}
 
Example #10
Source File: SkipTaskWithNoActionsExecuter.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void execute(TaskInternal task, TaskStateInternal state, TaskExecutionContext context) {
    if (task.getActions().isEmpty()) {
        LOGGER.info("Skipping {} as it has no actions.", task);
        boolean upToDate = true;
        for (Task dependency : task.getTaskDependencies().getDependencies(task)) {
            if (!dependency.getState().getSkipped()) {
                upToDate = false;
                break;
            }
        }
        if (upToDate) {
            state.upToDate();
        }
        return;
    }
    executer.execute(task, state, context);
}
 
Example #11
Source File: ValidatingTaskExecuter.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void execute(TaskInternal task, TaskStateInternal state, TaskExecutionContext context) {
    List<String> messages = new ArrayList<String>();
    for (TaskValidator validator : task.getValidators()) {
        validator.validate(task, messages);
    }
    if (!messages.isEmpty()) {
        List<InvalidUserDataException> causes = new ArrayList<InvalidUserDataException>();
        messages = messages.subList(0, Math.min(5, messages.size()));
        for (String message : messages) {
            causes.add(new InvalidUserDataException(message));
        }
        String errorMessage;
        if (messages.size() == 1) {
            errorMessage = String.format("A problem was found with the configuration of %s.", task);
        } else {
            errorMessage = String.format("Some problems were found with the configuration of %s.", task);
        }
        state.executed(new TaskValidationException(errorMessage, causes));
        return;
    }
    executer.execute(task, state, context);
}
 
Example #12
Source File: SkipTaskWithNoActionsExecuter.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void execute(TaskInternal task, TaskStateInternal state, TaskExecutionContext context) {
    if (task.getActions().isEmpty()) {
        LOGGER.info("Skipping {} as it has no actions.", task);
        boolean upToDate = true;
        for (Task dependency : task.getTaskDependencies().getDependencies(task)) {
            if (!dependency.getState().getSkipped()) {
                upToDate = false;
                break;
            }
        }
        if (upToDate) {
            state.upToDate();
        }
        return;
    }
    executer.execute(task, state, context);
}
 
Example #13
Source File: ExecuteAtMostOnceTaskExecuter.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void execute(TaskInternal task, TaskStateInternal state, TaskExecutionContext context) {
    if (state.getExecuted()) {
        return;
    }
    LOGGER.debug("Starting to execute {}", task);
    try {
        executer.execute(task, state, context);
    } finally {
        state.executed();
        LOGGER.debug("Finished executing {}", task);
    }
}
 
Example #14
Source File: SkipUpToDateTaskExecuter.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void execute(TaskInternal task, TaskStateInternal state, TaskExecutionContext context) {
    LOGGER.debug("Determining if {} is up-to-date", task);
    Clock clock = new Clock();
    TaskArtifactState taskArtifactState = repository.getStateFor(task);
    try {
        List<String> messages = new ArrayList<String>();
        if (taskArtifactState.isUpToDate(messages)) {
            LOGGER.info("Skipping {} as it is up-to-date (took {}).", task, clock.getTime());
            state.upToDate();
            return;
        }
        logOutOfDateMessages(messages, task, clock.getTime());

        task.getOutputs().setHistory(taskArtifactState.getExecutionHistory());
        context.setTaskArtifactState(taskArtifactState);

        taskArtifactState.beforeTask();
        try {
            executer.execute(task, state, context);
            if (state.getFailure() == null) {
                taskArtifactState.afterTask();
            }
        } finally {
            task.getOutputs().setHistory(null);
            context.setTaskArtifactState(null);
        }
    } finally {
        taskArtifactState.finished();
    }
}
 
Example #15
Source File: SkipUpToDateTaskExecuter.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void execute(TaskInternal task, TaskStateInternal state, TaskExecutionContext context) {
    LOGGER.debug("Determining if {} is up-to-date", task);
    Clock clock = new Clock();
    TaskArtifactState taskArtifactState = repository.getStateFor(task);
    try {
        List<String> messages = new ArrayList<String>();
        if (taskArtifactState.isUpToDate(messages)) {
            LOGGER.info("Skipping {} as it is up-to-date (took {}).", task, clock.getTime());
            state.upToDate();
            return;
        }
        logOutOfDateMessages(messages, task, clock.getTime());

        task.getOutputs().setHistory(taskArtifactState.getExecutionHistory());
        context.setTaskArtifactState(taskArtifactState);

        taskArtifactState.beforeTask();
        try {
            executer.execute(task, state, context);
            if (state.getFailure() == null) {
                taskArtifactState.afterTask();
            }
        } finally {
            task.getOutputs().setHistory(null);
            context.setTaskArtifactState(null);
        }
    } finally {
        taskArtifactState.finished();
    }
}
 
Example #16
Source File: ExecuteAtMostOnceTaskExecuter.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void execute(TaskInternal task, TaskStateInternal state, TaskExecutionContext context) {
    if (state.getExecuted()) {
        return;
    }
    LOGGER.debug("Starting to execute {}", task);
    try {
        executer.execute(task, state, context);
    } finally {
        state.executed();
        LOGGER.debug("Finished executing {}", task);
    }
}
 
Example #17
Source File: SkipEmptySourceFilesTaskExecuter.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void execute(TaskInternal task, TaskStateInternal state, TaskExecutionContext context) {
    if (task.getInputs().getHasSourceFiles() && task.getInputs().getSourceFiles().isEmpty()) {
        LOGGER.info("Skipping {} as it has no source files.", task);
        state.upToDate();
        return;
    }
    executer.execute(task, state, context);
}
 
Example #18
Source File: ExecuteAtMostOnceTaskExecuter.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void execute(TaskInternal task, TaskStateInternal state, TaskExecutionContext context) {
    if (state.getExecuted()) {
        return;
    }
    LOGGER.debug("Starting to execute {}", task);
    try {
        executer.execute(task, state, context);
    } finally {
        state.executed();
        LOGGER.debug("Finished executing {}", task);
    }
}
 
Example #19
Source File: SkipUpToDateTaskExecuter.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void execute(TaskInternal task, TaskStateInternal state, TaskExecutionContext context) {
    LOGGER.debug("Determining if {} is up-to-date", task);
    Clock clock = new Clock();
    TaskArtifactState taskArtifactState = repository.getStateFor(task);
    try {
        List<String> messages = new ArrayList<String>();
        if (taskArtifactState.isUpToDate(messages)) {
            LOGGER.info("Skipping {} as it is up-to-date (took {}).", task, clock.getTime());
            state.upToDate();
            return;
        }
        logOutOfDateMessages(messages, task, clock.getTime());

        task.getOutputs().setHistory(taskArtifactState.getExecutionHistory());
        context.setTaskArtifactState(taskArtifactState);

        taskArtifactState.beforeTask();
        try {
            executer.execute(task, state, context);
            if (state.getFailure() == null) {
                taskArtifactState.afterTask();
            }
        } finally {
            task.getOutputs().setHistory(null);
            context.setTaskArtifactState(null);
        }
    } finally {
        taskArtifactState.finished();
    }
}
 
Example #20
Source File: SkipEmptySourceFilesTaskExecuter.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void execute(TaskInternal task, TaskStateInternal state, TaskExecutionContext context) {
    if (task.getInputs().getHasSourceFiles() && task.getInputs().getSourceFiles().isEmpty()) {
        LOGGER.info("Skipping {} as it has no source files.", task);
        state.upToDate();
        return;
    }
    executer.execute(task, state, context);
}
 
Example #21
Source File: SkipEmptySourceFilesTaskExecuter.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void execute(TaskInternal task, TaskStateInternal state, TaskExecutionContext context) {
    if (task.getInputs().getHasSourceFiles() && task.getInputs().getSourceFiles().isEmpty()) {
        LOGGER.info("Skipping {} as it has no source files.", task);
        state.upToDate();
        return;
    }
    executer.execute(task, state, context);
}
 
Example #22
Source File: SkipEmptySourceFilesTaskExecuter.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void execute(TaskInternal task, TaskStateInternal state, TaskExecutionContext context) {
    if (task.getInputs().getHasSourceFiles() && task.getInputs().getSourceFiles().isEmpty()) {
        LOGGER.info("Skipping {} as it has no source files.", task);
        state.upToDate();
        return;
    }
    executer.execute(task, state, context);
}
 
Example #23
Source File: ExecuteAtMostOnceTaskExecuter.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void execute(TaskInternal task, TaskStateInternal state, TaskExecutionContext context) {
    if (state.getExecuted()) {
        return;
    }
    LOGGER.debug("Starting to execute {}", task);
    try {
        executer.execute(task, state, context);
    } finally {
        state.executed();
        LOGGER.debug("Finished executing {}", task);
    }
}
 
Example #24
Source File: SkipUpToDateTaskExecuter.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void execute(TaskInternal task, TaskStateInternal state, TaskExecutionContext context) {
    LOGGER.debug("Determining if {} is up-to-date", task);
    Clock clock = new Clock();
    TaskArtifactState taskArtifactState = repository.getStateFor(task);
    try {
        List<String> messages = new ArrayList<String>();
        if (taskArtifactState.isUpToDate(messages)) {
            LOGGER.info("Skipping {} as it is up-to-date (took {}).", task, clock.getTime());
            state.upToDate();
            return;
        }
        logOutOfDateMessages(messages, task, clock.getTime());

        task.getOutputs().setHistory(taskArtifactState.getExecutionHistory());
        context.setTaskArtifactState(taskArtifactState);

        taskArtifactState.beforeTask();
        try {
            executer.execute(task, state, context);
            if (state.getFailure() == null) {
                taskArtifactState.afterTask();
            }
        } finally {
            task.getOutputs().setHistory(null);
            context.setTaskArtifactState(null);
        }
    } finally {
        taskArtifactState.finished();
    }
}
 
Example #25
Source File: PostExecutionAnalysisTaskExecuter.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void execute(TaskInternal task, TaskStateInternal state, TaskExecutionContext context) {
    executer.execute(task, state, context);
    if (!state.getDidWork()) {
        state.upToDate();
    }
}
 
Example #26
Source File: AnnotationProcessingTaskFactory.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void contextualise(TaskExecutionContext context) {
    this.taskArtifactState = context == null ? null : context.getTaskArtifactState();
}
 
Example #27
Source File: AnnotationProcessingTaskFactory.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void contextualise(TaskExecutionContext context) {
    this.taskArtifactState = context == null ? null : context.getTaskArtifactState();
}
 
Example #28
Source File: PostExecutionAnalysisTaskExecuter.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void execute(TaskInternal task, TaskStateInternal state, TaskExecutionContext context) {
    executer.execute(task, state, context);
    if (!state.getDidWork()) {
        state.upToDate();
    }
}
 
Example #29
Source File: AnnotationProcessingTaskFactory.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void contextualise(TaskExecutionContext context) {
    this.taskArtifactState = context == null ? null : context.getTaskArtifactState();
}
 
Example #30
Source File: SkipExecuter.java    From atlas with Apache License 2.0 4 votes vote down vote up
public void execute(TaskInternal task, TaskStateInternal state, TaskExecutionContext context) {
    LOGGER.info("skip SkipExecuter");
    executer.execute(task, state, context);
}