Java 类org.gradle.api.internal.tasks.TaskExecutionContext 实例源码

项目:Reer    文件:ExecuteActionsTaskExecuter.java   
public void execute(TaskInternal task, TaskStateInternal state, TaskExecutionContext context) {
    listener.beforeActions(task);
    if (!task.getTaskActions().isEmpty()) {
        outputsGenerationListener.beforeTaskOutputsGenerated();
    }
    state.setExecuting(true);
    try {
        GradleException failure = executeActions(task, state, context);
        if (failure != null) {
            state.setOutcome(failure);
        } else {
            state.setOutcome(
                state.getDidWork() ? TaskExecutionOutcome.EXECUTED : TaskExecutionOutcome.UP_TO_DATE
            );
        }
    } finally {
        state.setExecuting(false);
        listener.afterActions(task);
    }
}
项目:Reer    文件:SkipOnlyIfTaskExecuter.java   
public void execute(TaskInternal task, TaskStateInternal state, TaskExecutionContext context) {
    boolean skip;
    try {
        skip = !task.getOnlyIf().isSatisfiedBy(task);
    } catch (Throwable t) {
        state.setOutcome(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.setOutcome(TaskExecutionOutcome.SKIPPED);
        return;
    }

    executer.execute(task, state, context);
}
项目:Reer    文件:ValidatingTaskExecuter.java   
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.setOutcome(new TaskValidationException(errorMessage, causes));
        return;
    }
    executer.execute(task, state, context);
}
项目:Pushjet-Android    文件:SkipOnlyIfTaskExecuter.java   
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);
}
项目:Pushjet-Android    文件:ValidatingTaskExecuter.java   
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);
}
项目:Pushjet-Android    文件:SkipTaskWithNoActionsExecuter.java   
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);
}
项目:Pushjet-Android    文件:SkipOnlyIfTaskExecuter.java   
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);
}
项目:Pushjet-Android    文件:ValidatingTaskExecuter.java   
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);
}
项目:Pushjet-Android    文件:SkipTaskWithNoActionsExecuter.java   
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);
}
项目:Reer    文件:ExecuteActionsTaskExecuter.java   
private void executeAction(TaskInternal task, ContextAwareTaskAction action, TaskExecutionContext context) {
    action.contextualise(context);
    try {
        action.execute(task);
    } finally {
        action.contextualise(null);
    }
}
项目:Reer    文件:VerifyNoInputChangesTaskExecuter.java   
@Override
public void execute(TaskInternal task, TaskStateInternal state, TaskExecutionContext context) {
    BuildCacheKey beforeExecution = context.getTaskArtifactState().calculateCacheKey();
    delegate.execute(task, state, context);
    if (beforeExecution != null) {
        BuildCacheKey afterExecution = repository.getStateFor(task).calculateCacheKey();
        if (afterExecution == null || !beforeExecution.getHashCode().equals(afterExecution.getHashCode())) {
            throw new TaskExecutionException(task, new GradleException("The inputs for the task changed during the execution! Check if you have a `doFirst` changing the inputs."));
        }
    }
}
项目:Reer    文件:CatchExceptionTaskExecuter.java   
@Override
public void execute(TaskInternal task, TaskStateInternal state, TaskExecutionContext context) {
    try {
        delegate.execute(task, state, context);
    } catch (RuntimeException e) {
        state.setOutcome(e);
    }
}
项目:Reer    文件:SkipUpToDateTaskExecuter.java   
public void execute(TaskInternal task, TaskStateInternal state, TaskExecutionContext context) {
    LOGGER.debug("Determining if {} is up-to-date", task);
    Timer clock = Timers.startTimer();
    TaskArtifactState taskArtifactState = context.getTaskArtifactState();
    try {
        List<String> messages = LOGGER.isInfoEnabled() ? new ArrayList<String>() : null;
        if (taskArtifactState.isUpToDate(messages)) {
            LOGGER.info("Skipping {} as it is up-to-date (took {}).", task, clock.getElapsed());
            state.setOutcome(TaskExecutionOutcome.UP_TO_DATE);
            return;
        }
        logOutOfDateMessages(messages, task, clock.getElapsed());

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

        taskArtifactState.beforeTask();
        try {
            executer.execute(task, state, context);
            if (state.getFailure() == null) {
                taskArtifactState.afterTask();
            }
        } finally {
            task.getOutputs().setHistory(null);
        }
    } finally {
        taskArtifactState.finished();
    }
}
项目:Reer    文件:ExecuteAtMostOnceTaskExecuter.java   
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 {
        LOGGER.debug("Finished executing {}", task);
    }
}
项目:Reer    文件:ResolveTaskArtifactStateTaskExecuter.java   
@Override
public void execute(TaskInternal task, TaskStateInternal state, TaskExecutionContext context) {
    Timer clock = Timers.startTimer();
    context.setTaskArtifactState(repository.getStateFor(task));
    LOGGER.info("Putting task artifact state for {} into context took {}.", task, clock.getElapsed());
    try {
        executer.execute(task, state, context);
    } finally {
        context.setTaskArtifactState(null);
        LOGGER.debug("Removed task artifact state for {} from context.");
    }
}
项目:Reer    文件:SkipTaskWithNoActionsExecuter.java   
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;
            }
        }
        state.setOutcome(upToDate ? TaskExecutionOutcome.UP_TO_DATE : TaskExecutionOutcome.EXECUTED);
        return;
    }
    executer.execute(task, state, context);
}
项目:Pushjet-Android    文件:SkipUpToDateTaskExecuter.java   
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();
    }
}
项目:Pushjet-Android    文件:ExecuteAtMostOnceTaskExecuter.java   
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);
    }
}
项目:Pushjet-Android    文件:SkipEmptySourceFilesTaskExecuter.java   
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);
}
项目:Pushjet-Android    文件:SkipUpToDateTaskExecuter.java   
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();
    }
}
项目:Pushjet-Android    文件:ExecuteAtMostOnceTaskExecuter.java   
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);
    }
}
项目:Pushjet-Android    文件:SkipEmptySourceFilesTaskExecuter.java   
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);
}
项目:Reer    文件:DefaultTaskClassInfoStore.java   
public void contextualise(TaskExecutionContext context) {
    this.taskArtifactState = context == null ? null : context.getTaskArtifactState();
}
项目:Reer    文件:SkipEmptySourceFilesTaskExecuter.java   
public void execute(TaskInternal task, TaskStateInternal state, TaskExecutionContext context) {
    FileCollection sourceFiles = task.getInputs().getSourceFiles();
    if (task.getInputs().getHasSourceFiles() && sourceFiles.isEmpty()) {
        TaskArtifactState taskArtifactState = context.getTaskArtifactState();
        FileCollection outputFiles = taskArtifactState.getExecutionHistory().getOutputFiles();
        if (outputFiles == null) {
            state.setOutcome(TaskExecutionOutcome.UP_TO_DATE);
            LOGGER.info("Skipping {} as it has no source files and no history of previous output files.", task);
        } else if (outputFiles.isEmpty()) {
            state.setOutcome(TaskExecutionOutcome.UP_TO_DATE);
            LOGGER.info("Skipping {} as it has no source files and no previous output files.", task);
        } else {
            Set<File> outputFileSet = outputFiles.getFiles();
            boolean deletedFiles = false;
            boolean debugEnabled = LOGGER.isDebugEnabled();
            for (File file : outputFileSet) {
                if (file.isFile()) {
                    if (file.delete()) {
                        if (debugEnabled) {
                            LOGGER.debug("Deleted stale output file '{}'.", file.getAbsolutePath());
                        }
                    } else {
                        state.setOutcome(new GradleException(String.format("Could not delete file: '%s'.", file.getAbsolutePath())));
                        return;
                    }
                    deletedFiles = true;
                }
            }
            if (deletedFiles) {
                LOGGER.info("Cleaned previous output of {} as it has no source files.", task);
                state.setOutcome(TaskExecutionOutcome.EXECUTED);
            } else {
                state.setOutcome(TaskExecutionOutcome.UP_TO_DATE);
            }
        }
        taskInputsListener.onExecute(task, Cast.cast(FileCollectionInternal.class, sourceFiles));
        return;
    } else {
        taskInputsListener.onExecute(task, Cast.cast(FileCollectionInternal.class, task.getInputs().getFiles()));
    }
    executer.execute(task, state, context);
}
项目:Reer    文件:AbstractTask.java   
public void contextualise(TaskExecutionContext context) {
}
项目:Reer    文件:AbstractTask.java   
public void contextualise(TaskExecutionContext context) {
    if (action instanceof ContextAwareTaskAction) {
        ((ContextAwareTaskAction) action).contextualise(context);
    }
}
项目:Pushjet-Android    文件:AnnotationProcessingTaskFactory.java   
public void contextualise(TaskExecutionContext context) {
    this.taskArtifactState = context == null ? null : context.getTaskArtifactState();
}
项目:Pushjet-Android    文件:PostExecutionAnalysisTaskExecuter.java   
public void execute(TaskInternal task, TaskStateInternal state, TaskExecutionContext context) {
    executer.execute(task, state, context);
    if (!state.getDidWork()) {
        state.upToDate();
    }
}
项目:Pushjet-Android    文件:AnnotationProcessingTaskFactory.java   
public void contextualise(TaskExecutionContext context) {
    this.taskArtifactState = context == null ? null : context.getTaskArtifactState();
}
项目:Pushjet-Android    文件:PostExecutionAnalysisTaskExecuter.java   
public void execute(TaskInternal task, TaskStateInternal state, TaskExecutionContext context) {
    executer.execute(task, state, context);
    if (!state.getDidWork()) {
        state.upToDate();
    }
}
项目:CodeColors    文件:IgnoreResFilesTaskActionWrapper.java   
@Override
public void contextualise(TaskExecutionContext taskExecutionContext) {
    mTask.contextualise(
            taskExecutionContext != null ?
                    new IgnoreResFilesTaskExecutionContextWrapper(taskExecutionContext, mResFiles) : null);
}
项目:CodeColors    文件:IgnoreResFilesTaskActionWrapper.java   
public IgnoreResFilesTaskExecutionContextWrapper(TaskExecutionContext taskExecutionContext,
                                                 Set<File> resFiles) {
    mResFiles = resFiles;
    setTaskArtifactState(taskExecutionContext.getTaskArtifactState());
}