in plugins/sandbox/src/main/java/co/elastic/gradle/sandbox/SandboxExecBaseTask.java [276:300]
private void linkPath(Path source) {
if (!Files.exists(source)) {
throw new IllegalArgumentException("No such file:" + source);
}
try {
// We can have inputs from other projects, so we construct paths relative to the root project
Path relativeDestination = rootProjectPath.relativize(source);
Path destination = sandbox.resolve(relativeDestination);
if (Files.isDirectory(source)) {
Files.createDirectories(destination);
} else {
if (Files.isSymbolicLink(source)) {
// A relative symbolic link needs to be kept as it can be relied on for behavior,
// e.g. `require` in some versions of node seems to care.
// since we keep the directory structure these should continue to work
Files.createDirectories(destination.getParent());
Files.copy(source, destination, LinkOption.NOFOLLOW_LINKS, StandardCopyOption.REPLACE_EXISTING);
} else {
createHardlink(source, destination);
}
}
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}