From 6513045039caf4c43a7d037f0b0f275e91552fd6 Mon Sep 17 00:00:00 2001 From: John Engelman Date: Fri, 27 Jun 2014 16:11:18 -0500 Subject: [PATCH] do not include a / directory in the jar --- ChangeLog.md | 1 + .../gradle/plugins/shadow/tasks/ShadowCopyAction.groovy | 4 +--- .../jengelman/gradle/plugins/shadow/ShadowPluginSpec.groovy | 3 +++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index cbe9aed93..05d081049 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -2,6 +2,7 @@ v1.0.1 ====== + Fix issue where non-class files are dropped when using relocation ([Issue #58](https://github.com/johnrengelman/shadow/issues/58)) ++ Do not create a / directory inside the output jar. v1.0.0 ====== diff --git a/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowCopyAction.groovy b/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowCopyAction.groovy index 4473710c0..ddf615afc 100644 --- a/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowCopyAction.groovy +++ b/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowCopyAction.groovy @@ -323,10 +323,8 @@ public class ShadowCopyAction implements CopyAction { } RelativeArchivePath getParent() { - if (!segments) { + if (!segments || segments.length == 1) { return null - } else if (segments.length == 1) { - return new RelativeArchivePath(new ZipEntry('/'), null) } else { //Parent is always a directory so add / to the end of the path String path = segments[0..-2].join('/') + '/' diff --git a/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/ShadowPluginSpec.groovy b/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/ShadowPluginSpec.groovy index 40215e3a4..9c89598e6 100644 --- a/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/ShadowPluginSpec.groovy +++ b/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/ShadowPluginSpec.groovy @@ -138,6 +138,9 @@ class ShadowPluginSpec extends PluginSpecification { and: contains(output, ['shadow/Passed.class', 'junit/framework/Test.class']) + + and: + doesNotContain(output, ['/']) } def 'include project dependencies'() {