Skip to content

Commit

Permalink
Merge pull request #1612 from robstoll/chore/activate-publishing-only…
Browse files Browse the repository at this point in the history
…-if-ENV-PUB-given

apply publishing plugins, esp. tutteli-dokka only if env PUB is true
  • Loading branch information
robstoll authored Nov 14, 2023
2 parents 8bf3874 + 3fee2e5 commit 04cdf6c
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 53 deletions.
11 changes: 11 additions & 0 deletions gradle/build-logic/basics/src/main/kotlin/extensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,14 @@ fun Project.prefixedProject(name: String): Project = project(":${rootProject.nam
// copied from com.github.vlsi.gradle.dsl.configureEach, using this instead so that we don't have to import
inline fun <reified S : Any> DomainObjectCollection<in S>.configureEach(noinline configuration: S.() -> Unit) =
withType().configureEach(configuration)

fun isPublishing() = isEnvVariableTrue("PUB")
fun ifIsPublishing(action: () -> Unit) = ifEnvVariableTrue("PUB", action)

fun ifEnvVariableTrue(name: String, action: () -> Unit) {
if (isEnvVariableTrue(name)) {
action()
}
}

fun isEnvVariableTrue(name: String) = System.getenv(name).toBoolean()
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,23 @@ import org.jetbrains.dokka.gradle.AbstractDokkaLeafTask

plugins {
id("build-logic.gradle-conventions")
id("ch.tutteli.gradle.plugins.dokka")
id("ch.tutteli.gradle.plugins.dokka") apply isPublishing()
}

val kdocDir = rootProject.projectDir.resolve("misc/kdoc")
ifIsPublishing {

tasks.configureEach<AbstractDokkaLeafTask> {
dokkaSourceSets.configureEach {
reportUndocumented.set(true)
jdkVersion.set(buildParameters.defaultJdkVersion)
perPackageOption {
matchingRegex.set("io.mockk")
suppress.set(true)
val kdocDir = rootProject.projectDir.resolve("misc/kdoc")

tasks.configureEach<AbstractDokkaLeafTask> {
dokkaSourceSets.configureEach {
reportUndocumented.set(true)
jdkVersion.set(buildParameters.defaultJdkVersion)
perPackageOption {
matchingRegex.set("io.mockk")
suppress.set(true)
}
includes.from(kdocDir.resolve("packages.md"))
}
includes.from(kdocDir.resolve("packages.md"))
configurePlugins()
}
configurePlugins()
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
plugins {
id("build-logic.kotlin-multiplatform")
id("ch.tutteli.gradle.plugins.publish")
id("ch.tutteli.gradle.plugins.publish") apply isPublishing()
id("build-logic.publish-to-tmp-maven-repo")
id("build-logic.dokka")
}

tutteliPublish {
resetLicenses("EUPL-1.2")
ifIsPublishing {
tutteliPublish {
resetLicenses("EUPL-1.2")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,46 +8,49 @@ import java.net.URL
plugins {
id("build-logic.gradle-conventions")
id("org.jetbrains.dokka")
id("ch.tutteli.gradle.plugins.dokka")
}

tutteliDokka {
writeToDocs.set(false)
id("ch.tutteli.gradle.plugins.dokka") apply isPublishing()
}

val rootProject = this

val modulesNotInGhPages = listOf(
// deprecated modules only clutter kdoc
"api-fluent-kotlin_1_3",
"api-infix-kotlin_1_3",
"logic-kotlin_1_3",
// internal modules are not of interest
"specs",
"verbs-internal",
// a user will most likely never look up translations, only clutter the search
"translations-de_CH", "translations-en_GB"
)
modulesNotInGhPages.forEach { projectName ->
prefixedProject(projectName).afterEvaluate {
val subproject = this
rootProject.tasks.configureEach<DokkaMultiModuleTask> {
dependsOn(subproject.tasks.named("cleanDokkaHtmlPartial"))
}
}
}
tasks.configureEach<DokkaMultiModuleTask> {
moduleName.set("Atrium")
configurePlugins()
}
ifIsPublishing {

gradle.taskGraph.whenReady {
if (hasTask(":dokkaHtmlMultiModule")) {
tutteliDokka {
writeToDocs.set(false)

val modulesNotInGhPages = listOf(
// deprecated modules only clutter kdoc
"api-fluent-kotlin_1_3",
"api-infix-kotlin_1_3",
"logic-kotlin_1_3",
// internal modules are not of interest
"specs",
"verbs-internal",
// a user will most likely never look up translations, only clutter the search
"translations-de_CH", "translations-en_GB"
)
modulesNotInGhPages.forEach { projectName ->
prefixedProject(projectName)
.tasks.configureEach<DokkaTaskPartial> {
enabled = false
prefixedProject(projectName).afterEvaluate {
val subproject = this
rootProject.tasks.configureEach<DokkaMultiModuleTask> {
dependsOn(subproject.tasks.named("cleanDokkaHtmlPartial"))
}
}
}
tasks.configureEach<DokkaMultiModuleTask> {
moduleName.set("Atrium")
configurePlugins()
}

gradle.taskGraph.whenReady {
if (hasTask(":dokkaHtmlMultiModule")) {
modulesNotInGhPages.forEach { projectName ->
prefixedProject(projectName)
.tasks.configureEach<DokkaTaskPartial> {
enabled = false
}
}
}
}
}
}
Expand Down
8 changes: 5 additions & 3 deletions translations/atrium-translations-de_CH/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ kotlin {
}
}

tasks.configureEach<AbstractDokkaLeafTask> {
dokkaSourceSets.configureEach {
reportUndocumented.set(false)
ifIsPublishing {
tasks.configureEach<AbstractDokkaLeafTask> {
dokkaSourceSets.configureEach {
reportUndocumented.set(false)
}
}
}
8 changes: 5 additions & 3 deletions translations/atrium-translations-en_GB/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ kotlin {
}
}

tasks.configureEach<AbstractDokkaLeafTask> {
dokkaSourceSets.configureEach {
reportUndocumented.set(false)
ifIsPublishing {
tasks.configureEach<AbstractDokkaLeafTask> {
dokkaSourceSets.configureEach {
reportUndocumented.set(false)
}
}
}

0 comments on commit 04cdf6c

Please sign in to comment.