aboutsummaryrefslogtreecommitdiff
path: root/runners
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
parentde6019337ae0e97e73db7fa9394e88ec2de4aeed (diff)
downloaddokka-e9f5da45c0fcfec5f7c150229301904d7915e090.tar.gz
dokka-e9f5da45c0fcfec5f7c150229301904d7915e090.tar.bz2
dokka-e9f5da45c0fcfec5f7c150229301904d7915e090.zip
Make logo replaceable #1339 (#1488)
Diffstat (limited to 'runners')
-rw-r--r--runners/cli/src/main/kotlin/cli/main.kt24
-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
-rw-r--r--runners/maven-plugin/src/main/kotlin/DokkaMojo.kt15
10 files changed, 77 insertions, 34 deletions
diff --git a/runners/cli/src/main/kotlin/cli/main.kt b/runners/cli/src/main/kotlin/cli/main.kt
index a1139e65..681ebfa6 100644
--- a/runners/cli/src/main/kotlin/cli/main.kt
+++ b/runners/cli/src/main/kotlin/cli/main.kt
@@ -46,7 +46,7 @@ class GlobalArguments(args: Array<String>) : DokkaConfiguration {
override val pluginsConfiguration by parser.option(
ArgTypePlugin,
description = "Configuration for plugins in format fqPluginName=json^^fqPluginName=json..."
- ).default(emptyMap())
+ ).delimiter("^^")
override val pluginsClasspath by parser.option(
ArgTypeFile,
@@ -254,16 +254,22 @@ object ArgTypeFile : ArgType<File>(true) {
object ArgTypePlatform : ArgType<Platform>(true) {
override fun convert(value: kotlin.String, name: kotlin.String): Platform = Platform.fromString(value)
override val description: kotlin.String
- get() = "{ String thar represents paltform }"
+ get() = "{ String that represents platform }"
}
-object ArgTypePlugin : ArgType<Map<String, String>>(true) {
- override fun convert(value: kotlin.String, name: kotlin.String): Map<kotlin.String, kotlin.String> =
- value.split("^^").map {
- it.split("=").let {
- it[0] to it[1]
- }
- }.toMap()
+object ArgTypePlugin : ArgType<DokkaConfiguration.PluginConfiguration>(true) {
+ override fun convert(
+ value: kotlin.String,
+ name: kotlin.String
+ ): DokkaConfiguration.PluginConfiguration {
+ return value.split("=").let {
+ PluginConfigurationImpl(
+ fqPluginName = it[0],
+ serializationFormat = DokkaConfiguration.SerializationFormat.JSON,
+ values = it[1]
+ )
+ }
+ }
override val description: kotlin.String
get() = "{ String fqName=json, remember to escape `\"` inside json }"
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,
diff --git a/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt b/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt
index 89928b4c..b03d2811 100644
--- a/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt
+++ b/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt
@@ -12,6 +12,7 @@ import org.apache.maven.project.MavenProjectHelper
import org.apache.maven.repository.internal.MavenRepositorySystemUtils
import org.codehaus.plexus.archiver.Archiver
import org.codehaus.plexus.archiver.jar.JarArchiver
+import org.codehaus.plexus.util.xml.Xpp3Dom
import org.eclipse.aether.DefaultRepositorySystemSession
import org.eclipse.aether.RepositorySystem
import org.eclipse.aether.RepositorySystemSession
@@ -224,6 +225,16 @@ abstract class AbstractDokkaMojo(private val defaultDokkaPlugins: List<Dependenc
val logger = MavenDokkaLogger(log)
+ val pluginsConfiguration =
+ (mavenProject?.getPlugin("org.jetbrains.dokka:dokka-maven-plugin")?.configuration as? Xpp3Dom)
+ ?.getChild("pluginsConfiguration")?.children?.map {
+ PluginConfigurationImpl(
+ it.name,
+ DokkaConfiguration.SerializationFormat.XML,
+ it.toString()
+ )
+ }.orEmpty()
+
val configuration = DokkaConfigurationImpl(
moduleName = moduleName,
outputDir = File(getOutDir()),
@@ -233,9 +244,9 @@ abstract class AbstractDokkaMojo(private val defaultDokkaPlugins: List<Dependenc
pluginsClasspath = getArtifactByAether("org.jetbrains.dokka", "dokka-base", dokkaVersion) +
dokkaPlugins.map { getArtifactByAether(it.groupId, it.artifactId, it.version ?: dokkaVersion) }
.flatten(),
- pluginsConfiguration = mutableMapOf(), //TODO implement as it is in Gradle
+ pluginsConfiguration = pluginsConfiguration.toMutableList(),
modules = emptyList(),
- failOnWarning = failOnWarning
+ failOnWarning = failOnWarning,
)
val gen = DokkaGenerator(configuration, logger)