diff options
author | Paul Merlin <paul@gradle.com> | 2018-09-15 15:46:28 +0200 |
---|---|---|
committer | Simon Ogorodnik <Simon.Ogorodnik@jetbrains.com> | 2019-01-25 17:29:02 +0300 |
commit | 22700d015f552429af2806c767d716bf8613178c (patch) | |
tree | 360a6dac6380a439f67c676e0c1764866c03d3a2 /runners/gradle-plugin/src/main/kotlin/main.kt | |
parent | fa6e8ab0b0a846192d46cf9d13a0e4f01262432f (diff) | |
download | dokka-22700d015f552429af2806c767d716bf8613178c.tar.gz dokka-22700d015f552429af2806c767d716bf8613178c.tar.bz2 dokka-22700d015f552429af2806c767d716bf8613178c.zip |
Add type safe counterparts to Closure taking methods on DokkaTask
Signed-off-by: Paul Merlin <paul@gradle.com>
Diffstat (limited to 'runners/gradle-plugin/src/main/kotlin/main.kt')
-rw-r--r-- | runners/gradle-plugin/src/main/kotlin/main.kt | 53 |
1 files changed, 41 insertions, 12 deletions
diff --git a/runners/gradle-plugin/src/main/kotlin/main.kt b/runners/gradle-plugin/src/main/kotlin/main.kt index d3a341e0..9130a329 100644 --- a/runners/gradle-plugin/src/main/kotlin/main.kt +++ b/runners/gradle-plugin/src/main/kotlin/main.kt @@ -1,6 +1,7 @@ package org.jetbrains.dokka.gradle import groovy.lang.Closure +import org.gradle.api.Action import org.gradle.api.DefaultTask import org.gradle.api.Plugin import org.gradle.api.Project @@ -147,14 +148,17 @@ open class DokkaTask : DefaultTask() { private var kotlinTasksConfigurator: () -> List<Any?>? = { defaultKotlinTasks() } private val kotlinTasks: List<Task> by lazy { extractKotlinCompileTasks() } + fun kotlinTasks(taskSupplier: Callable<List<Any>>) { + kotlinTasksConfigurator = { taskSupplier.call() } + } + fun kotlinTasks(closure: Closure<Any?>) { kotlinTasksConfigurator = { closure.call() as? List<Any?> } } - fun linkMapping(closure: Closure<Unit>) { + fun linkMapping(action: Action<LinkMapping>) { val mapping = LinkMapping() - closure.delegate = mapping - closure.call() + action.execute(mapping) if (mapping.path.isEmpty()) { throw IllegalArgumentException("Link mapping should have dir") @@ -166,27 +170,52 @@ open class DokkaTask : DefaultTask() { linkMappings.add(mapping) } - fun sourceRoot(closure: Closure<Unit>) { + fun linkMapping(closure: Closure<Unit>) { + linkMapping(Action { mapping -> + closure.delegate = mapping + closure.call() + }) + } + + fun sourceRoot(action: Action<SourceRoot>) { val sourceRoot = SourceRoot() - closure.delegate = sourceRoot - closure.call() + action.execute(sourceRoot) sourceRoots.add(sourceRoot) } - fun packageOptions(closure: Closure<Unit>) { + fun sourceRoot(closure: Closure<Unit>) { + sourceRoot(Action { sourceRoot -> + closure.delegate = sourceRoot + closure.call() + }) + } + + fun packageOptions(action: Action<PackageOptions>) { val packageOptions = PackageOptions() - closure.delegate = packageOptions - closure.call() + action.execute(packageOptions) perPackageOptions.add(packageOptions) } - fun externalDocumentationLink(closure: Closure<Unit>) { + fun packageOptions(closure: Closure<Unit>) { + packageOptions(Action { packageOptions -> + closure.delegate = packageOptions + closure.call() + }) + } + + fun externalDocumentationLink(action: Action<DokkaConfiguration.ExternalDocumentationLink.Builder>) { val builder = DokkaConfiguration.ExternalDocumentationLink.Builder() - closure.delegate = builder - closure.call() + action.execute(builder) externalDocumentationLinks.add(builder.build()) } + fun externalDocumentationLink(closure: Closure<Unit>) { + externalDocumentationLink(Action { builder -> + closure.delegate = builder + closure.call() + }) + } + fun tryResolveFatJar(project: Project): File { return try { val dependency = project.buildscript.dependencies.create(dokkaFatJar) |