Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add deprecated property to help migrate from JSON Dokka plugin configuration #3877

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/topics/dokka-migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -444,4 +444,4 @@ DGP v2 now supports Gradle build cache and configuration cache, improving build

* Explore more [DGP v2 project examples](https://github.com/Kotlin/dokka/tree/master/examples/gradle-v2).
* [Get started with Dokka](dokka-get-started.md).
* [Learn more about Dokka plugins](dokka-plugins.md).
* [Learn more about Dokka plugins](dokka-plugins.md).
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public abstract class org/jetbrains/dokka/gradle/DokkaExtension : java/io/Serial
public abstract fun getModulePath ()Lorg/gradle/api/provider/Property;
public abstract fun getModuleVersion ()Lorg/gradle/api/provider/Property;
public final fun getPluginsConfiguration ()Lorg/gradle/api/ExtensiblePolymorphicDomainObjectContainer;
public abstract fun getPluginsMapConfiguration ()Lorg/gradle/api/provider/MapProperty;
public abstract fun getSourceSetScopeDefault ()Lorg/gradle/api/provider/Property;
public abstract fun getSuppressInheritedMembers ()Lorg/gradle/api/provider/Property;
public abstract fun getSuppressObviousFunctions ()Lorg/gradle/api/provider/Property;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import org.gradle.api.file.DirectoryProperty
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.model.ObjectFactory
import org.gradle.api.plugins.ExtensionAware
import org.gradle.api.provider.MapProperty
import org.gradle.api.provider.Property
import org.gradle.api.tasks.Nested
import org.gradle.kotlin.dsl.newInstance
Expand Down Expand Up @@ -74,7 +75,7 @@ constructor(
*
* Each publication will generate one Dokka site based on the included Dokka Source Sets.
*
* The type of site is determined by the Dokka Plugins. By default, an HTML site will be generated.
* The type of site is determined by the Dokka plugins. By default, an HTML site will be generated.
*/
val dokkaPublications: NamedDomainObjectContainer<DokkaPublication> =
extensions.adding(
Expand Down Expand Up @@ -213,5 +214,90 @@ constructor(
*/
@Deprecated("Moved to DokkaPublication#suppressObviousFunctions")
abstract val suppressObviousFunctions: Property<Boolean>

/**
* JSON configuration of Dokka plugins is deprecated.
* Typesafe configuration must be used instead - see [pluginsConfiguration].
*
* In DPGv1 the Dokka plugins could be configured by manually writing JSON.
* This caused issues with registering task inputs for Gradle up-to-date checks.
* (For more information on registering task inputs, see
* [Gradle Docs: Incremental build](https://docs.gradle.org/current/userguide/incremental_build.html)).
*
* In DGPv2 Dokka plugins must be configured in a typesafe way, using [pluginsConfiguration].
*
* #### Configuration of built-in Dokka plugins
*
* The built-in Dokka plugins can be configured using a typesafe DSL.
*
* This example demonstrates how to convert JSON configuration of the
* [Dokka Versioning plugin](https://kotl.in/dokka-versioning-plugin)
* into the new, typesafe config.
*
* ```
* // Deprecated configuration of the Dokka Versioning plugin:
* tasks.dokkaHtmlMultiModule {
* pluginsMapConfiguration.set(
* mapOf(
* "org.jetbrains.dokka.versioning.VersioningPlugin" to """
* { "version": "1.2", "olderVersionsDir": "$projectDir/dokka-docs" }
* """.trimIndent()
* )
* )
* }
*
* // New configuration in DGPv2 is typesafe and compatible with incremental builds.
* dokka {
* pluginsConfiguration {
* versioning {
* version.set("1.2")
* olderVersionsDir.set(projectDir.resolve("dokka-docs"))
* }
* }
* }
* ```
*
* #### External Dokka Plugin configuration
*
* To configure external Dokka plugins you must create a subclass of
* [DokkaPluginParametersBaseSpec][org.jetbrains.dokka.gradle.engine.plugins.DokkaPluginParametersBaseSpec],
* and register it as a configuration type using
* [pluginsConfiguration.registerBinding][org.gradle.api.ExtensiblePolymorphicDomainObjectContainer.registerBinding].
*
* ```
* import org.jetbrains.dokka.gradle.engine.plugins.DokkaPluginParametersBaseSpec
*
* @OptIn(DokkaInternalApi::class)
* abstract class MyCustomDokkaPluginConfiguration @Inject constructor(
* name: String
* ) : DokkaPluginParametersBaseSpec(name, "demo.MyCustomDokkaPlugin") {
*
* @get:Input
* @get:Optional
* abstract val flags: ListProperty<String>
*
* override fun jsonEncode(): String {
* // convert the 'flags' to JSON, to be decoded by MyCustomDokkaPlugin.
* }
* }
*
* dokka {
* pluginsConfiguration {
* registerBinding(MyCustomDokkaPluginConfiguration::class, MyCustomDokkaPluginConfiguration::class)
* register<MyCustomDokkaPluginConfiguration>("MyCustomDokkaPlugin") {
* flags.add("someFlag...")
* }
* }
* }
* ```
*
* @see pluginsConfiguration
*/
@Deprecated(
message = "JSON configuration of Dokka plugins is deprecated. Typesafe configuration must be used instead.",
level = DeprecationLevel.ERROR,
)
@Suppress("unused")
abstract val pluginsMapConfiguration: MapProperty<String, String>
//endregion
}
Loading