aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Doległo <kamilok1965@interia.pl>2019-04-15 13:26:26 +0200
committerKamil Doległo <kamilok1965@interia.pl>2019-04-15 13:26:26 +0200
commitd5864c672135bd2f5c7ce4fea5aeccd861796a47 (patch)
tree25b61fcd03f42b2ec5ee57da440b427f3a72bfac
parent64305246bf6a22a4111c11dc3c671297cf223393 (diff)
downloaddokka-d5864c672135bd2f5c7ce4fea5aeccd861796a47.tar.gz
dokka-d5864c672135bd2f5c7ce4fea5aeccd861796a47.tar.bz2
dokka-d5864c672135bd2f5c7ce4fea5aeccd861796a47.zip
Light refactoring
-rw-r--r--runners/android-gradle-plugin/src/main/kotlin/mainAndroid.kt4
-rw-r--r--runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaTask.kt (renamed from runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/dokkaTask.kt)22
-rw-r--r--runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/ProxyUtils.kt4
-rw-r--r--runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/configurationImplementations.kt35
-rw-r--r--runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/main.kt5
5 files changed, 41 insertions, 29 deletions
diff --git a/runners/android-gradle-plugin/src/main/kotlin/mainAndroid.kt b/runners/android-gradle-plugin/src/main/kotlin/mainAndroid.kt
index 2fbeaae7..367b9257 100644
--- a/runners/android-gradle-plugin/src/main/kotlin/mainAndroid.kt
+++ b/runners/android-gradle-plugin/src/main/kotlin/mainAndroid.kt
@@ -3,8 +3,8 @@ package org.jetbrains.dokka.gradle
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.tasks.Input
-import org.jetbrains.dokka.DokkaConfiguration
import org.jetbrains.dokka.DokkaConfiguration.ExternalDocumentationLink.Builder
+import org.jetbrains.dokka.DokkaConfiguration.SourceRoot
import java.io.File
open class DokkaAndroidPlugin : Plugin<Project> {
@@ -24,7 +24,7 @@ open class DokkaAndroidTask : DokkaTask() {
@Input var noAndroidSdkLink: Boolean = false
- override fun collectSuppressedFiles(sourceRoots: List<DokkaConfiguration.SourceRoot>): List<String> {
+ override fun collectSuppressedFiles(sourceRoots: List<SourceRoot>): List<String> {
val generatedRoot = project.buildDir.resolve("generated").absoluteFile
return sourceRoots
.map { File(it.path) }
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 0d78461c..e8067e4c 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
@@ -13,6 +13,7 @@ import org.gradle.api.tasks.*
import org.gradle.api.tasks.compile.AbstractCompile
import org.jetbrains.dokka.DokkaBootstrap
import org.jetbrains.dokka.DokkaConfiguration
+import org.jetbrains.dokka.DokkaConfiguration.SourceRoot
import org.jetbrains.dokka.ReflectDsl
import org.jetbrains.dokka.ReflectDsl.isNotInstance
import java.io.File
@@ -44,10 +45,13 @@ open class DokkaTask : DefaultTask() {
@Input
var moduleName: String = ""
+
@Input
var outputFormat: String = "html"
+
@OutputDirectory
var outputDirectory: String = ""
+
var dokkaRuntime: Configuration? = null
@InputFiles
@@ -55,17 +59,23 @@ open class DokkaTask : DefaultTask() {
@Input
var sourceDirs: Iterable<File> = emptyList()
+
@Input
var sourceRoots: MutableList<DokkaConfiguration.SourceRoot> = arrayListOf()
+
@Input
var dokkaFatJar: Any = "org.jetbrains.dokka:dokka-fatjar:${DokkaVersion.version}"
+
@Input
var impliedPlatforms: MutableList<String> = arrayListOf()
+
@Optional
@Input
var cacheRoot: String? = null
+
@Input
var collectInheritedExtensionsFromLibraries: Boolean = false
+
@get:Internal
internal val kotlinCompileBasedClasspathAndSourceRoots: ClasspathAndSourceRoots by lazy { extractClasspathAndSourceRootsFromKotlinTasks() }
@@ -158,7 +168,7 @@ open class DokkaTask : DefaultTask() {
private fun Iterable<File>.toSourceRoots(): List<GradleSourceRootImpl> = this.filter { it.exists() }.map { GradleSourceRootImpl().apply { path = it.path } }
- protected open fun collectSuppressedFiles(sourceRoots: List<DokkaConfiguration.SourceRoot>): List<String> = emptyList()
+ protected open fun collectSuppressedFiles(sourceRoots: List<SourceRoot>): List<String> = emptyList()
@TaskAction
fun generate() {
@@ -174,7 +184,7 @@ open class DokkaTask : DefaultTask() {
// TODO: implement extracting source roots from kotlin tasks
val (_, tasksSourceRoots) = kotlinCompileBasedClasspathAndSourceRoots
- val sourceRoots = collectSourceRoots(sourceDirs, sourceRoots) + tasksSourceRoots.toSourceRoots()
+ val sourceRoots = collectSourceRoots() + tasksSourceRoots.toSourceRoots()
val bootstrapClass = ClassloaderContainer.fatJarClassLoader!!.loadClass("org.jetbrains.dokka.DokkaBootstrapImpl")
val bootstrapInstance = bootstrapClass.constructors.first().newInstance()
@@ -183,10 +193,10 @@ open class DokkaTask : DefaultTask() {
val gson = GsonBuilder().setPrettyPrinting().create()
- val passConfigurationExtension: GradlePassConfigurationImpl? = this.extensions.findByName(
+ val passConfigurationExtension: GradlePassConfigurationImpl? = extensions.findByName(
CONFIGURATION_EXTENSION_NAME) as GradlePassConfigurationImpl?
val passConfigurationsContainer by lazy {
- (this.extensions.getByName(MULTIPLATFORM_EXTENSION_NAME) as Iterable<GradlePassConfigurationImpl>).toList()
+ (extensions.getByName(MULTIPLATFORM_EXTENSION_NAME) as Iterable<GradlePassConfigurationImpl>).toList()
}
passConfigurationExtension?.sourceRoots?.addAll(sourceRoots)
@@ -221,7 +231,7 @@ open class DokkaTask : DefaultTask() {
}
private fun defaultPassConfiguration(passConfig: GradlePassConfigurationImpl): GradlePassConfigurationImpl{
- val (tasksClasspath, tasksSourceRoots) = kotlinCompileBasedClasspathAndSourceRoots
+ val (tasksClasspath, _) = kotlinCompileBasedClasspathAndSourceRoots
val fullClasspath = tasksClasspath + classpath
passConfig.moduleName = moduleName
@@ -235,7 +245,7 @@ open class DokkaTask : DefaultTask() {
return passConfig
}
- private fun collectSourceRoots(sourceDirs: Iterable<File>, sourceRoots: List<DokkaConfiguration.SourceRoot>): List<DokkaConfiguration.SourceRoot> {
+ private fun collectSourceRoots(): List<DokkaConfiguration.SourceRoot> {
val sourceDirs = when {
sourceDirs.any() -> {
logger.info("Dokka: Taking source directories provided by the user")
diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/ProxyUtils.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/ProxyUtils.kt
index 61c9e773..f8965993 100644
--- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/ProxyUtils.kt
+++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/ProxyUtils.kt
@@ -26,8 +26,8 @@ inline fun <reified T : Any> automagicTypedProxy(targetClassLoader: ClassLoader,
*/
fun automagicProxy(targetClassLoader: ClassLoader, targetType: Class<*>, delegate: Any): Any =
Proxy.newProxyInstance(
- targetClassLoader,
- arrayOf(targetType),
+ targetClassLoader,
+ arrayOf(targetType),
DelegatedInvocationHandler(delegate)
)
diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/configurationImplementations.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/configurationImplementations.kt
index bab36f29..56bfe262 100644
--- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/configurationImplementations.kt
+++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/configurationImplementations.kt
@@ -4,12 +4,13 @@ import groovy.lang.Closure
import org.gradle.api.Action
import org.gradle.util.ConfigureUtil
import org.jetbrains.dokka.DokkaConfiguration
+import org.jetbrains.dokka.DokkaConfiguration.*
import org.jetbrains.dokka.Platform
import java.io.File
import java.io.Serializable
import java.net.URL
-class GradleSourceRootImpl: DokkaConfiguration.SourceRoot, Serializable{
+class GradleSourceRootImpl: SourceRoot, Serializable {
override var path: String = ""
set(value) {
field = File(value).absolutePath
@@ -18,10 +19,10 @@ class GradleSourceRootImpl: DokkaConfiguration.SourceRoot, Serializable{
override fun toString(): String = path
}
-open class GradlePassConfigurationImpl(@Transient val name: String = ""): DokkaConfiguration.PassConfiguration {
+open class GradlePassConfigurationImpl(@Transient val name: String = ""): PassConfiguration {
override var classpath: List<String> = emptyList()
override var moduleName: String = ""
- override var sourceRoots: MutableList<DokkaConfiguration.SourceRoot> = mutableListOf()
+ override var sourceRoots: MutableList<SourceRoot> = mutableListOf()
override var samples: List<String> = emptyList()
override var includes: List<String> = emptyList()
override var includeNonPublic: Boolean = false
@@ -30,9 +31,9 @@ open class GradlePassConfigurationImpl(@Transient val name: String = ""): DokkaC
override var skipEmptyPackages: Boolean = false
override var skipDeprecated: Boolean = false
override var jdkVersion: Int = 6
- override var sourceLinks: MutableList<DokkaConfiguration.SourceLinkDefinition> = mutableListOf()
- override var perPackageOptions: MutableList<DokkaConfiguration.PackageOptions> = mutableListOf()
- override var externalDocumentationLinks: MutableList<DokkaConfiguration.ExternalDocumentationLink> = mutableListOf()
+ override var sourceLinks: MutableList<SourceLinkDefinition> = mutableListOf()
+ override var perPackageOptions: MutableList<PackageOptions> = mutableListOf()
+ override var externalDocumentationLinks: MutableList<ExternalDocumentationLink> = mutableListOf()
override var languageVersion: String? = null
override var apiVersion: String? = null
override var noStdlibLink: Boolean = false
@@ -43,58 +44,58 @@ open class GradlePassConfigurationImpl(@Transient val name: String = ""): DokkaC
override var targets: List<String> = listOf("JVM")
override var sinceKotlin: String = "1.0"
- fun sourceRoot(c: Closure<Unit>){
+ fun sourceRoot(c: Closure<Unit>) {
val configured = ConfigureUtil.configure(c, GradleSourceRootImpl())
sourceRoots.add(configured)
}
- fun sourceRoot(action: Action<in GradleSourceRootImpl>){
+ fun sourceRoot(action: Action<in GradleSourceRootImpl>) {
val sourceRoot = GradleSourceRootImpl()
action.execute(sourceRoot)
sourceRoots.add(sourceRoot)
}
- fun sourceLink(c: Closure<Unit>){
+ fun sourceLink(c: Closure<Unit>) {
val configured = ConfigureUtil.configure(c, GradleSourceLinkDefinitionImpl())
sourceLinks.add(configured)
}
- fun sourceLink(action: Action<in GradleSourceLinkDefinitionImpl>){
+ fun sourceLink(action: Action<in GradleSourceLinkDefinitionImpl>) {
val sourceLink = GradleSourceLinkDefinitionImpl()
action.execute(sourceLink)
sourceLinks.add(sourceLink)
}
- fun perPackageOption(c: Closure<Unit>){
+ fun perPackageOption(c: Closure<Unit>) {
val configured = ConfigureUtil.configure(c, GradlePackageOptionsImpl())
perPackageOptions.add(configured)
}
- fun perPackageOption(action: Action<in GradlePackageOptionsImpl>){
+ fun perPackageOption(action: Action<in GradlePackageOptionsImpl>) {
val option = GradlePackageOptionsImpl()
action.execute(option)
perPackageOptions.add(option)
}
- fun externalDocumentationLink(c: Closure<Unit>){
+ fun externalDocumentationLink(c: Closure<Unit>) {
val link = ConfigureUtil.configure(c, GradleExternalDocumentationLinkImpl())
externalDocumentationLinks.add(link)
}
- fun externalDocumentationLink(action: Action<in GradleExternalDocumentationLinkImpl>){
+ fun externalDocumentationLink(action: Action<in GradleExternalDocumentationLinkImpl>) {
val link = GradleExternalDocumentationLinkImpl()
action.execute(link)
externalDocumentationLinks.add(link)
}
}
-class GradleSourceLinkDefinitionImpl : DokkaConfiguration.SourceLinkDefinition {
+class GradleSourceLinkDefinitionImpl : SourceLinkDefinition {
override var path: String = ""
override var url: String = ""
override var lineSuffix: String? = null
}
-class GradleExternalDocumentationLinkImpl : DokkaConfiguration.ExternalDocumentationLink {
+class GradleExternalDocumentationLinkImpl : ExternalDocumentationLink {
override var url: URL = URL("")
override var packageListUrl: URL = URL("")
}
@@ -108,7 +109,7 @@ class GradleDokkaConfigurationImpl: DokkaConfiguration {
override var passesConfigurations: List<GradlePassConfigurationImpl> = emptyList()
}
-class GradlePackageOptionsImpl: DokkaConfiguration.PackageOptions {
+class GradlePackageOptionsImpl: PackageOptions {
override var prefix: String = ""
override val includeNonPublic: Boolean = false
override val reportUndocumented: Boolean = true
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 defddd31..d04ed5f0 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
@@ -7,9 +7,10 @@ import java.io.InputStream
import java.util.*
/*
-* Those are extension names, which are used in a build.gradle file as closure names:
+* Extension names, which are used in a build.gradle file as closure names:
* dokka {
-* configuration { <- extension name
+* configuration { // extension name
+*
* }
* }
* */