aboutsummaryrefslogtreecommitdiff
path: root/runners/gradle-plugin/src
diff options
context:
space:
mode:
authorMarcin Aman <marcin.aman@gmail.com>2020-10-07 13:58:46 +0200
committerGitHub <noreply@github.com>2020-10-07 13:58:46 +0200
commite9f5da45c0fcfec5f7c150229301904d7915e090 (patch)
treec094b57b37fec4c901bbfaa508268d354a4dc4c8 /runners/gradle-plugin/src
parentde6019337ae0e97e73db7fa9394e88ec2de4aeed (diff)
downloaddokka-e9f5da45c0fcfec5f7c150229301904d7915e090.tar.gz
dokka-e9f5da45c0fcfec5f7c150229301904d7915e090.tar.bz2
dokka-e9f5da45c0fcfec5f7c150229301904d7915e090.zip
Make logo replaceable #1339 (#1488)
Diffstat (limited to 'runners/gradle-plugin/src')
-rw-r--r--runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/AbstractDokkaTask.kt39
-rw-r--r--runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaCollectorTask.kt1
-rw-r--r--runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaMultiModuleTask.kt3
-rw-r--r--runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaTask.kt11
-rw-r--r--runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/utils.kt1
-rw-r--r--runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaConfigurationJsonTest.kt4
-rw-r--r--runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaConfigurationSerializableTest.kt5
-rw-r--r--runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaMultiModuleTaskTest.kt8
8 files changed, 49 insertions, 23 deletions
diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/AbstractDokkaTask.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/AbstractDokkaTask.kt
index 9dab1f04..77b4b2e1 100644
--- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/AbstractDokkaTask.kt
+++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/AbstractDokkaTask.kt
@@ -8,17 +8,19 @@ import org.gradle.api.DefaultTask
import org.gradle.api.Task
import org.gradle.api.artifacts.Configuration
import org.gradle.api.plugins.JavaBasePlugin
+import org.gradle.api.provider.ListProperty
import org.gradle.api.provider.MapProperty
import org.gradle.api.provider.Property
import org.gradle.api.tasks.*
+import org.gradle.kotlin.dsl.listProperty
import org.gradle.kotlin.dsl.mapProperty
-import org.jetbrains.dokka.DokkaBootstrap
-import org.jetbrains.dokka.DokkaConfigurationImpl
-import org.jetbrains.dokka.DokkaDefaults
-import org.jetbrains.dokka.toJsonString
+import org.jetbrains.dokka.*
+import org.jetbrains.dokka.plugability.ConfigurableBlock
+import org.jetbrains.dokka.plugability.DokkaPlugin
import java.io.File
import java.util.function.BiConsumer
import kotlin.reflect.KClass
+import kotlin.reflect.full.createInstance
abstract class AbstractDokkaTask(
private val bootstrapClass: KClass<out DokkaBootstrap> = DokkaBootstrap::class
@@ -49,7 +51,23 @@ abstract class AbstractDokkaTask(
.safeConvention(DokkaDefaults.offlineMode)
@Input
- val pluginsConfiguration: MapProperty<String, String> = project.objects.mapProperty()
+ val pluginsConfiguration: ListProperty<in DokkaConfiguration.PluginConfiguration> = project.objects.listProperty()
+
+ /**
+ * Used to keep compatibility with gradle using Kotlin lower than 1.3.50
+ */
+ @Input
+ val pluginsMapConfiguration: MapProperty<String, String> = project.objects.mapProperty()
+
+ inline fun <reified P : DokkaPlugin, reified T : ConfigurableBlock> pluginConfiguration(block: T.() -> Unit) {
+ val instance = T::class.createInstance().apply(block)
+ val pluginConfiguration = PluginConfigurationImpl(
+ fqPluginName = P::class.qualifiedName!!,
+ serializationFormat = DokkaConfiguration.SerializationFormat.JSON,
+ values = instance.toJsonString()
+ )
+ pluginsConfiguration.add(pluginConfiguration)
+ }
@Classpath
val plugins: Configuration = project.maybeCreateDokkaPluginConfiguration(name)
@@ -84,4 +102,15 @@ abstract class AbstractDokkaTask(
init {
group = JavaBasePlugin.DOCUMENTATION_GROUP
}
+
+ internal fun buildPluginsConfiguration(): List<PluginConfigurationImpl> {
+ val manuallyConfigured = pluginsMapConfiguration.getSafe().entries.map { entry ->
+ PluginConfigurationImpl(
+ entry.key,
+ DokkaConfiguration.SerializationFormat.JSON,
+ entry.value
+ )
+ }
+ return pluginsConfiguration.getSafe().mapNotNull { it as? PluginConfigurationImpl } + manuallyConfigured
+ }
}
diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaCollectorTask.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaCollectorTask.kt
index cd53398a..b0fc5f22 100644
--- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaCollectorTask.kt
+++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaCollectorTask.kt
@@ -17,6 +17,7 @@ abstract class DokkaCollectorTask : AbstractDokkaParentTask() {
failOnWarning = failOnWarning.getSafe(),
offlineMode = offlineMode.getSafe(),
pluginsClasspath = plugins.resolve().toList(),
+ pluginsConfiguration = buildPluginsConfiguration()
)
val subprojectDokkaConfigurations = childDokkaTasks.map { dokkaTask -> dokkaTask.buildDokkaConfiguration() }
diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaMultiModuleTask.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaMultiModuleTask.kt
index 92560c94..03e0b4d7 100644
--- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaMultiModuleTask.kt
+++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaMultiModuleTask.kt
@@ -6,6 +6,7 @@ import org.gradle.api.tasks.*
import org.jetbrains.dokka.DokkaConfigurationImpl
import org.jetbrains.dokka.DokkaModuleDescriptionImpl
import org.jetbrains.dokka.DokkaMultimoduleBootstrapImpl
+import org.jetbrains.dokka.PluginConfigurationImpl
import java.io.File
@Suppress("unused") // Shall provide source compatibility if possible
@@ -49,7 +50,7 @@ abstract class DokkaMultiModuleTask : AbstractDokkaParentTask(DokkaMultimoduleBo
moduleName = moduleName.getSafe(),
outputDir = outputDirectory.getSafe(),
cacheRoot = cacheRoot.getSafe(),
- pluginsConfiguration = pluginsConfiguration.getSafe(),
+ pluginsConfiguration = buildPluginsConfiguration(),
failOnWarning = failOnWarning.getSafe(),
offlineMode = offlineMode.getSafe(),
pluginsClasspath = plugins.resolve().toList(),
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 ed3989af..9944bacb 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
@@ -4,9 +4,7 @@ import org.gradle.api.NamedDomainObjectContainer
import org.gradle.api.internal.plugins.DslObject
import org.gradle.api.tasks.Internal
import org.gradle.api.tasks.Nested
-import org.jetbrains.dokka.DokkaBootstrapImpl
-import org.jetbrains.dokka.DokkaConfigurationImpl
-import org.jetbrains.dokka.build
+import org.jetbrains.dokka.*
abstract class DokkaTask : AbstractDokkaTask(DokkaBootstrapImpl::class) {
@@ -34,8 +32,8 @@ abstract class DokkaTask : AbstractDokkaTask(DokkaBootstrapImpl::class) {
.also(::checkSourceSetDependencies)
.filterNot { it.suppress.getSafe() }
- override fun buildDokkaConfiguration(): DokkaConfigurationImpl {
- return DokkaConfigurationImpl(
+ override fun buildDokkaConfiguration(): DokkaConfigurationImpl =
+ DokkaConfigurationImpl(
moduleName = moduleName.getSafe(),
moduleVersion = moduleVersion.orNull,
outputDir = outputDirectory.getSafe(),
@@ -43,8 +41,7 @@ abstract class DokkaTask : AbstractDokkaTask(DokkaBootstrapImpl::class) {
offlineMode = offlineMode.getSafe(),
failOnWarning = failOnWarning.getSafe(),
sourceSets = unsuppressedSourceSets.build(),
- pluginsConfiguration = pluginsConfiguration.getSafe(),
+ pluginsConfiguration = buildPluginsConfiguration(),
pluginsClasspath = plugins.resolve().toList()
)
- }
}
diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/utils.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/utils.kt
index 14b2a045..1c0c8080 100644
--- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/utils.kt
+++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/utils.kt
@@ -7,7 +7,6 @@ import org.gradle.api.provider.HasMultipleValues
import org.gradle.api.provider.Property
import org.gradle.api.provider.Provider
import org.gradle.util.Path
-import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
import org.jetbrains.kotlin.gradle.plugin.KotlinTarget
diff --git a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaConfigurationJsonTest.kt b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaConfigurationJsonTest.kt
index d1bfb0e1..68506876 100644
--- a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaConfigurationJsonTest.kt
+++ b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaConfigurationJsonTest.kt
@@ -25,8 +25,8 @@ class DokkaConfigurationJsonTest {
this.offlineMode by true
this.outputDirectory by File("customOutputDir")
this.cacheRoot by File("customCacheRoot")
- this.pluginsConfiguration.put("0", "a")
- this.pluginsConfiguration.put("1", "b")
+ this.pluginsConfiguration.add(PluginConfigurationImpl("A", DokkaConfiguration.SerializationFormat.JSON, """ { "key" : "value1" } """))
+ this.pluginsConfiguration.add(PluginConfigurationImpl("B", DokkaConfiguration.SerializationFormat.JSON, """ { "key" : "value2" } """))
this.dokkaSourceSets.create("main") { sourceSet ->
sourceSet.displayName by "customSourceSetDisplayName"
sourceSet.reportUndocumented by true
diff --git a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaConfigurationSerializableTest.kt b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaConfigurationSerializableTest.kt
index 99fca12d..2887f957 100644
--- a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaConfigurationSerializableTest.kt
+++ b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaConfigurationSerializableTest.kt
@@ -3,6 +3,7 @@ package org.jetbrains.dokka.gradle
import org.gradle.kotlin.dsl.withType
import org.gradle.testfixtures.ProjectBuilder
import org.jetbrains.dokka.DokkaConfiguration
+import org.jetbrains.dokka.PluginConfigurationImpl
import org.jetbrains.dokka.toJsonString
import org.junit.Rule
import org.junit.rules.TemporaryFolder
@@ -32,8 +33,8 @@ class DokkaConfigurationSerializableTest {
this.offlineMode by true
this.outputDirectory by File("customOutputDir")
this.cacheRoot by File("customCacheRoot")
- this.pluginsConfiguration.put("0", "a")
- this.pluginsConfiguration.put("1", "b")
+ this.pluginsConfiguration.add(PluginConfigurationImpl("A", DokkaConfiguration.SerializationFormat.JSON, """ { "key" : "value1" } """))
+ this.pluginsConfiguration.add(PluginConfigurationImpl("B", DokkaConfiguration.SerializationFormat.JSON, """ { "key" : "value2" } """))
this.dokkaSourceSets.create("main") { sourceSet ->
sourceSet.displayName by "customSourceSetDisplayName"
sourceSet.reportUndocumented by true
diff --git a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaMultiModuleTaskTest.kt b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaMultiModuleTaskTest.kt
index bea80f1e..fd449346 100644
--- a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaMultiModuleTaskTest.kt
+++ b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaMultiModuleTaskTest.kt
@@ -4,9 +4,7 @@ package org.jetbrains.dokka.gradle
import org.gradle.kotlin.dsl.*
import org.gradle.testfixtures.ProjectBuilder
-import org.jetbrains.dokka.DokkaConfigurationImpl
-import org.jetbrains.dokka.DokkaException
-import org.jetbrains.dokka.DokkaModuleDescriptionImpl
+import org.jetbrains.dokka.*
import java.io.File
import kotlin.test.Test
import kotlin.test.assertEquals
@@ -68,7 +66,7 @@ class DokkaMultiModuleTaskTest {
moduleName by "custom Module Name"
outputDirectory by project.buildDir.resolve("customOutputDirectory")
cacheRoot by File("customCacheRoot")
- pluginsConfiguration.put("pluginA", "configA")
+ pluginsConfiguration.add(PluginConfigurationImpl("pluginA", DokkaConfiguration.SerializationFormat.JSON, """ { "key" : "value2" } """))
failOnWarning by true
offlineMode by true
}
@@ -79,7 +77,7 @@ class DokkaMultiModuleTaskTest {
moduleName = "custom Module Name",
outputDir = multiModuleTask.project.buildDir.resolve("customOutputDirectory"),
cacheRoot = File("customCacheRoot"),
- pluginsConfiguration = mapOf("pluginA" to "configA"),
+ pluginsConfiguration = mutableListOf(PluginConfigurationImpl("pluginA", DokkaConfiguration.SerializationFormat.JSON, """ { "key" : "value2" } """)),
pluginsClasspath = emptyList(),
failOnWarning = true,
offlineMode = true,