aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin
diff options
context:
space:
mode:
authorPaweł Marks <pmarks@virtuslab.com>2019-11-15 10:23:35 +0100
committerBłażej Kardyś <bkardys@virtuslab.com>2019-11-25 16:24:16 +0100
commit007aacb9ae3b228d0cef45ff5beb066b1dcd4cdc (patch)
treefa0477b575f9e10605c1b7f9a7d6aa2882c23a84 /core/src/main/kotlin
parente7c23a65606a5a844d1664552c935590a06bf58d (diff)
downloaddokka-007aacb9ae3b228d0cef45ff5beb066b1dcd4cdc.tar.gz
dokka-007aacb9ae3b228d0cef45ff5beb066b1dcd4cdc.tar.bz2
dokka-007aacb9ae3b228d0cef45ff5beb066b1dcd4cdc.zip
Adds simplest classpath checking for plugins
Diffstat (limited to 'core/src/main/kotlin')
-rw-r--r--core/src/main/kotlin/plugability/DokkaContext.kt13
1 files changed, 11 insertions, 2 deletions
diff --git a/core/src/main/kotlin/plugability/DokkaContext.kt b/core/src/main/kotlin/plugability/DokkaContext.kt
index 7da4d9a7..b54d8ed0 100644
--- a/core/src/main/kotlin/plugability/DokkaContext.kt
+++ b/core/src/main/kotlin/plugability/DokkaContext.kt
@@ -20,8 +20,17 @@ class DokkaContext private constructor() {
fun from(pluginsClasspath: Iterable<File>) = DokkaContext().apply {
pluginsClasspath.map { it.relativeTo(File(".").absoluteFile).toURI().toURL() }
.toTypedArray()
- .let { ServiceLoader.load(DokkaPlugin::class.java, URLClassLoader(it, this.javaClass.classLoader)) }
+ .let { URLClassLoader(it, this.javaClass.classLoader) }
+ .also { checkClasspath(it) }
+ .let { ServiceLoader.load(DokkaPlugin::class.java, it) }
.forEach { install(it) }
}
}
-} \ No newline at end of file
+
+ private fun checkClasspath(classLoader: URLClassLoader) {
+ classLoader.findResource(javaClass.name.replace('.','/') + ".class")?.also {
+ throw AssertionError("Dokka API found on plugins classpath. This will lead to subtle bugs. " +
+ "Please fix your plugins dependencies or exclude dokka api artifact from plugin classpath")
+ }
+ }
+}