aboutsummaryrefslogtreecommitdiff
path: root/runners/gradle-plugin/src/main
diff options
context:
space:
mode:
authorKrystianUjma <kujma@virtuslab.com>2019-05-31 17:04:45 +0200
committerKrystianUjma <kujma@virtuslab.com>2019-05-31 17:04:45 +0200
commit8b5329a48aa84de32c76e39f62fd3edbd36051ec (patch)
tree4a9eb44cfdec575e044f6d7e7ba29584480a40d4 /runners/gradle-plugin/src/main
parent24d590574bb19a8063b1afefd0243353c34644fa (diff)
parentdfe9b83c57f21d8f9f2bda74a02bc042bd329271 (diff)
downloaddokka-8b5329a48aa84de32c76e39f62fd3edbd36051ec.tar.gz
dokka-8b5329a48aa84de32c76e39f62fd3edbd36051ec.tar.bz2
dokka-8b5329a48aa84de32c76e39f62fd3edbd36051ec.zip
Merge branch 'dokka-runtime-multiple-dokka-tasks' into multiplatform-support
Diffstat (limited to 'runners/gradle-plugin/src/main')
-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 4a4518b9..554748b9 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
@@ -53,8 +53,12 @@ open class DokkaTask : DefaultTask() {
var dokkaRuntime: Configuration? = null
+ var defaultDokkaRuntime: Configuration? = null
+
@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()
@@ -94,20 +98,17 @@ open class DokkaTask : DefaultTask() {
@Input
var subProjects: List<String> = emptyList()
- 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)
}
}
@@ -139,11 +140,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 7cc19900..16e633fd 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
@@ -16,8 +16,14 @@ open class DokkaPlugin : Plugin<Project> {
DokkaVersion.loadFrom(javaClass.getResourceAsStream("/META-INF/gradle-plugins/org.jetbrains.dokka.properties"))
// TODO: Register instead of create for Gradle >= 4.10
+ 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
}