aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorSimon Ogorodnik <Simon.Ogorodnik@jetbrains.com>2016-11-02 14:19:14 +0300
committerSimon Ogorodnik <Simon.Ogorodnik@jetbrains.com>2016-11-02 14:20:38 +0300
commit0c33c3c53517a33521ba1176a929867f2f60ebec (patch)
treefa9096607e8eed02e44bc05ee2d891cb386e989b /core
parent7922e2a940f91b587c70dfb3d41e0048bc93a19e (diff)
downloaddokka-0c33c3c53517a33521ba1176a929867f2f60ebec.tar.gz
dokka-0c33c3c53517a33521ba1176a929867f2f60ebec.tar.bz2
dokka-0c33c3c53517a33521ba1176a929867f2f60ebec.zip
Fix for GH #99 : Dokka crash on startup if dokka-fatjar located in path with spaces
Diffstat (limited to 'core')
-rw-r--r--core/src/main/kotlin/Utilities/ServiceLocator.kt16
1 files changed, 14 insertions, 2 deletions
diff --git a/core/src/main/kotlin/Utilities/ServiceLocator.kt b/core/src/main/kotlin/Utilities/ServiceLocator.kt
index 6c29d1cd..71bfd21b 100644
--- a/core/src/main/kotlin/Utilities/ServiceLocator.kt
+++ b/core/src/main/kotlin/Utilities/ServiceLocator.kt
@@ -1,6 +1,8 @@
package org.jetbrains.dokka.Utilities
import java.io.File
+import java.net.URISyntaxException
+import java.net.URL
import java.util.*
import java.util.jar.JarFile
import java.util.zip.ZipEntry
@@ -40,14 +42,24 @@ object ServiceLocator {
return ServiceDescriptor(implementationName, category, properties["description"]?.toString(), className)
}
+ fun URL.toFile(): File {
+ assert(protocol == "file")
+
+ return try {
+ File(toURI())
+ } catch (e: URISyntaxException) { //Try to handle broken URLs, with unescaped spaces
+ File(path)
+ }
+ }
+
fun allServices(category: String): List<ServiceDescriptor> {
val entries = this.javaClass.classLoader.getResources("dokka/$category")?.toList() ?: emptyList()
return entries.flatMap {
when (it.protocol) {
- "file" -> File(it.file).listFiles()?.filter { it.extension == "properties" }?.map { lookupDescriptor(category, it.nameWithoutExtension) } ?: emptyList()
+ "file" -> it.toFile().listFiles()?.filter { it.extension == "properties" }?.map { lookupDescriptor(category, it.nameWithoutExtension) } ?: emptyList()
"jar" -> {
- val file = JarFile(it.file.removePrefix("file:").substringBefore("!"))
+ val file = JarFile(URL(it.file.substringBefore("!")).toFile())
try {
val jarPath = it.file.substringAfterLast("!").removePrefix("/")
file.entries()