diff options
author | sebastian.sellmair <sebastian.sellmair@jetbrains.com> | 2020-08-20 10:03:36 +0200 |
---|---|---|
committer | Sebastian Sellmair <34319766+sellmair@users.noreply.github.com> | 2020-08-20 16:36:30 +0200 |
commit | d2085c1049b3d27cc907b60605c43b832ae8d469 (patch) | |
tree | 15bf4bee739bc47a155dfda5eafbb8f954059857 /runners/gradle-plugin/src/main/kotlin/org | |
parent | ccd630109f1ed28d7e3113f1005dfee46160db46 (diff) | |
download | dokka-d2085c1049b3d27cc907b60605c43b832ae8d469.tar.gz dokka-d2085c1049b3d27cc907b60605c43b832ae8d469.tar.bz2 dokka-d2085c1049b3d27cc907b60605c43b832ae8d469.zip |
Implement tests for enhanced KotlinSourceSetGist mechanism
Diffstat (limited to 'runners/gradle-plugin/src/main/kotlin/org')
5 files changed, 16 insertions, 14 deletions
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 08ed7d70..e63863b3 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 @@ -22,18 +22,17 @@ open class DokkaTask : AbstractDokkaTask(DokkaBootstrapImpl::class) { } } - // TODO NOW: Test /** * Only contains source sets that are marked with `isDocumented`. * Non documented source sets are not relevant for Gradle's UP-TO-DATE mechanism, as well * as task dependency graph. */ @get:Nested - protected val documentedDokkaSourceSets: List<GradleDokkaSourceSetBuilder> + protected val unsuppressedSourceSets: List<GradleDokkaSourceSetBuilder> get() = dokkaSourceSets .toList() .also(::checkSourceSetDependencies) - .filter { it.isDocumented.getSafe() } + .filterNot { it.suppress.getSafe() } override fun buildDokkaConfiguration(): DokkaConfigurationImpl { return DokkaConfigurationImpl( @@ -41,7 +40,7 @@ open class DokkaTask : AbstractDokkaTask(DokkaBootstrapImpl::class) { cacheRoot = cacheRoot.getSafe(), offlineMode = offlineMode.getSafe(), failOnWarning = failOnWarning.getSafe(), - sourceSets = documentedDokkaSourceSets.build(), + sourceSets = unsuppressedSourceSets.build(), pluginsConfiguration = pluginsConfiguration.getSafe(), pluginsClasspath = plugins.resolve().toList() ) 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 b0686011..3b26e1e9 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 @@ -33,9 +33,8 @@ open class GradleDokkaSourceSetBuilder constructor( val sourceSetID: DokkaSourceSetID = DokkaSourceSetID(project, name) @Input - @get:JvmName("getIsDocumented") - val isDocumented: Property<Boolean> = project.objects.safeProperty<Boolean>() - .safeConvention(true) + val suppress: Property<Boolean> = project.objects.safeProperty<Boolean>() + .safeConvention(false) @Classpath @Optional 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 8d2f70fd..989ad10a 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 @@ -2,7 +2,6 @@ package org.jetbrains.dokka.gradle import org.jetbrains.dokka.DokkaSourceSetID -// TODO NOW: Test internal fun checkSourceSetDependencies(sourceSets: List<GradleDokkaSourceSetBuilder>) { checkSourceSetDependencies(sourceSets.associateBy { it.sourceSetID }) } @@ -11,13 +10,13 @@ private fun checkSourceSetDependencies(sourceSets: Map<DokkaSourceSetID, GradleD sourceSets.values.forEach { sourceSet -> sourceSet.dependentSourceSets.getSafe().forEach { dependentSourceSetID -> val dependentSourceSet = requireNotNull(sourceSets[dependentSourceSetID]) { - "Dokka source set ${sourceSet.name}: Cannot find dependent source set $dependentSourceSetID" + "Dokka source set \"${sourceSet.name}\": Cannot find dependent source set \"$dependentSourceSetID\"" } - if (sourceSet.isDocumented.getSafe() && dependentSourceSet.isDocumented.getSafe().not()) { + if (sourceSet.suppress.getSafe().not() && dependentSourceSet.suppress.getSafe()) { throw IllegalArgumentException( - "Dokka source set: ${sourceSet.name}: " + - "Documented source set cannot depend on undocumented source set $dependentSourceSetID" + "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/kotlin/isMainSourceSet.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/kotlin/isMainSourceSet.kt index 2c1eba5b..15989217 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/kotlin/isMainSourceSet.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/kotlin/isMainSourceSet.kt @@ -7,7 +7,12 @@ import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJvmAndroidCompilation internal fun Project.isMainSourceSet(sourceSet: KotlinSourceSet): Boolean { - return allCompilationsOf(sourceSet).any { compilation -> isMainCompilation(compilation) } + return isMainSourceSet(allCompilationsOf(sourceSet)) +} + +internal fun isMainSourceSet(compilations: List<KotlinCompilation>): Boolean { + if (compilations.isEmpty()) return true + return compilations.any { compilation -> isMainCompilation(compilation) } } private fun isMainCompilation(compilation: KotlinCompilation): Boolean { diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/sourceSetKotlinGistConfiguration.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/sourceSetKotlinGistConfiguration.kt index fee86094..a7231f04 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/sourceSetKotlinGistConfiguration.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/sourceSetKotlinGistConfiguration.kt @@ -14,7 +14,7 @@ internal fun GradleDokkaSourceSetBuilder.configureWithKotlinSourceSetGist(source sourceSetNames.map { sourceSetName -> DokkaSourceSetID(sourceSetName) } } - this.isDocumented by sourceSet.isMain + this.suppress by sourceSet.isMain.map { !it } this.sourceRoots.from(sourceSet.sourceRoots) this.classpath.from(sourceSet.classpath) this.platform by sourceSet.platform.map { Platform.fromString(it.name) } |