From 71e9da443730692832805bcbea1c715f0075cca7 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Sat, 20 Feb 2016 02:09:20 +0400 Subject: [PATCH] Fix empty directory FileSpec. --- .../src/main/kotlin/com/beust/kobalt/FileSpec.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/FileSpec.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/FileSpec.kt index c8f507df..1a7619b8 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/FileSpec.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/FileSpec.kt @@ -42,14 +42,16 @@ sealed class IFileSpec { val includes = Glob(*spec.toTypedArray()) if (File(filePath).isDirectory) { - val rootDir = (if (File(filePath).isAbsolute) Paths.get(filePath) + val orgRootDir = (if (File(filePath).isAbsolute) Paths.get(filePath) else if (baseDir != null) Paths.get(baseDir, filePath) else Paths.get(filePath)).run { normalize() } + // Paths.get(".").normalize() returns an empty string, which is not a valid file :-( + val rootDir = if (orgRootDir.toFile().path.isEmpty()) Paths.get("./") else orgRootDir if (rootDir.toFile().exists()) { Files.walkFileTree(rootDir, object : SimpleFileVisitor() { override fun visitFile(p: Path, attrs: BasicFileAttributes): FileVisitResult { val path = p.normalize() - val rel = rootDir.relativize(path) + val rel = orgRootDir.relativize(path) if (isIncluded(includes, excludes, path)) { log(2, " including file " + rel.toFile() + " from rootDir $rootDir") result.add(rel.toFile())