diff options
author | sebastian.sellmair <sebastian.sellmair@jetbrains.com> | 2020-08-27 15:50:40 +0200 |
---|---|---|
committer | Sebastian Sellmair <34319766+sellmair@users.noreply.github.com> | 2020-08-31 15:10:04 +0200 |
commit | 8cd28416817dfd7d28bb66b28e849d97cc09012b (patch) | |
tree | 962f9420f3ccdb47d6847c9e5a16d00018c9110c /runners/gradle-plugin/src/main | |
parent | 732d181e4908ed0ddc513e305addc71560c0e109 (diff) | |
download | dokka-8cd28416817dfd7d28bb66b28e849d97cc09012b.tar.gz dokka-8cd28416817dfd7d28bb66b28e849d97cc09012b.tar.bz2 dokka-8cd28416817dfd7d28bb66b28e849d97cc09012b.zip |
Let module name be configurable withing `AbstractDokkaTask` and remove concept of `moduleDisplayName`
Diffstat (limited to 'runners/gradle-plugin/src/main')
9 files changed, 52 insertions, 43 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 89308e2a..b4800124 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 @@ -24,6 +24,10 @@ abstract class AbstractDokkaTask( private val bootstrapClass: KClass<out DokkaBootstrap> = DokkaBootstrap::class ) : DefaultTask() { + @Input + val moduleName: Property<String> = project.objects.safeProperty<String>() + .safeConvention(project.name) + @OutputDirectory val outputDirectory: Property<File> = project.objects.safeProperty<File>() .safeConvention(defaultDokkaOutputDirectory()) 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 532e9e84..cd53398a 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 @@ -11,6 +11,7 @@ abstract class DokkaCollectorTask : AbstractDokkaParentTask() { override fun buildDokkaConfiguration(): DokkaConfigurationImpl { val initialDokkaConfiguration = DokkaConfigurationImpl( + moduleName = moduleName.getSafe(), outputDir = outputDirectory.getSafe(), cacheRoot = cacheRoot.getSafe(), failOnWarning = failOnWarning.getSafe(), 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 2e7b7490..82e2148f 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 @@ -3,6 +3,8 @@ package org.jetbrains.dokka.gradle import org.gradle.api.internal.tasks.TaskDependencyInternal import org.gradle.api.provider.Property import org.gradle.api.tasks.* +import org.jetbrains.dokka.DokkaConfiguration +import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet import org.jetbrains.dokka.DokkaConfigurationImpl import org.jetbrains.dokka.DokkaModuleDescriptionImpl import org.jetbrains.dokka.DokkaMultimoduleBootstrapImpl @@ -51,6 +53,7 @@ abstract class DokkaMultiModuleTask : AbstractDokkaParentTask(DokkaMultimoduleBo } override fun buildDokkaConfiguration(): DokkaConfigurationImpl = DokkaConfigurationImpl( + moduleName = moduleName.getSafe(), outputDir = outputDirectory.getSafe(), cacheRoot = cacheRoot.getSafe(), pluginsConfiguration = pluginsConfiguration.getSafe(), @@ -67,4 +70,3 @@ abstract class DokkaMultiModuleTask : AbstractDokkaParentTask(DokkaMultimoduleBo ) } - 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 d07873d8..beec3a7e 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 @@ -12,7 +12,7 @@ abstract class DokkaTask : AbstractDokkaTask(DokkaBootstrapImpl::class) { @get:Internal val dokkaSourceSets: NamedDomainObjectContainer<GradleDokkaSourceSetBuilder> = - project.container(GradleDokkaSourceSetBuilder::class.java, GradleDokkaSourceSetBuilderFactory()) + project.container(GradleDokkaSourceSetBuilder::class.java, gradleDokkaSourceSetBuilderFactory()) .also { container -> DslObject(this).extensions.add("dokkaSourceSets", container) project.kotlinOrNull?.sourceSets?.all { kotlinSourceSet -> @@ -36,6 +36,7 @@ abstract class DokkaTask : AbstractDokkaTask(DokkaBootstrapImpl::class) { override fun buildDokkaConfiguration(): DokkaConfigurationImpl { return DokkaConfigurationImpl( + moduleName = moduleName.getSafe(), outputDir = outputDirectory.getSafe(), cacheRoot = cacheRoot.getSafe(), offlineMode = offlineMode.getSafe(), 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 bb44eb52..d3a6c587 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 @@ -1,12 +1,10 @@ @file:Suppress("FunctionName", "UnstableApiUsage") +@file:JvmName("GradleDokkaSourceSetBuilderKt") package org.jetbrains.dokka.gradle -import com.android.build.gradle.api.AndroidSourceSet import groovy.lang.Closure -import org.gradle.api.Action -import org.gradle.api.Project -import org.gradle.api.Task +import org.gradle.api.* import org.gradle.api.file.ConfigurableFileCollection import org.gradle.api.provider.ListProperty import org.gradle.api.provider.Property @@ -16,21 +14,17 @@ import org.gradle.kotlin.dsl.listProperty import org.gradle.kotlin.dsl.setProperty import org.gradle.util.ConfigureUtil import org.jetbrains.dokka.* -import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet import java.io.File import java.net.URL -internal fun Task.GradleDokkaSourceSetBuilderFactory(): (name: String) -> GradleDokkaSourceSetBuilder = - { name -> GradleDokkaSourceSetBuilder(name, project) } - - -open class GradleDokkaSourceSetBuilder constructor( +open class GradleDokkaSourceSetBuilder( @Transient @get:Input val name: String, - @Transient @get:Internal internal val project: Project + @Transient @get:Internal internal val project: Project, + @Transient @get:Internal internal val sourceSetIdFactory: NamedDomainObjectFactory<DokkaSourceSetID>, ) : DokkaConfigurationBuilder<DokkaSourceSetImpl> { - @Internal - val sourceSetID: DokkaSourceSetID = DokkaSourceSetID(project, name) + @Input + val sourceSetID: DokkaSourceSetID = sourceSetIdFactory.create(name) @Input val suppress: Property<Boolean> = project.objects.safeProperty<Boolean>() @@ -42,10 +36,6 @@ open class GradleDokkaSourceSetBuilder constructor( @Input @Optional - val moduleDisplayName: Property<String?> = project.objects.safeProperty() - - @Input - @Optional val displayName: Property<String?> = project.objects.safeProperty() @InputFiles @@ -125,9 +115,7 @@ open class GradleDokkaSourceSetBuilder constructor( val platform: Property<Platform> = project.objects.safeProperty<Platform>() .safeConvention(Platform.DEFAULT) - fun DokkaSourceSetID(sourceSetName: String): DokkaSourceSetID = - DokkaSourceSetID(project, sourceSetName) - + fun DokkaSourceSetID(sourceSetName: String): DokkaSourceSetID = sourceSetIdFactory.create(sourceSetName) fun dependsOn(sourceSet: SourceSet) { dependsOn(DokkaSourceSetID(sourceSet.name)) @@ -208,15 +196,3 @@ open class GradleDokkaSourceSetBuilder constructor( override fun build(): DokkaSourceSetImpl = toDokkaSourceSetImpl() } - -fun GradleDokkaSourceSetBuilder.dependsOn(sourceSet: KotlinSourceSet) { - dependsOn(DokkaSourceSetID(sourceSet.name)) -} - -fun GradleDokkaSourceSetBuilder.dependsOn(sourceSet: AndroidSourceSet) { - dependsOn(DokkaSourceSetID(sourceSet.name)) -} - -fun GradleDokkaSourceSetBuilder.kotlinSourceSet(kotlinSourceSet: KotlinSourceSet) { - configureWithKotlinSourceSet(kotlinSourceSet) -} diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilderExtensions.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilderExtensions.kt new file mode 100644 index 00000000..c5c7428f --- /dev/null +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilderExtensions.kt @@ -0,0 +1,17 @@ +package org.jetbrains.dokka.gradle + +import com.android.build.gradle.api.AndroidSourceSet +import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet + +fun GradleDokkaSourceSetBuilder.dependsOn(sourceSet: KotlinSourceSet) { + dependsOn(DokkaSourceSetID(sourceSet.name)) +} + +fun GradleDokkaSourceSetBuilder.dependsOn(sourceSet: AndroidSourceSet) { + dependsOn(DokkaSourceSetID(sourceSet.name)) +} + +fun GradleDokkaSourceSetBuilder.kotlinSourceSet(kotlinSourceSet: KotlinSourceSet) { + configureWithKotlinSourceSet(kotlinSourceSet) +} + diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilderFactory.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilderFactory.kt new file mode 100644 index 00000000..49c489c7 --- /dev/null +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilderFactory.kt @@ -0,0 +1,9 @@ +package org.jetbrains.dokka.gradle + +import org.gradle.api.NamedDomainObjectFactory +import org.gradle.api.Task + +@Suppress("ObjectLiteralToLambda") // Will fail at runtime in Gradle versions <= 6.6 +fun AbstractDokkaTask.gradleDokkaSourceSetBuilderFactory(): NamedDomainObjectFactory<GradleDokkaSourceSetBuilder> = + NamedDomainObjectFactory { name -> GradleDokkaSourceSetBuilder(name, project, DokkaSourceSetIdFactory()) } + diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/dokkaSourceSetIDFactory.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/dokkaSourceSetIDFactory.kt index 3fadb4fd..41cc19e3 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/dokkaSourceSetIDFactory.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/dokkaSourceSetIDFactory.kt @@ -2,9 +2,14 @@ package org.jetbrains.dokka.gradle -import org.gradle.api.Project +import org.gradle.api.NamedDomainObjectFactory +import org.gradle.api.Task import org.jetbrains.dokka.DokkaSourceSetID -internal fun DokkaSourceSetID(project: Project, sourceSetName: String): DokkaSourceSetID { - return DokkaSourceSetID(moduleName = project.path, sourceSetName = sourceSetName) +internal fun DokkaSourceSetID(task: Task, sourceSetName: String): DokkaSourceSetID { + return DokkaSourceSetID(task.path, sourceSetName) +} + +internal fun Task.DokkaSourceSetIdFactory() = NamedDomainObjectFactory<DokkaSourceSetID> { name -> + DokkaSourceSetID(this@DokkaSourceSetIdFactory, name) } diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/toDokkaSourceSetImpl.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/toDokkaSourceSetImpl.kt index 0f9d4053..2813d04e 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/toDokkaSourceSetImpl.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/toDokkaSourceSetImpl.kt @@ -6,7 +6,6 @@ import java.io.File internal fun GradleDokkaSourceSetBuilder.toDokkaSourceSetImpl(): DokkaSourceSetImpl = DokkaSourceSetImpl( classpath = classpath.toList(), - moduleDisplayName = moduleNameOrDefault(), displayName = displayNameOrDefault(), sourceSetID = sourceSetID, sourceRoots = sourceRoots.toSet(), @@ -29,11 +28,6 @@ internal fun GradleDokkaSourceSetBuilder.toDokkaSourceSetImpl(): DokkaSourceSetI analysisPlatform = platform.getSafe() ) - -private fun GradleDokkaSourceSetBuilder.moduleNameOrDefault(): String { - return moduleDisplayName.getSafe() ?: project.name -} - private fun GradleDokkaSourceSetBuilder.displayNameOrDefault(): String { displayName.getSafe()?.let { return it } if (name.endsWith("Main") && name != "Main") { |