本文整理汇总了Java中org.gradle.api.file.FileCollection.getFiles方法的典型用法代码示例。如果您正苦于以下问题:Java FileCollection.getFiles方法的具体用法?Java FileCollection.getFiles怎么用?Java FileCollection.getFiles使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.gradle.api.file.FileCollection
的用法示例。
在下文中一共展示了FileCollection.getFiles方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFiles
import org.gradle.api.file.FileCollection; //导入方法依赖的package包/类
public Set<File> getFiles() {
// Gather each of the backing Sets first, so we can set the initial capacity of the LinkedHashSet
List<Set<File>> fileSets = new LinkedList<Set<File>>();
int fileCount = 0;
for (FileCollection collection : getSourceCollections()) {
Set<File> files = collection.getFiles();
fileCount += files.size();
fileSets.add(files);
}
Set<File> allFiles = new LinkedHashSet<File>(fileCount);
for (Set<File> fileSet : fileSets) {
allFiles.addAll(fileSet);
}
return allFiles;
}
示例2: prepareValue
import org.gradle.api.file.FileCollection; //导入方法依赖的package包/类
private Object prepareValue(Object value) {
while (true) {
if (value instanceof Callable) {
Callable callable = (Callable) value;
value = uncheckedCall(callable);
} else if (value instanceof FileCollection) {
FileCollection fileCollection = (FileCollection) value;
return fileCollection.getFiles();
} else {
return avoidGString(value);
}
}
}
示例3: execute
import org.gradle.api.file.FileCollection; //导入方法依赖的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);
}