aboutsummaryrefslogtreecommitdiff
path: root/runners/gradle-plugin
diff options
context:
space:
mode:
authorsebastian.sellmair <sebastian.sellmair@jetbrains.com>2020-08-27 15:50:40 +0200
committerSebastian Sellmair <34319766+sellmair@users.noreply.github.com>2020-08-31 15:10:04 +0200
commit8cd28416817dfd7d28bb66b28e849d97cc09012b (patch)
tree962f9420f3ccdb47d6847c9e5a16d00018c9110c /runners/gradle-plugin
parent732d181e4908ed0ddc513e305addc71560c0e109 (diff)
downloaddokka-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')
-rw-r--r--runners/gradle-plugin/MIGRATION.md2
-rw-r--r--runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/AbstractDokkaTask.kt4
-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.kt4
-rw-r--r--runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaTask.kt3
-rw-r--r--runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilder.kt40
-rw-r--r--runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilderExtensions.kt17
-rw-r--r--runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilderFactory.kt9
-rw-r--r--runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/dokkaSourceSetIDFactory.kt11
-rw-r--r--runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/toDokkaSourceSetImpl.kt6
-rw-r--r--runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/ConfigureWithKotlinSourceSetGistTest.kt2
-rw-r--r--runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaCollectorTaskTest.kt2
-rw-r--r--runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaConfigurationJsonTest.kt1
-rw-r--r--runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaConfigurationSerializableTest.kt1
-rw-r--r--runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaMultiModuleTaskTest.kt2
-rw-r--r--runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilder.kt11
-rw-r--r--runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilderTest.kt39
-rw-r--r--runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/KotlinDslDokkaTaskConfigurationTest.kt6
18 files changed, 82 insertions, 79 deletions
diff --git a/runners/gradle-plugin/MIGRATION.md b/runners/gradle-plugin/MIGRATION.md
index 555ce66e..527c3e66 100644
--- a/runners/gradle-plugin/MIGRATION.md
+++ b/runners/gradle-plugin/MIGRATION.md
@@ -68,7 +68,7 @@ tasks.dokkaHtml.configure {
#### Properties
```kotlin
/* 0.10.x */ moduleName = "myModule"
-/* 1.4.x */ moduleDisplayName.set("myModule")
+/* 1.4.x */ /* Use AbstractDokkaTask#moduleName instead */
/* 0.10.x */ includeNonPublic = false
/* 1.4.x */ includeNonPublic.set(false)
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") {
diff --git a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/ConfigureWithKotlinSourceSetGistTest.kt b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/ConfigureWithKotlinSourceSetGistTest.kt
index efe03c56..c06a3992 100644
--- a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/ConfigureWithKotlinSourceSetGistTest.kt
+++ b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/ConfigureWithKotlinSourceSetGistTest.kt
@@ -1,9 +1,7 @@
package org.jetbrains.dokka.gradle
import org.gradle.api.artifacts.FileCollectionDependency
-import org.gradle.api.file.ConfigurableFileCollection
import org.gradle.kotlin.dsl.get
-import org.gradle.kotlin.dsl.property
import org.gradle.testfixtures.ProjectBuilder
import org.jetbrains.dokka.Platform
import org.jetbrains.dokka.gradle.kotlin.KotlinSourceSetGist
diff --git a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaCollectorTaskTest.kt b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaCollectorTaskTest.kt
index 04dd1eed..6e9bef38 100644
--- a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaCollectorTaskTest.kt
+++ b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaCollectorTaskTest.kt
@@ -33,6 +33,7 @@ class DokkaCollectorTaskTest {
val collectorTasks = rootProject.tasks.withType<DokkaCollectorTask>()
collectorTasks.configureEach { task ->
+ task.moduleName by "custom Module Name"
task.outputDirectory by File("customOutputDirectory")
task.cacheRoot by File("customCacheRoot")
task.failOnWarning by true
@@ -45,6 +46,7 @@ class DokkaCollectorTaskTest {
val dokkaConfiguration = task.buildDokkaConfiguration()
assertEquals(
DokkaConfigurationImpl(
+ moduleName = "custom Module Name",
outputDir = File("customOutputDirectory"),
cacheRoot = File("customCacheRoot"),
failOnWarning = true,
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 29532877..d1bfb0e1 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
@@ -28,7 +28,6 @@ class DokkaConfigurationJsonTest {
this.pluginsConfiguration.put("0", "a")
this.pluginsConfiguration.put("1", "b")
this.dokkaSourceSets.create("main") { sourceSet ->
- sourceSet.moduleDisplayName by "moduleDisplayName"
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 f22a5b8c..99fca12d 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
@@ -35,7 +35,6 @@ class DokkaConfigurationSerializableTest {
this.pluginsConfiguration.put("0", "a")
this.pluginsConfiguration.put("1", "b")
this.dokkaSourceSets.create("main") { sourceSet ->
- sourceSet.moduleDisplayName by "moduleDisplayName"
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 62c867ba..5b9413c8 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
@@ -58,6 +58,7 @@ class DokkaMultiModuleTaskTest {
assertTrue(multimoduleTasks.isNotEmpty(), "Expected at least one multimodule task")
multimoduleTasks.configureEach { task ->
+ task.moduleName by "custom Module Name"
task.documentationFileName by "customDocumentationFileName.md"
task.outputDirectory by task.project.buildDir.resolve("customOutputDirectory")
task.cacheRoot by File("customCacheRoot")
@@ -70,6 +71,7 @@ class DokkaMultiModuleTaskTest {
val dokkaConfiguration = task.buildDokkaConfiguration()
assertEquals(
DokkaConfigurationImpl(
+ moduleName = "custom Module Name",
outputDir = task.project.buildDir.resolve("customOutputDirectory"),
cacheRoot = File("customCacheRoot"),
pluginsConfiguration = mapOf("pluginA" to "configA"),
diff --git a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilder.kt b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilder.kt
new file mode 100644
index 00000000..c555985b
--- /dev/null
+++ b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilder.kt
@@ -0,0 +1,11 @@
+@file:Suppress("TestFunctionName")
+
+package org.jetbrains.dokka.gradle
+
+import org.gradle.api.Project
+import org.jetbrains.dokka.DokkaSourceSetID
+
+fun GradleDokkaSourceSetBuilder(name: String, project: Project, sourceSetScopeId: String = "${project.path}:test"):
+ GradleDokkaSourceSetBuilder {
+ return GradleDokkaSourceSetBuilder(name, project) { DokkaSourceSetID(sourceSetScopeId, it) }
+}
diff --git a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilderTest.kt b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilderTest.kt
index c1053069..920c48b4 100644
--- a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilderTest.kt
+++ b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilderTest.kt
@@ -1,6 +1,9 @@
+@file:Suppress("TestFunctionName")
+
package org.jetbrains.dokka.gradle
import com.android.build.gradle.internal.api.DefaultAndroidSourceSet
+import org.gradle.api.Project
import org.gradle.kotlin.dsl.closureOf
import org.gradle.testfixtures.ProjectBuilder
import org.jetbrains.dokka.*
@@ -15,14 +18,14 @@ class GradleDokkaSourceSetBuilderTest {
@Test
fun sourceSetId() {
- val sourceSet = GradleDokkaSourceSetBuilder("myName", project)
+ val sourceSet = GradleDokkaSourceSetBuilder("myName", project, "scopeId")
assertEquals(
- DokkaSourceSetID(project, "myName"), sourceSet.sourceSetID,
+ DokkaSourceSetID("scopeId", "myName"), sourceSet.sourceSetID,
"Expected sourceSet.sourceSetID to match output of DokkaSourceSetID factory function"
)
assertEquals(
- ":/myName", sourceSet.sourceSetID.toString(),
+ "scopeId/myName", sourceSet.sourceSetID.toString(),
"Expected SourceSetId's string representation"
)
}
@@ -46,29 +49,6 @@ class GradleDokkaSourceSetBuilderTest {
}
@Test
- fun moduleDisplayName() {
- val sourceSet = GradleDokkaSourceSetBuilder("myName", project)
-
- assertNull(
- sourceSet.moduleDisplayName.getSafe(),
- "Expected no ${GradleDokkaSourceSetBuilder::moduleDisplayName.name} being set by default"
- )
-
- assertEquals(
- "root", sourceSet.build().moduleDisplayName,
- "Expected project name being used for ${DokkaConfiguration.DokkaSourceSet::moduleDisplayName.name} " +
- "after building source set with no ${GradleDokkaSourceSetBuilder::moduleDisplayName.name} being set"
- )
-
- sourceSet.moduleDisplayName by "displayName"
-
- assertEquals(
- "displayName", sourceSet.build().moduleDisplayName,
- "Expected previously set ${GradleDokkaSourceSetBuilder::displayName.name} to be present after build"
- )
- }
-
- @Test
fun displayName() {
val sourceSet = GradleDokkaSourceSetBuilder("myName", project)
assertNull(
@@ -128,9 +108,9 @@ class GradleDokkaSourceSetBuilderTest {
val sourceSet = GradleDokkaSourceSetBuilder("", project)
assertEquals(emptySet(), sourceSet.build().dependentSourceSets, "Expected no dependent sourceSets by default")
- sourceSet.dependentSourceSets.add(DokkaSourceSetID(project, "s1"))
+ sourceSet.dependentSourceSets.add(sourceSet.DokkaSourceSetID("s1"))
sourceSet.dependsOn("s2")
- sourceSet.dependsOn(DokkaSourceSetID(project, "s3"))
+ sourceSet.dependsOn(sourceSet.DokkaSourceSetID("s3"))
sourceSet.dependsOn(GradleDokkaSourceSetBuilder("s4", project))
sourceSet.dependsOn(GradleDokkaSourceSetBuilder("s5", project).build())
sourceSet.dependsOn(DefaultKotlinSourceSet(project, "s6"))
@@ -456,3 +436,6 @@ class GradleDokkaSourceSetBuilderTest {
)
}
}
+
+private fun GradleDokkaSourceSetBuilder(name: String, project: Project) =
+ GradleDokkaSourceSetBuilder(name, project, project.path)
diff --git a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/KotlinDslDokkaTaskConfigurationTest.kt b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/KotlinDslDokkaTaskConfigurationTest.kt
index 6a356b79..9c788a01 100644
--- a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/KotlinDslDokkaTaskConfigurationTest.kt
+++ b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/KotlinDslDokkaTaskConfigurationTest.kt
@@ -50,7 +50,7 @@ class KotlinDslDokkaTaskConfigurationTest {
)
assertEquals(
- DokkaSourceSetID(project.path, "commonMain"), commonMain.sourceSetID
+ DokkaSourceSetID(dokkaTask, "commonMain"), commonMain.sourceSetID
)
}
}
@@ -83,14 +83,14 @@ class KotlinDslDokkaTaskConfigurationTest {
val kotlin = project.extensions.getByName("kotlin") as KotlinJvmProjectExtension
- project.tasks.withType(DokkaTask::class.java).first().run {
+ project.tasks.withType(DokkaTask::class.java).first().apply {
dokkaSourceSets.run {
val special = create("special") {
it.dependsOn(kotlin.sourceSets.getByName("main"))
}
assertEquals(
- DokkaSourceSetID(project, "main"), special.dependentSourceSets.get().single()
+ DokkaSourceSetID(this@apply, "main"), special.dependentSourceSets.get().single()
)
}
}