use of org.gradle.api.file.RelativePath in project gradle by gradle.
the class RelativePathTest method appendPath.
@Test
public void appendPath() {
RelativePath childPath = new RelativePath(false, "one", "two").append(new RelativePath(true, "three", "four"));
assertPathContains(childPath, true, "one", "two", "three", "four");
childPath = new RelativePath(false, "one", "two").append(new RelativePath(true));
assertPathContains(childPath, true, "one", "two");
childPath = new RelativePath(false, "one", "two").plus(new RelativePath(true, "three"));
assertPathContains(childPath, true, "one", "two", "three");
}
use of org.gradle.api.file.RelativePath in project gradle by gradle.
the class RelativePathTest method prependNames.
@Test
public void prependNames() {
RelativePath childPath = new RelativePath(false, "one", "two").prepend("three", "four");
assertPathContains(childPath, false, "three", "four", "one", "two");
childPath = new RelativePath(false, "one", "two").prepend();
assertPathContains(childPath, false, "one", "two");
}
use of org.gradle.api.file.RelativePath in project gradle by gradle.
the class AbstractDirectoryWalker method walkDir.
@Override
public void walkDir(File file, RelativePath path, FileVisitor visitor, Spec<? super FileTreeElement> spec, AtomicBoolean stopFlag, boolean postfix) {
File[] children = getChildren(file);
if (children == null) {
if (file.isDirectory() && !file.canRead()) {
throw new GradleException(String.format("Could not list contents of directory '%s' as it is not readable.", file));
}
// else, might be a link which points to nothing, or has been removed while we're visiting, or ...
throw new GradleException(String.format("Could not list contents of '%s'.", file));
}
List<FileVisitDetails> dirs = new ArrayList<FileVisitDetails>();
for (int i = 0; !stopFlag.get() && i < children.length; i++) {
File child = children[i];
boolean isFile = child.isFile();
RelativePath childPath = path.append(isFile, child.getName());
FileVisitDetails details = new DefaultFileVisitDetails(child, childPath, stopFlag, fileSystem, fileSystem, !isFile);
if (DirectoryFileTree.isAllowed(details, spec)) {
if (isFile) {
visitor.visitFile(details);
} else {
dirs.add(details);
}
}
}
// now handle dirs
for (int i = 0; !stopFlag.get() && i < dirs.size(); i++) {
FileVisitDetails dir = dirs.get(i);
if (postfix) {
walkDir(dir.getFile(), dir.getRelativePath(), visitor, spec, stopFlag, postfix);
visitor.visitDir(dir);
} else {
visitor.visitDir(dir);
walkDir(dir.getFile(), dir.getRelativePath(), visitor, spec, stopFlag, postfix);
}
}
}
use of org.gradle.api.file.RelativePath in project zaproxy by zaproxy.
the class JFlexGenerator method generate.
private void generate(FileVisitDetails source, File baseOutputDir) {
if (source.isDirectory()) {
return;
}
RelativePath relPath = source.getRelativePath();
List<String> args = new ArrayList<>();
args.add("--encoding");
args.add("UTF-8");
args.add("--nobak");
args.add("--quiet");
args.add("-d");
args.add(getOutputDir(baseOutputDir, relPath));
args.add(source.getFile().getAbsolutePath());
ExecResult result = getProject().javaexec(spec -> {
spec.getMainClass().set("jflex.Main");
spec.setClasspath(classpath).args(args).setStandardOutput(System.out).setErrorOutput(System.err).setWorkingDir(getWorkingDir(source.getFile(), relPath));
});
result.assertNormalExitValue();
}
use of org.gradle.api.file.RelativePath in project gradle by gradle.
the class RenamingCopyAction method execute.
@Override
public void execute(FileCopyDetails fileCopyDetails) {
RelativePath path = fileCopyDetails.getRelativePath();
String newName = transformer.transform(path.getLastName());
if (newName != null) {
path = path.replaceLastName(newName);
fileCopyDetails.setRelativePath(path);
}
}
Aggregations