示例#1
0
  public TaskUpToDateState(
      TaskInternal task,
      TaskHistoryRepository.History history,
      FileCollectionSnapshotter outputFilesSnapshotter,
      FileCollectionSnapshotter inputFilesSnapshotter,
      FileCollectionSnapshotter discoveredFilesSnapshotter) {
    TaskExecution thisExecution = history.getCurrentExecution();
    TaskExecution lastExecution = history.getPreviousExecution();

    noHistoryState = NoHistoryStateChangeRule.create(task, lastExecution);
    taskTypeState = TaskTypeStateChangeRule.create(task, lastExecution, thisExecution);
    inputPropertiesState =
        InputPropertiesStateChangeRule.create(task, lastExecution, thisExecution);

    // Capture outputs state
    try {
      outputFilesState =
          caching(
              OutputFilesStateChangeRule.create(
                  task, lastExecution, thisExecution, outputFilesSnapshotter));
    } catch (UncheckedIOException e) {
      throw new UncheckedIOException(
          String.format(
              "Failed to capture snapshot of output files for task '%s' during up-to-date check.",
              task.getName()),
          e);
    }

    // Capture inputs state
    try {
      FileCollectionSnapshot inputFilesSnapshot =
          inputFilesSnapshotter.snapshot(task.getInputs().getFiles());
      this.inputFilesSnapshot = inputFilesSnapshot.getSnapshot();
      inputFilesState =
          caching(
              InputFilesStateChangeRule.create(lastExecution, thisExecution, inputFilesSnapshot));
    } catch (UncheckedIOException e) {
      throw new UncheckedIOException(
          String.format(
              "Failed to capture snapshot of input files for task '%s' during up-to-date check.",
              task.getName()),
          e);
    }

    // Capture discovered inputs state from previous execution
    try {
      discoveredInputFilesState =
          DiscoveredInputFilesStateChangeRule.create(
              lastExecution, thisExecution, discoveredFilesSnapshotter);
    } catch (UncheckedIOException e) {
      throw new UncheckedIOException(
          String.format(
              "Failed to capture snapshot of input files for task '%s' during up-to-date check.",
              task.getName()),
          e);
    }

    allTaskChanges =
        new SummaryTaskStateChanges(
            MAX_OUT_OF_DATE_MESSAGES,
            noHistoryState,
            taskTypeState,
            inputPropertiesState,
            outputFilesState,
            inputFilesState,
            caching(discoveredInputFilesState));
    rebuildChanges =
        new SummaryTaskStateChanges(
            1, noHistoryState, taskTypeState, inputPropertiesState, outputFilesState);
  }
 public FilesSnapshotSet getSnapshot() {
   return filesSnapshot.getSnapshot();
 }