1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-26 08:27:12 -07:00

Fix inclusion bug.

This commit is contained in:
Cedric Beust 2016-02-19 02:01:40 +04:00
parent a574bc1adf
commit 2f386a622d
6 changed files with 44 additions and 17 deletions

View file

@ -42,9 +42,13 @@ sealed class IFileSpec {
val includes = Glob(*spec.toTypedArray())
if (File(filePath).isDirectory) {
Files.walkFileTree(Paths.get(filePath), object : SimpleFileVisitor<Path>() {
override public fun visitFile(path: Path, attrs: BasicFileAttributes): FileVisitResult {
val rel = Paths.get(filePath).relativize(path)
val rootDir = if (File(filePath).isAbsolute) Paths.get(filePath)
else if (baseDir != null) Paths.get(baseDir, filePath)
else Paths.get(filePath)
Files.walkFileTree(rootDir, object : SimpleFileVisitor<Path>() {
override fun visitFile(path: Path, attrs: BasicFileAttributes): FileVisitResult {
val rel = if (baseDir != null && !baseDir.isEmpty()) Paths.get(baseDir).relativize(path)
else path
if (isIncluded(includes, excludes, path)) {
result.add(rel.toFile())
}

View file

@ -4,6 +4,7 @@ import com.beust.kobalt.Glob
import com.beust.kobalt.IFileSpec
import com.google.common.io.CharStreams
import java.io.*
import java.nio.file.Paths
import java.util.jar.JarEntry
import java.util.jar.JarFile
import java.util.jar.JarInputStream
@ -39,7 +40,7 @@ public class JarUtils {
// Turn the found file into the local physical file that will be put in the jar file
val localFile = if (File(foundFile.path).isAbsolute) File(foundFile.path)
else file.from(foundFile.path)
else File(directory, file.from(foundFile.path).path)
if (!localFile.exists()) {
throw AssertionError("File should exist: $localFile")
@ -174,7 +175,7 @@ class IncludedFile(val fromOriginal: From, val toOriginal: To, val specs: List<I
result.add(if (source.isAbsolute) source else File(source.path))
}
}
return result
return result.map { Paths.get(it.path).normalize().toFile()}
}
}