From ea9f3dfdc4cd195c48b5546f33ba2ef49ccaeb99 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Sun, 14 Feb 2016 13:38:02 -0800 Subject: [PATCH] Handle resources in the packaging task. --- .../src/main/kotlin/com/beust/kobalt/misc/JarUtils.kt | 2 +- .../kotlin/com/beust/kobalt/plugin/packaging/JarGenerator.kt | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) 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 637c9cba..3c9dd6b4 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 @@ -59,7 +59,7 @@ public class JarUtils { val includedFile = IncludedFile(From(source.path), To(""), listOf(IFileSpec.GlobSpec("**"))) addSingleFile(".", includedFile, outputStream, expandJarFiles) } else { - if (expandJarFiles and source.name.endsWith(".jar")) { + if (expandJarFiles && source.name.endsWith(".jar") && ! source.path.contains("resources")) { log(2, "Writing contents of jar file $source") val stream = JarInputStream(FileInputStream(source)) var entry = stream.nextEntry diff --git a/src/main/kotlin/com/beust/kobalt/plugin/packaging/JarGenerator.kt b/src/main/kotlin/com/beust/kobalt/plugin/packaging/JarGenerator.kt index 0af5bc47..51d44271 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/packaging/JarGenerator.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/packaging/JarGenerator.kt @@ -39,6 +39,11 @@ class JarGenerator @Inject constructor(val dependencyManager: DependencyManager) fileSpecs.add(IFileSpec.FileSpec(it.path.toString().substring(prefixPath.toString().length + 1))) } result.add(IncludedFile(From(prefixPath.toString() + "/"), To(""), fileSpecs)) + + // Resources, if applicable + project.sourceDirectories.filter { it.contains("resources") }.forEach { + result.add(IncludedFile(From(it), To(""), listOf(IFileSpec.GlobSpec("**")))) + } } else { // // The user specified an include, just use it verbatim