From cbbe9cbeb72f3e129b21209bdef9288a8b423b21 Mon Sep 17 00:00:00 2001 From: DevCharly Date: Tue, 7 Jun 2016 16:58:18 +0200 Subject: [PATCH] fixed fatJar for projects in subdirectories that depend on other projects E.g. building p2 (see below) failed with `java.lang.AssertionError: File should exist: p2\p1\kobaltBuild\classes` because `p2.directory is != "."` ``` val p1 = project { name = "p1" directory = name } val p2 = project(p1) { name = "p2" directory = name assemble { jar { fatJar = true } } } ``` --- .../src/main/kotlin/com/beust/kobalt/JarGenerator.kt | 2 +- .../src/main/kotlin/com/beust/kobalt/misc/JarUtils.kt | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/JarGenerator.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/JarGenerator.kt index 39c4c2e1..59f51deb 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/JarGenerator.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/JarGenerator.kt @@ -107,7 +107,7 @@ class JarGenerator @Inject constructor(val dependencyManager: DependencyManager) if (! seen.contains(file.path)) { seen.add(file.path) if (! KFiles.Companion.isExcluded(file, jar.excludes)) { - result.add(IncludedFile(specs = arrayListOf(IFileSpec.FileSpec(file.path)), + result.add(IncludedFile(specs = arrayListOf(IFileSpec.FileSpec(file.absolutePath)), expandJarFiles = true)) } } diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/JarUtils.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/JarUtils.kt index dfd8cc70..fedac00f 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/JarUtils.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/JarUtils.kt @@ -47,12 +47,12 @@ public class JarUtils { throw AssertionError("File should exist: $localFile") } - if (foundFile.isDirectory) { + if (localFile.isDirectory) { log(2, "Writing contents of directory $foundFile") // Directory - val includedFile = IncludedFile(From(foundFile.path), To(""), listOf(IFileSpec.GlobSpec("**"))) - addSingleFile(".", includedFile, outputStream, expandJarFiles) + val includedFile = IncludedFile(From(""), To(""), listOf(IFileSpec.GlobSpec("**"))) + addSingleFile(localFile.path, includedFile, outputStream, expandJarFiles) } else { if (file.expandJarFiles && foundFile.name.endsWith(".jar") && ! file.from.contains("resources")) { log(2, "Writing contents of jar file $foundFile")