From 8d23340d1c377b8f490cdee3c2c874453d321dd8 Mon Sep 17 00:00:00 2001 From: aSemy <897017+aSemy@users.noreply.github.com> Date: Thu, 23 Feb 2023 13:42:15 +0100 Subject: Update custom Gradle utils to use Gradle Kotlin DSL (#2833) --- .../dokka/gradle/DokkaMultiModuleFileLayout.kt | 7 ++- .../org/jetbrains/dokka/gradle/DokkaProperty.kt | 20 -------- .../jetbrains/dokka/gradle/DokkaSourceSetMapper.kt | 42 ++++++++-------- .../dokka/gradle/GradleDokkaSourceSetBuilder.kt | 56 +++++++++++----------- .../GradleExternalDocumentationLinkBuilder.kt | 9 ++-- .../dokka/gradle/GradlePackageOptionsBuilder.kt | 39 +++++++-------- .../dokka/gradle/GradleSourceLinkBuilder.kt | 17 +++---- .../dokka/gradle/checkDependentSourceSets.kt | 4 +- .../dokka/gradle/tasks/AbstractDokkaLeafTask.kt | 2 +- .../dokka/gradle/tasks/AbstractDokkaTask.kt | 35 +++++++------- .../dokka/gradle/tasks/DokkaCollectorTask.kt | 14 +++--- .../dokka/gradle/tasks/DokkaMultiModuleTask.kt | 23 ++++----- .../org/jetbrains/dokka/gradle/tasks/DokkaTask.kt | 14 +++--- .../dokka/gradle/tasks/DokkaTaskPartial.kt | 14 +++--- 14 files changed, 141 insertions(+), 155 deletions(-) (limited to 'runners/gradle-plugin/src/main/kotlin/org/jetbrains') diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaMultiModuleFileLayout.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaMultiModuleFileLayout.kt index 3daaa3b7..e604ed46 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaMultiModuleFileLayout.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaMultiModuleFileLayout.kt @@ -23,7 +23,7 @@ fun interface DokkaMultiModuleFileLayout { */ object NoCopy : DokkaMultiModuleFileLayout { override fun targetChildOutputDirectory(parent: DokkaMultiModuleTask, child: AbstractDokkaTask): File = - child.outputDirectory.getSafe() + child.outputDirectory.get() } /** @@ -38,7 +38,7 @@ fun interface DokkaMultiModuleFileLayout { val relativeProjectPath = parent.project.relativeProjectPath(child.project.path) val relativeFilePath = relativeProjectPath.replace(":", File.separator) check(!File(relativeFilePath).isAbsolute) { "Unexpected absolute path $relativeFilePath" } - return parent.outputDirectory.getSafe().resolve(relativeFilePath) + return parent.outputDirectory.get().resolve(relativeFilePath) } } } @@ -56,7 +56,7 @@ internal fun DokkaMultiModuleTask.copyChildOutputDirectories() { internal fun DokkaMultiModuleTask.copyChildOutputDirectory(child: AbstractDokkaTask) { val targetChildOutputDirectory = project.file(fileLayout.get().targetChildOutputDirectory(this, child)) - val sourceChildOutputDirectory = child.outputDirectory.getSafe() + val sourceChildOutputDirectory = child.outputDirectory.get() /* Pointing to the same directory -> No copy necessary */ if (sourceChildOutputDirectory.absoluteFile == targetChildOutputDirectory.absoluteFile) { @@ -79,4 +79,3 @@ internal fun DokkaMultiModuleTask.copyChildOutputDirectory(child: AbstractDokkaT sourceChildOutputDirectory.copyRecursively(targetChildOutputDirectory, overwrite = true) } - diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaProperty.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaProperty.kt index 18026e77..7ad63348 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaProperty.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaProperty.kt @@ -1,26 +1,6 @@ package org.jetbrains.dokka.gradle -import org.gradle.api.model.ObjectFactory -import org.gradle.api.provider.Property import org.gradle.api.provider.Provider -import org.gradle.kotlin.dsl.property -import org.jetbrains.dokka.utilities.cast -import kotlin.reflect.typeOf -internal inline fun ObjectFactory.safeProperty() = property() - -internal inline fun Property.safeConvention(value: T): Property { - return this.convention(value).cast() -} - -internal inline fun Property.safeConvention(provider: Provider): Property { - return this.convention(provider).cast() -} - -@OptIn(ExperimentalStdlibApi::class) -internal inline fun Provider.getSafe(): T = - if (typeOf().isMarkedNullable) orNull as T - else get() internal fun Provider.getValidVersionOrNull() = orNull?.takeIf { it != "unspecified" } - diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaSourceSetMapper.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaSourceSetMapper.kt index 56c3f071..0626fc59 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaSourceSetMapper.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaSourceSetMapper.kt @@ -9,28 +9,28 @@ internal fun GradleDokkaSourceSetBuilder.toDokkaSourceSetImpl(): DokkaSourceSetI displayName = displayNameOrDefault(), sourceSetID = sourceSetID, sourceRoots = sourceRoots.toSet(), - dependentSourceSets = dependentSourceSets.getSafe().toSet(), + dependentSourceSets = dependentSourceSets.get().toSet(), samples = samples.toSet(), includes = includes.toSet(), - includeNonPublic = includeNonPublic.getSafe(), - documentedVisibilities = documentedVisibilities.getSafe(), - reportUndocumented = reportUndocumented.getSafe(), - skipEmptyPackages = skipEmptyPackages.getSafe(), - skipDeprecated = skipDeprecated.getSafe(), - jdkVersion = jdkVersion.getSafe(), - sourceLinks = sourceLinks.getSafe().build().toSet(), - perPackageOptions = perPackageOptions.getSafe().build(), + includeNonPublic = includeNonPublic.get(), + documentedVisibilities = documentedVisibilities.get(), + reportUndocumented = reportUndocumented.get(), + skipEmptyPackages = skipEmptyPackages.get(), + skipDeprecated = skipDeprecated.get(), + jdkVersion = jdkVersion.get(), + sourceLinks = sourceLinks.get().build().toSet(), + perPackageOptions = perPackageOptions.get().build(), externalDocumentationLinks = externalDocumentationLinksWithDefaults(), - languageVersion = languageVersion.getSafe(), - apiVersion = apiVersion.getSafe(), - noStdlibLink = noStdlibLink.getSafe(), - noJdkLink = noJdkLink.getSafe(), + languageVersion = languageVersion.orNull, + apiVersion = apiVersion.orNull, + noStdlibLink = noStdlibLink.get(), + noJdkLink = noJdkLink.get(), suppressedFiles = suppressedFilesWithDefaults(), - analysisPlatform = platform.getSafe() + analysisPlatform = platform.get() ) private fun GradleDokkaSourceSetBuilder.displayNameOrDefault(): String { - displayName.getSafe()?.let { return it } + displayName.orNull?.let { return it } if (name.endsWith("Main") && name != "Main") { return name.removeSuffix("Main") } @@ -39,17 +39,17 @@ private fun GradleDokkaSourceSetBuilder.displayNameOrDefault(): String { } private fun GradleDokkaSourceSetBuilder.externalDocumentationLinksWithDefaults(): Set { - return externalDocumentationLinks.getSafe().build() + return externalDocumentationLinks.get().build() .run { - if (noJdkLink.getSafe()) this - else this + ExternalDocumentationLink.jdk(jdkVersion.getSafe()) + if (noJdkLink.get()) this + else this + ExternalDocumentationLink.jdk(jdkVersion.get()) } .run { - if (noStdlibLink.getSafe()) this + if (noStdlibLink.get()) this else this + ExternalDocumentationLink.kotlinStdlib() } .run { - if (noAndroidSdkLink.getSafe() || !project.isAndroidProject()) this + if (noAndroidSdkLink.get() || !project.isAndroidProject()) this else this + ExternalDocumentationLink.androidSdk() + ExternalDocumentationLink.androidX() @@ -58,7 +58,7 @@ private fun GradleDokkaSourceSetBuilder.externalDocumentationLinksWithDefaults() } private fun GradleDokkaSourceSetBuilder.suppressedFilesWithDefaults(): Set { - val suppressedGeneratedFiles = if (suppressGeneratedFiles.getSafe()) { + val suppressedGeneratedFiles = if (suppressGeneratedFiles.get()) { val generatedRoot = project.buildDir.resolve("generated").absoluteFile sourceRoots .filter { it.startsWith(generatedRoot) } diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilder.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilder.kt index deff5050..1a19d0bb 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilder.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilder.kt @@ -8,6 +8,7 @@ import org.gradle.api.provider.Property import org.gradle.api.provider.SetProperty import org.gradle.api.tasks.* import org.gradle.kotlin.dsl.listProperty +import org.gradle.kotlin.dsl.property import org.gradle.kotlin.dsl.setProperty import org.jetbrains.dokka.* import java.io.File @@ -51,8 +52,8 @@ open class GradleDokkaSourceSetBuilder( * Default is `false`. */ @Input - val suppress: Property = project.objects.safeProperty() - .safeConvention(false) + val suppress: Property = project.objects.property() + .convention(false) /** * Display name used to refer to the source set. @@ -64,7 +65,7 @@ open class GradleDokkaSourceSetBuilder( */ @Input @Optional - val displayName: Property = project.objects.safeProperty() + val displayName: Property = project.objects.property() /** * List of Markdown files that contain @@ -108,8 +109,9 @@ open class GradleDokkaSourceSetBuilder( * Default is [DokkaConfiguration.Visibility.PUBLIC]. */ @Input - val documentedVisibilities: SetProperty = project.objects.setProperty() - .convention(DokkaDefaults.documentedVisibilities) + val documentedVisibilities: SetProperty = + project.objects.setProperty() + .convention(DokkaDefaults.documentedVisibilities) /** * Specifies source sets that current source set depends on. @@ -169,8 +171,8 @@ open class GradleDokkaSourceSetBuilder( * Default is `false`. */ @Input - val reportUndocumented: Property = project.objects.safeProperty() - .safeConvention(DokkaDefaults.reportUndocumented) + val reportUndocumented: Property = project.objects.property() + .convention(DokkaDefaults.reportUndocumented) /** * Specifies the location of the project source code on the Web. If provided, Dokka generates @@ -209,8 +211,8 @@ open class GradleDokkaSourceSetBuilder( */ @Input @Optional - val platform: Property = project.objects.safeProperty() - .safeConvention(Platform.DEFAULT) + val platform: Property = project.objects.property() + .convention(Platform.DEFAULT) /** * Whether to skip packages that contain no visible declarations after @@ -222,8 +224,8 @@ open class GradleDokkaSourceSetBuilder( * Default is `true`. */ @Input - val skipEmptyPackages: Property = project.objects.safeProperty() - .safeConvention(DokkaDefaults.skipEmptyPackages) + val skipEmptyPackages: Property = project.objects.property() + .convention(DokkaDefaults.skipEmptyPackages) /** * Whether to document declarations annotated with [Deprecated]. @@ -233,8 +235,8 @@ open class GradleDokkaSourceSetBuilder( * Default is `false`. */ @Input - val skipDeprecated: Property = project.objects.safeProperty() - .safeConvention(DokkaDefaults.skipDeprecated) + val skipDeprecated: Property = project.objects.property() + .convention(DokkaDefaults.skipDeprecated) /** * Directories or individual files that should be suppressed, meaning declarations from them @@ -256,8 +258,8 @@ open class GradleDokkaSourceSetBuilder( * Default is `true`. */ @Input - val suppressGeneratedFiles: Property = project.objects.safeProperty() - .safeConvention(DokkaDefaults.suppressGeneratedFiles) + val suppressGeneratedFiles: Property = project.objects.property() + .convention(DokkaDefaults.suppressGeneratedFiles) /** * Whether to generate external documentation links that lead to API reference @@ -266,8 +268,8 @@ open class GradleDokkaSourceSetBuilder( * Default is `false`, meaning links will be generated. */ @Input - val noStdlibLink: Property = project.objects.safeProperty() - .safeConvention(DokkaDefaults.noStdlibLink) + val noStdlibLink: Property = project.objects.property() + .convention(DokkaDefaults.noStdlibLink) /** * Whether to generate external documentation links to JDK's Javadocs @@ -278,8 +280,8 @@ open class GradleDokkaSourceSetBuilder( * Default is `false`, meaning links will be generated. */ @Input - val noJdkLink: Property = project.objects.safeProperty() - .safeConvention(DokkaDefaults.noJdkLink) + val noJdkLink: Property = project.objects.property() + .convention(DokkaDefaults.noJdkLink) /** * Whether to generate external documentation links for Android SDK API reference @@ -290,8 +292,8 @@ open class GradleDokkaSourceSetBuilder( * Default is `false`, meaning links will be generated. */ @Input - val noAndroidSdkLink: Property = project.objects.safeProperty() - .safeConvention(DokkaDefaults.noAndroidSdkLink) + val noAndroidSdkLink: Property = project.objects.property() + .convention(DokkaDefaults.noAndroidSdkLink) /** * [Kotlin language version](https://kotlinlang.org/docs/compatibility-modes.html) @@ -302,7 +304,7 @@ open class GradleDokkaSourceSetBuilder( */ @Input @Optional - val languageVersion: Property = project.objects.safeProperty() + val languageVersion: Property = project.objects.property() /** * [Kotlin API version](https://kotlinlang.org/docs/compatibility-modes.html) @@ -313,7 +315,7 @@ open class GradleDokkaSourceSetBuilder( */ @Input @Optional - val apiVersion: Property = project.objects.safeProperty() + val apiVersion: Property = project.objects.property() /** * JDK version to use when generating external documentation links for Java types. @@ -325,15 +327,15 @@ open class GradleDokkaSourceSetBuilder( * Default is JDK 8. */ @Input - val jdkVersion: Property = project.objects.safeProperty() - .safeConvention(DokkaDefaults.jdkVersion) + val jdkVersion: Property = project.objects.property() + .convention(DokkaDefaults.jdkVersion) /** * Deprecated. Use [documentedVisibilities] instead. */ @Input - val includeNonPublic: Property = project.objects.safeProperty() - .safeConvention(DokkaDefaults.includeNonPublic) + val includeNonPublic: Property = project.objects.property() + .convention(DokkaDefaults.includeNonPublic) fun DokkaSourceSetID(sourceSetName: String): DokkaSourceSetID = sourceSetIdFactory.create(sourceSetName) diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleExternalDocumentationLinkBuilder.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleExternalDocumentationLinkBuilder.kt index 36e4f81d..ff347e66 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleExternalDocumentationLinkBuilder.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleExternalDocumentationLinkBuilder.kt @@ -5,6 +5,7 @@ import org.gradle.api.provider.Property import org.gradle.api.tasks.Input import org.gradle.api.tasks.Internal import org.gradle.api.tasks.Optional +import org.gradle.kotlin.dsl.property import org.jetbrains.dokka.DokkaConfigurationBuilder import org.jetbrains.dokka.ExternalDocumentationLink import org.jetbrains.dokka.ExternalDocumentationLinkImpl @@ -52,7 +53,7 @@ class GradleExternalDocumentationLinkBuilder( * ``` */ @Input - val url: Property = project.objects.safeProperty() + val url: Property = project.objects.property() /** * Specifies the exact location of a `package-list` instead of relying on Dokka @@ -66,10 +67,10 @@ class GradleExternalDocumentationLinkBuilder( */ @Optional @Input - val packageListUrl: Property = project.objects.safeProperty() + val packageListUrl: Property = project.objects.property() override fun build(): ExternalDocumentationLinkImpl = ExternalDocumentationLink( - url = checkNotNull(url.getSafe()) { "url not specified " }, - packageListUrl = packageListUrl.getSafe() + url = checkNotNull(url.get()) { "url not specified " }, + packageListUrl = packageListUrl.orNull, ) } diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradlePackageOptionsBuilder.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradlePackageOptionsBuilder.kt index 4e53cf81..c853181d 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradlePackageOptionsBuilder.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradlePackageOptionsBuilder.kt @@ -7,7 +7,7 @@ import org.gradle.api.provider.Property import org.gradle.api.provider.SetProperty import org.gradle.api.tasks.Input import org.gradle.api.tasks.Internal -import org.gradle.kotlin.dsl.setProperty +import org.gradle.kotlin.dsl.* import org.jetbrains.dokka.DokkaConfiguration import org.jetbrains.dokka.DokkaConfigurationBuilder import org.jetbrains.dokka.DokkaDefaults @@ -40,8 +40,8 @@ class GradlePackageOptionsBuilder( * Default is any string: `.*`. */ @Input - val matchingRegex: Property = project.objects.safeProperty() - .safeConvention(".*") + val matchingRegex: Property = project.objects.property() + .convention(".*") /** * Whether this package should be skipped when generating documentation. @@ -49,8 +49,8 @@ class GradlePackageOptionsBuilder( * Default is `false`. */ @Input - val suppress: Property = project.objects.safeProperty() - .safeConvention(DokkaDefaults.suppress) + val suppress: Property = project.objects.property() + .convention(DokkaDefaults.suppress) /** * Set of visibility modifiers that should be documented. @@ -63,8 +63,9 @@ class GradlePackageOptionsBuilder( * Default is [DokkaConfiguration.Visibility.PUBLIC]. */ @Input - val documentedVisibilities: SetProperty = project.objects.setProperty() - .convention(DokkaDefaults.documentedVisibilities) + val documentedVisibilities: SetProperty = + project.objects.setProperty() + .convention(DokkaDefaults.documentedVisibilities) /** * Whether to document declarations annotated with [Deprecated]. @@ -74,8 +75,8 @@ class GradlePackageOptionsBuilder( * Default is `false`. */ @Input - val skipDeprecated: Property = project.objects.safeProperty() - .safeConvention(DokkaDefaults.skipDeprecated) + val skipDeprecated: Property = project.objects.property() + .convention(DokkaDefaults.skipDeprecated) /** * Whether to emit warnings about visible undocumented declarations, that is declarations from @@ -88,23 +89,23 @@ class GradlePackageOptionsBuilder( * Default is `false`. */ @Input - val reportUndocumented: Property = project.objects.safeProperty() - .safeConvention(DokkaDefaults.reportUndocumented) + val reportUndocumented: Property = project.objects.property() + .convention(DokkaDefaults.reportUndocumented) /** * Deprecated. Use [documentedVisibilities] instead. */ @Input - val includeNonPublic: Property = project.objects.safeProperty() - .safeConvention(DokkaDefaults.includeNonPublic) + val includeNonPublic: Property = project.objects.property() + .convention(DokkaDefaults.includeNonPublic) override fun build(): PackageOptionsImpl = PackageOptionsImpl( - matchingRegex = checkNotNull(matchingRegex.getSafe()) { "prefix not specified" }, - includeNonPublic = includeNonPublic.getSafe(), - documentedVisibilities = documentedVisibilities.getSafe(), - reportUndocumented = reportUndocumented.getSafe(), - skipDeprecated = skipDeprecated.getSafe(), - suppress = suppress.getSafe() + matchingRegex = matchingRegex.get(), + includeNonPublic = includeNonPublic.get(), + documentedVisibilities = documentedVisibilities.get(), + reportUndocumented = reportUndocumented.get(), + skipDeprecated = skipDeprecated.get(), + suppress = suppress.get() ) } diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleSourceLinkBuilder.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleSourceLinkBuilder.kt index b307796d..4b992ae9 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleSourceLinkBuilder.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleSourceLinkBuilder.kt @@ -4,6 +4,7 @@ import org.gradle.api.Project import org.gradle.api.provider.Property import org.gradle.api.provider.Provider import org.gradle.api.tasks.* +import org.gradle.kotlin.dsl.property import org.jetbrains.dokka.DokkaConfigurationBuilder import org.jetbrains.dokka.SourceLinkDefinitionImpl import java.io.File @@ -42,8 +43,8 @@ class GradleSourceLinkBuilder( * ``` */ @Internal // changing contents of the directory should not invalidate the task - val localDirectory: Property = project.objects.safeProperty() - + val localDirectory: Property = project.objects.property() + /** * The relative path to [localDirectory] from the project directory. Declared as an input to invalidate the task if that path changes. * Should not be used anywhere directly. @@ -65,7 +66,7 @@ class GradleSourceLinkBuilder( * ``` */ @Input - val remoteUrl: Property = project.objects.safeProperty() + val remoteUrl: Property = project.objects.property() /** * Suffix used to append source code line number to the URL. This will help readers navigate @@ -84,14 +85,14 @@ class GradleSourceLinkBuilder( */ @Optional @Input - val remoteLineSuffix: Property = project.objects.safeProperty() - .safeConvention("#L") + val remoteLineSuffix: Property = project.objects.property() + .convention("#L") override fun build(): SourceLinkDefinitionImpl { return SourceLinkDefinitionImpl( - localDirectory = localDirectory.getSafe()?.canonicalPath ?: project.projectDir.canonicalPath, - remoteUrl = checkNotNull(remoteUrl.getSafe()) { "missing remoteUrl on source link" }, - remoteLineSuffix = remoteLineSuffix.getSafe() + localDirectory = localDirectory.orNull?.canonicalPath ?: project.projectDir.canonicalPath, + remoteUrl = remoteUrl.get(), + remoteLineSuffix = remoteLineSuffix.get(), ) } } diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/checkDependentSourceSets.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/checkDependentSourceSets.kt index 989ad10a..eeb48c00 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/checkDependentSourceSets.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/checkDependentSourceSets.kt @@ -8,12 +8,12 @@ internal fun checkSourceSetDependencies(sourceSets: List) { sourceSets.values.forEach { sourceSet -> - sourceSet.dependentSourceSets.getSafe().forEach { dependentSourceSetID -> + sourceSet.dependentSourceSets.get().forEach { dependentSourceSetID -> val dependentSourceSet = requireNotNull(sourceSets[dependentSourceSetID]) { "Dokka source set \"${sourceSet.name}\": Cannot find dependent source set \"$dependentSourceSetID\"" } - if (sourceSet.suppress.getSafe().not() && dependentSourceSet.suppress.getSafe()) { + if (sourceSet.suppress.get().not() && dependentSourceSet.suppress.get()) { throw IllegalArgumentException( "Dokka source set: \"${sourceSet.name}\": " + "Unsuppressed source set cannot depend on suppressed source set \"$dependentSourceSetID\"" diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/tasks/AbstractDokkaLeafTask.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/tasks/AbstractDokkaLeafTask.kt index f24df017..18e159c6 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/tasks/AbstractDokkaLeafTask.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/tasks/AbstractDokkaLeafTask.kt @@ -33,5 +33,5 @@ abstract class AbstractDokkaLeafTask : AbstractDokkaTask() { get() = dokkaSourceSets .toList() .also(::checkSourceSetDependencies) - .filterNot { it.suppress.getSafe() } + .filterNot { it.suppress.get() } } diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/tasks/AbstractDokkaTask.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/tasks/AbstractDokkaTask.kt index e5d42ffa..b817e51d 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/tasks/AbstractDokkaTask.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/tasks/AbstractDokkaTask.kt @@ -14,6 +14,7 @@ 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.gradle.kotlin.dsl.property import org.gradle.work.DisableCachingByDefault import org.jetbrains.dokka.* import org.jetbrains.dokka.plugability.ConfigurableBlock @@ -33,8 +34,8 @@ abstract class AbstractDokkaTask : DefaultTask() { * Default is Gradle project name. */ @Input - val moduleName: Property = project.objects.safeProperty() - .safeConvention(project.name) + val moduleName: Property = project.objects.property() + .convention(project.name) /** * Module version. @@ -45,8 +46,8 @@ abstract class AbstractDokkaTask : DefaultTask() { * Default is Gradle project version. */ @Input - val moduleVersion: Property = project.objects.safeProperty() - .safeConvention(project.provider { project.version.toString() }) + val moduleVersion: Property = project.objects.property() + .convention(project.provider { project.version.toString() }) /** * Directory to which documentation will be generated, regardless of format. @@ -56,8 +57,8 @@ abstract class AbstractDokkaTask : DefaultTask() { * for `dokkaHtmlMultiModule` task it will be `project/buildDir/htmlMultiModule` */ @OutputDirectory - val outputDirectory: Property = project.objects.safeProperty() - .safeConvention(project.provider { defaultDokkaOutputDirectory() }) + val outputDirectory: Property = project.objects.property() + .convention(project.provider { defaultDokkaOutputDirectory() }) /** * Configuration for Dokka plugins. This property is not expected to be used directly - if possible, use @@ -103,8 +104,8 @@ abstract class AbstractDokkaTask : DefaultTask() { * Default is `true` */ @Input - val suppressObviousFunctions: Property = project.objects.safeProperty() - .safeConvention(DokkaDefaults.suppressObviousFunctions) + val suppressObviousFunctions: Property = project.objects.property() + .convention(DokkaDefaults.suppressObviousFunctions) /** * Whether to suppress inherited members that aren't explicitly overridden in a given class. @@ -116,8 +117,8 @@ abstract class AbstractDokkaTask : DefaultTask() { * Default is `false`. */ @Input - val suppressInheritedMembers: Property = project.objects.safeProperty() - .safeConvention(DokkaDefaults.suppressInheritedMembers) + val suppressInheritedMembers: Property = project.objects.property() + .convention(DokkaDefaults.suppressInheritedMembers) /** * Whether to resolve remote files/links over network. @@ -135,8 +136,8 @@ abstract class AbstractDokkaTask : DefaultTask() { * Default is `false`. */ @Input - val offlineMode: Property = project.objects.safeProperty() - .safeConvention(DokkaDefaults.offlineMode) + val offlineMode: Property = project.objects.property() + .convention(DokkaDefaults.offlineMode) /** * Whether to fail documentation generation if Dokka has emitted a warning or an error. @@ -147,13 +148,13 @@ abstract class AbstractDokkaTask : DefaultTask() { * Default is `false`. */ @Input - val failOnWarning: Property = project.objects.safeProperty() - .safeConvention(DokkaDefaults.failOnWarning) + val failOnWarning: Property = project.objects.property() + .convention(DokkaDefaults.failOnWarning) @Optional @InputDirectory @PathSensitive(PathSensitivity.RELATIVE) - val cacheRoot: Property = project.objects.safeProperty() + val cacheRoot: Property = project.objects.property() /** * Type-safe configuration for a Dokka plugin. @@ -231,13 +232,13 @@ abstract class AbstractDokkaTask : DefaultTask() { } internal fun buildPluginsConfiguration(): List { - val manuallyConfigured = pluginsMapConfiguration.getSafe().entries.map { entry -> + val manuallyConfigured = pluginsMapConfiguration.get().entries.map { entry -> PluginConfigurationImpl( entry.key, DokkaConfiguration.SerializationFormat.JSON, entry.value ) } - return pluginsConfiguration.getSafe().mapNotNull { it as? PluginConfigurationImpl } + manuallyConfigured + return pluginsConfiguration.get().mapNotNull { it as? PluginConfigurationImpl } + manuallyConfigured } } diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/tasks/DokkaCollectorTask.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/tasks/DokkaCollectorTask.kt index 38f4017a..096dace5 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/tasks/DokkaCollectorTask.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/tasks/DokkaCollectorTask.kt @@ -15,15 +15,15 @@ abstract class DokkaCollectorTask : AbstractDokkaParentTask() { override fun buildDokkaConfiguration(): DokkaConfigurationImpl { val initialDokkaConfiguration = DokkaConfigurationImpl( - moduleName = moduleName.getSafe(), - outputDir = outputDirectory.getSafe(), - cacheRoot = cacheRoot.getSafe(), - failOnWarning = failOnWarning.getSafe(), - offlineMode = offlineMode.getSafe(), + moduleName = moduleName.get(), + outputDir = outputDirectory.get(), + cacheRoot = cacheRoot.orNull, + failOnWarning = failOnWarning.get(), + offlineMode = offlineMode.get(), pluginsClasspath = plugins.resolve().toList(), pluginsConfiguration = buildPluginsConfiguration(), - suppressObviousFunctions = suppressObviousFunctions.getSafe(), - suppressInheritedMembers = suppressInheritedMembers.getSafe(), + suppressObviousFunctions = suppressObviousFunctions.get(), + suppressInheritedMembers = suppressInheritedMembers.get(), ) val subprojectDokkaConfigurations = childDokkaTasks.map { dokkaTask -> dokkaTask.buildDokkaConfiguration() } diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/tasks/DokkaMultiModuleTask.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/tasks/DokkaMultiModuleTask.kt index 190dc6df..1b61d57e 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/tasks/DokkaMultiModuleTask.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/tasks/DokkaMultiModuleTask.kt @@ -6,6 +6,7 @@ import org.gradle.api.file.ConfigurableFileCollection import org.gradle.api.internal.tasks.TaskDependencyInternal import org.gradle.api.provider.Property import org.gradle.api.tasks.* +import org.gradle.kotlin.dsl.property import org.jetbrains.dokka.DokkaConfigurationImpl import org.jetbrains.dokka.DokkaModuleDescriptionImpl import java.io.File @@ -51,13 +52,13 @@ abstract class DokkaMultiModuleTask : AbstractDokkaParentTask() { val includes: ConfigurableFileCollection = project.files() @Internal - val fileLayout: Property = project.objects.safeProperty() - .safeConvention(DokkaMultiModuleFileLayout.CompactInParent) + val fileLayout: Property = project.objects.property() + .convention(DokkaMultiModuleFileLayout.CompactInParent) @get:InputFiles @get:PathSensitive(PathSensitivity.RELATIVE) internal val sourceChildOutputDirectories: Iterable - get() = childDokkaTasks.map { task -> task.outputDirectory.getSafe() } + get() = childDokkaTasks.map { task -> task.outputDirectory.get() } @get:OutputDirectories internal val targetChildOutputDirectories: Iterable @@ -83,20 +84,20 @@ abstract class DokkaMultiModuleTask : AbstractDokkaParentTask() { } override fun buildDokkaConfiguration(): DokkaConfigurationImpl = DokkaConfigurationImpl( - moduleName = moduleName.getSafe(), + moduleName = moduleName.get(), moduleVersion = moduleVersion.getValidVersionOrNull(), - outputDir = outputDirectory.getSafe(), - cacheRoot = cacheRoot.getSafe(), + outputDir = outputDirectory.get(), + cacheRoot = cacheRoot.orNull, pluginsConfiguration = buildPluginsConfiguration(), - failOnWarning = failOnWarning.getSafe(), - offlineMode = offlineMode.getSafe(), + failOnWarning = failOnWarning.get(), + offlineMode = offlineMode.get(), pluginsClasspath = plugins.resolve().toList(), modules = childDokkaTasks.map { dokkaTask -> DokkaModuleDescriptionImpl( - name = dokkaTask.moduleName.getSafe(), - relativePathToOutputDirectory = targetChildOutputDirectory(dokkaTask).relativeTo(outputDirectory.getSafe()), + name = dokkaTask.moduleName.get(), + relativePathToOutputDirectory = targetChildOutputDirectory(dokkaTask).relativeTo(outputDirectory.get()), includes = childDokkaTaskIncludes[dokkaTask.path].orEmpty(), - sourceOutputDirectory = dokkaTask.outputDirectory.getSafe() + sourceOutputDirectory = dokkaTask.outputDirectory.get() ) }, includes = includes.toSet(), diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/tasks/DokkaTask.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/tasks/DokkaTask.kt index 102ae336..46c59e95 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/tasks/DokkaTask.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/tasks/DokkaTask.kt @@ -10,16 +10,16 @@ import org.gradle.api.tasks.* abstract class DokkaTask : AbstractDokkaLeafTask() { override fun buildDokkaConfiguration(): DokkaConfigurationImpl = DokkaConfigurationImpl( - moduleName = moduleName.getSafe(), + moduleName = moduleName.get(), moduleVersion = moduleVersion.getValidVersionOrNull(), - outputDir = outputDirectory.getSafe(), - cacheRoot = cacheRoot.getSafe(), - offlineMode = offlineMode.getSafe(), - failOnWarning = failOnWarning.getSafe(), + outputDir = outputDirectory.get(), + cacheRoot = cacheRoot.orNull, + offlineMode = offlineMode.get(), + failOnWarning = failOnWarning.get(), sourceSets = unsuppressedSourceSets.build(), pluginsConfiguration = buildPluginsConfiguration(), pluginsClasspath = plugins.resolve().toList(), - suppressObviousFunctions = suppressObviousFunctions.getSafe(), - suppressInheritedMembers = suppressInheritedMembers.getSafe(), + suppressObviousFunctions = suppressObviousFunctions.get(), + suppressInheritedMembers = suppressInheritedMembers.get(), ) } diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/tasks/DokkaTaskPartial.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/tasks/DokkaTaskPartial.kt index 14c6576c..8431f1df 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/tasks/DokkaTaskPartial.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/tasks/DokkaTaskPartial.kt @@ -11,18 +11,18 @@ abstract class DokkaTaskPartial : AbstractDokkaLeafTask() { override fun buildDokkaConfiguration(): DokkaConfigurationImpl { return DokkaConfigurationImpl( - moduleName = moduleName.getSafe(), + moduleName = moduleName.get(), moduleVersion = moduleVersion.orNull, - outputDir = outputDirectory.getSafe(), - cacheRoot = cacheRoot.getSafe(), - offlineMode = offlineMode.getSafe(), - failOnWarning = failOnWarning.getSafe(), + outputDir = outputDirectory.get(), + cacheRoot = cacheRoot.orNull, + offlineMode = offlineMode.get(), + failOnWarning = failOnWarning.get(), sourceSets = unsuppressedSourceSets.build(), pluginsConfiguration = buildPluginsConfiguration(), pluginsClasspath = plugins.resolve().toList(), delayTemplateSubstitution = true, - suppressObviousFunctions = suppressObviousFunctions.getSafe(), - suppressInheritedMembers = suppressInheritedMembers.getSafe(), + suppressObviousFunctions = suppressObviousFunctions.get(), + suppressInheritedMembers = suppressInheritedMembers.get(), ) } } -- cgit