use of org.gradle.api.file.FileTree in project gradle by gradle.
the class IncrementalCompilationInitializer method deleteStaleFilesIn.
private void deleteStaleFilesIn(PatternSet classesToDelete, File destinationDir) {
if (destinationDir == null) {
return;
}
FileTree deleteMe = fileOperations.fileTree(destinationDir).matching(classesToDelete);
fileOperations.delete(deleteMe);
}
use of org.gradle.api.file.FileTree in project gradle by gradle.
the class JdkCacheDirectory method unpack.
private File unpack(File jdkArchive) {
final FileTree fileTree = asFileTree(jdkArchive);
final String rootName = getRootDirectory(fileTree);
String installRootName = getNameWithoutExtension(jdkArchive);
final File installLocation = new File(jdkDirectory, installRootName);
if (!installLocation.exists()) {
operations.copy(spec -> {
spec.from(fileTree);
spec.into(jdkDirectory);
spec.exclude(FileTreeElement::isDirectory);
spec.eachFile(fileCopyDetails -> {
String path = fileCopyDetails.getPath();
if (path.startsWith(rootName)) {
// root names can be weird, regexp based replacement won't work
String newPath = installRootName + path.substring(rootName.length());
fileCopyDetails.setPath(newPath);
}
});
});
LOGGER.info("Installed {} into {}", jdkArchive.getName(), installLocation);
}
return installLocation;
}
use of org.gradle.api.file.FileTree in project gradle by gradle.
the class TemplateFactory method whenNoSourcesAvailable.
public TemplateOperation whenNoSourcesAvailable(String subproject, List<TemplateOperation> operations) {
return new ConditionalTemplateOperation(() -> {
FileTree mainFiles = initSettings.getTarget().dir(subproject + "/src/main/" + language.getName()).getAsFileTree();
FileTree testFiles = initSettings.getTarget().dir(subproject + "/src/test/" + language.getName()).getAsFileTree();
return mainFiles.isEmpty() || testFiles.isEmpty();
}, operations);
}
use of org.gradle.api.file.FileTree in project rest.li by linkedin.
the class PublishRestModelTask method copy.
@Override
public void copy() {
if (getSource().isEmpty()) {
getProject().getLogger().error("No interface file is found. Skip publishing interface.");
return;
}
getProject().getLogger().lifecycle("Publishing rest model to API project ...");
FileTree apiRestModelFiles = getSuffixedFiles(getProject(), getDestinationDir(), _suffix);
int apiRestModelFileCount = apiRestModelFiles.getFiles().size();
super.copy();
// FileTree is lazily evaluated, so that it scans for files only when the contents of the file tree are queried
if (apiRestModelFileCount != 0 && apiRestModelFileCount != apiRestModelFiles.getFiles().size()) {
getProject().getLogger().warn("{} files count changed after publish. You may have duplicate files with different names.", _suffix);
}
}
Aggregations