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

项目:Reer    文件:ClientForwardingTaskListener.java   
private static AbstractTaskResult toTaskResult(TaskInternal task, OperationResult result) {
    TaskStateInternal state = task.getState();
    long startTime = result.getStartTime();
    long endTime = result.getEndTime();

    if (state.getUpToDate()) {
        return new DefaultTaskSuccessResult(startTime, endTime, true, state.isFromCache(), state.getSkipMessage());
    } else if (state.getSkipped()) {
        return new DefaultTaskSkippedResult(startTime, endTime, state.getSkipMessage());
    } else {
        Throwable failure = result.getFailure();
        if (failure == null) {
            return new DefaultTaskSuccessResult(startTime, endTime, false, state.isFromCache(), "SUCCESS");
        } else {
            return new DefaultTaskFailureResult(startTime, endTime, Collections.singletonList(DefaultFailure.fromThrowable(failure)));
        }
    }
}
项目: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);
}
项目:Reer    文件:DefaultTaskGraphExecuter.java   
@Override
public void execute(final TaskInternal task) {
    TaskOperationDescriptor taskOperation = new TaskOperationDescriptor(task);
    BuildOperationDetails buildOperationDetails = BuildOperationDetails.displayName("Task " + task.getIdentityPath()).name(task.getIdentityPath().toString()).parent(parentOperation).operationDescriptor(taskOperation).build();
    buildOperationExecutor.run(buildOperationDetails, new Action<BuildOperationContext>() {
        @Override
        public void execute(BuildOperationContext buildOperationContext) {
            // These events are used by build scans
            TaskOperationInternal legacyOperation = new TaskOperationInternal(task, buildOperationExecutor.getCurrentOperation().getId());
            internalTaskListener.beforeExecute(legacyOperation, new OperationStartEvent(0));
            TaskStateInternal state = task.getState();
            taskListeners.getSource().beforeExecute(task);
            taskExecuter.execute(task, state, new DefaultTaskExecutionContext());
            taskListeners.getSource().afterExecute(task, state);
            buildOperationContext.failed(state.getFailure());
            internalTaskListener.afterExecute(legacyOperation, new OperationResult(0, 0, state.getFailure()));
        }
    });
}
项目: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    文件:TaskExecutionStatisticsEventAdapter.java   
@Override
public void afterExecute(Task task, TaskState state) {
    TaskStateInternal stateInternal = (TaskStateInternal) state;
    TaskExecutionOutcome outcome = stateInternal.getOutcome();
    taskCounts.put(outcome, taskCounts.get(outcome) + 1);
    if (stateInternal.isCacheable() && outcome == TaskExecutionOutcome.EXECUTED) {
        cacheMissCount++;
    }
}
项目: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);
}
项目:gradle-circle-style    文件:CircleBuildFailureListenerTests.java   
private static TaskState succeeded() {
    TaskStateInternal state = new TaskStateInternal();
    state.setOutcome(TaskExecutionOutcome.EXECUTED);
    return state;
}
项目:gradle-circle-style    文件:CircleBuildFailureListenerTests.java   
private static TaskState failed(String message) {
    TaskStateInternal state = new TaskStateInternal();
    state.setOutcome(TaskExecutionOutcome.EXECUTED);
    state.setOutcome(new RuntimeException(message));
    return state;
}
项目: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 TaskStateInternal getState() {
    return state;
}
项目: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    文件:PostExecutionAnalysisTaskExecuter.java   
public void execute(TaskInternal task, TaskStateInternal state, TaskExecutionContext context) {
    executer.execute(task, state, context);
    if (!state.getDidWork()) {
        state.upToDate();
    }
}
项目:Reer    文件:TaskInternal.java   
TaskStateInternal getState();
项目:Pushjet-Android    文件:TaskInternal.java   
TaskStateInternal getState();
项目:Pushjet-Android    文件:TaskInternal.java   
TaskStateInternal getStateInternal();