aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKrystianUjma <kujma@virtuslab.com>2019-05-31 16:59:32 +0200
committerKrystianUjma <kujma@virtuslab.com>2019-05-31 16:59:32 +0200
commitdfe9b83c57f21d8f9f2bda74a02bc042bd329271 (patch)
tree5f80ae1b11e4ab3fce3e4eca030631f8b58bb83d
parent551a5a83e5e88afcfa584d213951c6e42a3b2109 (diff)
downloaddokka-dfe9b83c57f21d8f9f2bda74a02bc042bd329271.tar.gz
dokka-dfe9b83c57f21d8f9f2bda74a02bc042bd329271.tar.bz2
dokka-dfe9b83c57f21d8f9f2bda74a02bc042bd329271.zip
462 - make dokkaRuntime support for multiple dokka tasks
-rw-r--r--runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaTask.kt22
-rw-r--r--runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/main.kt8
2 files changed, 16 insertions, 14 deletions
diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaTask.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaTask.kt
index d4eee4b2..c16c041f 100644
--- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaTask.kt
+++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaTask.kt
@@ -54,6 +54,8 @@ open class DokkaTask : DefaultTask() {
var dokkaRuntime: Configuration? = null
+ var defaultDokkaRuntime: Configuration? = null
+
@InputFiles
var classpath: Iterable<File> = arrayListOf()
@@ -64,7 +66,9 @@ open class DokkaTask : DefaultTask() {
var sourceRoots: MutableList<SourceRoot> = arrayListOf()
@Input
- var dokkaFatJar: Any = "org.jetbrains.dokka:dokka-fatjar:${DokkaVersion.version}"
+ var dokkaFatJar: String = "dokka-fatjar-${DokkaVersion.version}"
+
+ private val defaultDokkaFatJar = "dokka-fatjar-${DokkaVersion.version}"
@Input
var impliedPlatforms: MutableList<String> = arrayListOf()
@@ -93,20 +97,17 @@ open class DokkaTask : DefaultTask() {
}
- fun tryResolveFatJar(project: Project): Set<File> {
+ fun tryResolveFatJar(configuration: Configuration?): Set<File> {
return try {
- dokkaRuntime!!.resolve()
+ configuration!!.resolve()
} catch (e: Exception) {
- project.parent?.let { tryResolveFatJar(it) } ?: throw e
+ project.parent?.let { tryResolveFatJar(configuration) } ?: throw e
}
}
fun loadFatJar() {
if (ClassloaderContainer.fatJarClassLoader == null) {
- val jars = if (dokkaFatJar is File)
- setOf(dokkaFatJar as File)
- else
- tryResolveFatJar(project)
+ val jars = tryResolveFatJar(dokkaRuntime).toList().union(tryResolveFatJar(defaultDokkaRuntime).toList()).filter { it.name.contains(dokkaFatJar) || it.name.contains(defaultDokkaFatJar) }
ClassloaderContainer.fatJarClassLoader = URLClassLoader(jars.map { it.toURI().toURL() }.toTypedArray(), ClassLoader.getSystemClassLoader().parent)
}
}
@@ -172,11 +173,6 @@ open class DokkaTask : DefaultTask() {
@TaskAction
fun generate() {
- if (dokkaRuntime == null){
- dokkaRuntime = project.configurations.getByName("dokkaRuntime")
- }
-
- dokkaRuntime?.defaultDependencies{ dependencies -> dependencies.add(project.dependencies.create(dokkaFatJar)) }
val kotlinColorsEnabledBefore = System.getProperty(COLORS_ENABLED_PROPERTY) ?: "false"
System.setProperty(COLORS_ENABLED_PROPERTY, "false")
try {
diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/main.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/main.kt
index d04ed5f0..fa82d42d 100644
--- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/main.kt
+++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/main.kt
@@ -22,8 +22,14 @@ open class DokkaPlugin : Plugin<Project> {
override fun apply(project: Project) {
DokkaVersion.loadFrom(javaClass.getResourceAsStream("/META-INF/gradle-plugins/org.jetbrains.dokka.properties"))
+ val dokkaRuntimeConfiguration = project.configurations.create("dokkaRuntime")
+ val defaultDokkaRuntimeConfiguration = project.configurations.create("defaultDokkaRuntime")
+
+ defaultDokkaRuntimeConfiguration.defaultDependencies{ dependencies -> dependencies.add(project.dependencies.create("org.jetbrains.dokka:dokka-fatjar:${DokkaVersion.version}")) }
+
project.tasks.create("dokka", DokkaTask::class.java).apply {
- dokkaRuntime = project.configurations.create("dokkaRuntime")
+ dokkaRuntime = dokkaRuntimeConfiguration
+ defaultDokkaRuntime = defaultDokkaRuntimeConfiguration
moduleName = project.name
outputDirectory = File(project.buildDir, "dokka").absolutePath
}