diff --git a/README.md b/README.md index b5cd13f..6a4a583 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ build.gradle snippet to use ManifestClasspath plugin ##### Build script snippet for plugins DSL for Gradle 2.1 and later ``` plugins { - id "com.github.ManifestClasspath" version "0.1.0-RELEASE" + id "com.github.ManifestClasspath" version "0.2.0-RELEASE" } ``` ##### Build script snippet for use in older Gradle versions or where dynamic configuration is required @@ -26,7 +26,7 @@ buildscript { } } dependencies { - classpath "gradle.plugin.com.github.viswaramamoorthy:gradle-util-plugins:0.1.0-RELEASE" + classpath "gradle.plugin.com.github.viswaramamoorthy:gradle-util-plugins:0.2.0-RELEASE" } } diff --git a/build.gradle b/build.gradle index 514bc32..163e435 100644 --- a/build.gradle +++ b/build.gradle @@ -20,7 +20,7 @@ apply plugin: 'io.codearte.nexus-staging' apply plugin: 'com.gradle.plugin-publish' group = 'com.github.viswaramamoorthy' -version = '0.1.0-RELEASE' +version = '0.2.0-RELEASE' sourceCompatibility = 1.8 diff --git a/src/main/groovy/vr/util/ManifestUtil.groovy b/src/main/groovy/vr/util/ManifestUtil.groovy index 5923c0c..634e6f9 100644 --- a/src/main/groovy/vr/util/ManifestUtil.groovy +++ b/src/main/groovy/vr/util/ManifestUtil.groovy @@ -34,11 +34,23 @@ class ManifestUtil if (!fileCollection) return def classPathString = fileCollection.files.collect { - it.toURL().toString() + toClassPathEntry(it) }.join(' ') createManifestJar(jarFile, manifestWithClasspath(classPathString)) } + /** + * Convert a file to its URL, with any spaces in the path replaced by {@ %20} so that directories + * containing spaces in their names in the classpath will be properly processed when running. + * + * @param element file to convert to string for inclusion in classpath + * @return classpath string referencing given file, as described + */ + private static String toClassPathEntry(File element) { + String path = element.toURL().toString() + return path.replaceAll(' ', '%20') + } + private static def createManifestJar(def jarFile, def manifest = null) throws IOException { def jarOutputStream