當前位置: 首頁>>代碼示例>>Java>>正文


Java TaskExecutionContext.getTaskArtifactState方法代碼示例

本文整理匯總了Java中org.gradle.api.internal.tasks.TaskExecutionContext.getTaskArtifactState方法的典型用法代碼示例。如果您正苦於以下問題:Java TaskExecutionContext.getTaskArtifactState方法的具體用法?Java TaskExecutionContext.getTaskArtifactState怎麽用?Java TaskExecutionContext.getTaskArtifactState使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.gradle.api.internal.tasks.TaskExecutionContext的用法示例。


在下文中一共展示了TaskExecutionContext.getTaskArtifactState方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: execute

import org.gradle.api.internal.tasks.TaskExecutionContext; //導入方法依賴的package包/類
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();
    }
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:29,代碼來源:SkipUpToDateTaskExecuter.java

示例2: contextualise

import org.gradle.api.internal.tasks.TaskExecutionContext; //導入方法依賴的package包/類
public void contextualise(TaskExecutionContext context) {
    this.taskArtifactState = context == null ? null : context.getTaskArtifactState();
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:4,代碼來源:DefaultTaskClassInfoStore.java

示例3: execute

import org.gradle.api.internal.tasks.TaskExecutionContext; //導入方法依賴的package包/類
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);
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:43,代碼來源:SkipEmptySourceFilesTaskExecuter.java


注:本文中的org.gradle.api.internal.tasks.TaskExecutionContext.getTaskArtifactState方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。