mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 00:17:11 -07:00
Support multiple dokka tasks.
This commit is contained in:
parent
074811da1d
commit
df20758428
2 changed files with 19 additions and 7 deletions
14
src/main/kotlin/com/beust/kobalt/api/ConfigsPlugin.kt
Normal file
14
src/main/kotlin/com/beust/kobalt/api/ConfigsPlugin.kt
Normal file
|
@ -0,0 +1,14 @@
|
|||
package com.beust.kobalt.api
|
||||
|
||||
import com.google.common.collect.ArrayListMultimap
|
||||
|
||||
/**
|
||||
* A plug-in that has some per-project list of configurations in the build file.
|
||||
*/
|
||||
abstract public class ConfigsPlugin<T> : BasePlugin() {
|
||||
private val configurations = ArrayListMultimap.create<String, T>()
|
||||
|
||||
fun configurationFor(project: Project) = configurations[project.name]
|
||||
|
||||
fun addConfiguration(project: Project, configuration: T) = configurations.put(project.name, configuration)
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
package com.beust.kobalt.plugin.dokka
|
||||
|
||||
import com.beust.kobalt.TaskResult
|
||||
import com.beust.kobalt.api.ConfigPlugin
|
||||
import com.beust.kobalt.api.ConfigsPlugin
|
||||
import com.beust.kobalt.api.Kobalt
|
||||
import com.beust.kobalt.api.Project
|
||||
import com.beust.kobalt.api.annotation.Directive
|
||||
|
@ -16,7 +16,7 @@ import java.util.*
|
|||
import javax.inject.Singleton
|
||||
|
||||
@Singleton
|
||||
class DokkaPlugin : ConfigPlugin<DokkaConfig>() {
|
||||
class DokkaPlugin : ConfigsPlugin<DokkaConfig>() {
|
||||
override val name = PLUGIN_NAME
|
||||
|
||||
companion object {
|
||||
|
@ -28,13 +28,13 @@ class DokkaPlugin : ConfigPlugin<DokkaConfig>() {
|
|||
*/
|
||||
@Task(name = "dokka", description = "Run dokka", runAfter = arrayOf(PackagingPlugin.TASK_ASSEMBLE))
|
||||
fun taskDokka(project: Project) : TaskResult {
|
||||
val config = configurationFor(project)
|
||||
val configs = configurationFor(project)
|
||||
val classpath = context.dependencyManager.calculateDependencies(project, context)
|
||||
val buildDir = project.buildDirectory!!
|
||||
val classpathList = classpath.map { it.jarFile.get().absolutePath } + listOf(buildDir)
|
||||
var success = true
|
||||
if (config != null) {
|
||||
if (! config.skip) {
|
||||
configs.forEach { config ->
|
||||
if (!config.skip) {
|
||||
val outputDir = buildDir + "/" +
|
||||
if (config.outputDir.isBlank()) "doc" else config.outputDir
|
||||
|
||||
|
@ -54,8 +54,6 @@ class DokkaPlugin : ConfigPlugin<DokkaConfig>() {
|
|||
} else {
|
||||
log(2, "skip is true, not generating the documentation")
|
||||
}
|
||||
} else {
|
||||
log(2, "No dokka configuration found for project ${project.name}, skipping it")
|
||||
}
|
||||
return TaskResult(success)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue