From b796872cfb0dcf0abff658559a633a2fbb1081c7 Mon Sep 17 00:00:00 2001 From: John Engelman Date: Fri, 13 Jun 2014 16:02:05 -0700 Subject: [PATCH] closes issue 49, calculate file name correctly on windows --- ChangeLog.md | 5 +++++ README.md | 2 +- .../jengelman/gradle/plugins/shadow/tasks/ShadowJar.groovy | 5 +++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 63878bc8e..480459b1f 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,3 +1,8 @@ +v0.9.0-M3 +========= + ++ Use commons.io FilenameUtils to determine name of resolved jars for including/excluding + v0.9.0-M2 ========= diff --git a/README.md b/README.md index fb3eb059a..a343eba78 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ instead of a port of the Maven Shade code. Documentation for version 0.8 and pri buildscript { repositories { jcenter() } dependencies { - classpath 'com.github.jengelman.gradle.plugins:shadow:0.9.0-M2' + classpath 'com.github.jengelman.gradle.plugins:shadow:0.9.0-M3' } } diff --git a/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.groovy b/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.groovy index 5a236ea61..9d80015e6 100644 --- a/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.groovy +++ b/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.groovy @@ -10,6 +10,7 @@ import com.github.jengelman.gradle.plugins.shadow.relocation.SimpleRelocator import com.github.jengelman.gradle.plugins.shadow.transformers.AppendingTransformer import com.github.jengelman.gradle.plugins.shadow.transformers.ServiceFileTransformer import com.github.jengelman.gradle.plugins.shadow.transformers.Transformer +import org.apache.commons.io.FilenameUtils import org.apache.tools.zip.ZipOutputStream import org.gradle.api.artifacts.Dependency import org.gradle.api.artifacts.ResolvedDependency @@ -107,7 +108,7 @@ class ShadowJar extends Jar { Set dependencies = findMatchingDependencies(spec, project.configurations.runtime.resolvedConfiguration.firstLevelModuleDependencies, includeTransitive) dependencies.collect { it.moduleArtifacts.file }.flatten().each { File file -> - this.exclude(file.path.substring(file.path.lastIndexOf('/')+1)) //Get just the file name + this.exclude(FilenameUtils.getName(file.path)) } return this } @@ -123,7 +124,7 @@ class ShadowJar extends Jar { Set dependencies = findMatchingDependencies(spec, project.configurations.runtime.resolvedConfiguration.firstLevelModuleDependencies, includeTransitive) dependencies.collect { it.moduleArtifacts.file }.flatten().each { File file -> - this.include(file.path.substring(file.path.lastIndexOf('/')+1)) + this.include(FilenameUtils.getName(file.path)) } return this }