Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apply publishing plugins, esp. tutteli-dokka only if env PUB is true #1612

Merged
merged 1 commit into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
}
}
}