Path (Path baseDir, String relativePath) { if (relativePath.startsWith("$")) { return ResourcePathMacros.resolve(relativePath); } Path root = baseDir; while (relativePath.startsWith("../")) { relativePath = relativePath.substring(3); root = root.getParent(); } if (!relativePath.isEmpty()) { root = root.resolve(relativePath); } return root; }