Skip to content
Draft
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
7 changes: 7 additions & 0 deletions build-logic/convention/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ dependencies {
compileOnly(libs.detekt.gradlePlugin)
compileOnly(libs.ktlint.gradlePlugin)
compileOnly(libs.spotless.gradle)
compileOnly(libs.dokka.gradlePlugin)
implementation(libs.truth)
compileOnly(libs.androidx.room.gradle.plugin)
compileOnly(libs.firebase.crashlytics.gradlePlugin)
Expand Down Expand Up @@ -125,5 +126,11 @@ gradlePlugin {
description = "Configures Room for the project"
}

// Dokka for documentation
register("dokkaConvention") {
id = "org.convention.dokka.plugin"
implementationClass = "DokkaConventionPlugin"
description = "Configures Dokka for the project"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class CMPFeatureConventionPlugin : Plugin<Project> {
apply("org.jetbrains.compose")
apply("org.convention.detekt.plugin")
apply("org.convention.spotless.plugin")
apply("org.convention.dokka.plugin")
}

dependencies {
Expand Down
23 changes: 23 additions & 0 deletions build-logic/convention/src/main/kotlin/DokkaConventionPlugin.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

import org.convention.dokkaGradle
import org.gradle.api.Plugin
import org.convention.configureDokka
import org.gradle.api.Project

class DokkaConventionPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
applyPlugins()

dokkaGradle {
configureDokka(this)
}
}
}

private fun Project.applyPlugins() {
pluginManager.apply {
apply("org.jetbrains.dokka")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class KMPLibraryConventionPlugin: Plugin<Project> {
apply("org.convention.spotless.plugin")
apply("org.jetbrains.kotlin.plugin.serialization")
apply("org.jetbrains.kotlin.plugin.parcelize")
apply("org.convention.dokka.plugin")
}

configureKotlinMultiplatform()
Expand Down
30 changes: 30 additions & 0 deletions build-logic/convention/src/main/kotlin/org/convention/Dokka.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.convention

import org.gradle.api.Project
import org.jetbrains.dokka.gradle.DokkaExtension

/**
* Configures Dokka and suppresses non-allowed modules.
* Sets moduleName only for modules inside :core and :core-base.
*
* e.g., ":core-base:designsystem" -> "core-base-designsystem"
* "core:designsystem" -> "core-designsystem"
*/
internal fun Project.configureDokka(extension: DokkaExtension) = extension.apply {
val isUnderCoreTrees = project.path.matches(Regex("^:(core|core-base):.+$"))
if (isUnderCoreTrees) {
val moduleId = project.path
.trimStart(':')
.replace(':', '-')
.ifBlank { project.name }
moduleName.set(moduleId)
}

// Allow only :cmp-*, :core, :core-base, :feature and any of their submodules
val allowed = project.path.matches(Regex("^:(cmp-[^:]+|core(?:-base)?|feature)(?::.*)?$"))
if (!allowed) {
dokkaSourceSets.configureEach {
suppress.set(true)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import org.gradle.api.artifacts.VersionCatalog
import org.gradle.api.artifacts.VersionCatalogsExtension
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.getByType
import org.jetbrains.dokka.gradle.DokkaExtension
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.plugin.KotlinHierarchyBuilder
import org.jetbrains.dokka.gradle.DokkaTask

/**
* Get the `libs` version catalog.
Expand Down Expand Up @@ -36,4 +38,12 @@ inline fun Project.detektGradle(crossinline configure: DetektExtension.() -> Uni
inline fun Project.spotlessGradle(crossinline configure: SpotlessExtension.() -> Unit) =
extensions.configure<SpotlessExtension> {
configure()
}

/**
* Configures the `dokka` plugin with the [configure] lambda for all DokkaTasks.
*/
inline fun Project.dokkaGradle(crossinline configure: DokkaExtension.() -> Unit) =
extensions.configure<DokkaExtension> {
configure()
}
40 changes: 40 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,46 @@ plugins {
alias(libs.plugins.ktrofit) apply false

alias(libs.plugins.room) apply false
alias(libs.plugins.dokka)
}

dokka {
dokkaPublications.html {
outputDirectory.set(layout.buildDirectory.dir("$rootDir/docs/docs-api/"))
}
}

// Currently cmp-web throws some unresolved symbol errors
// So it is not included in the dokka task

dependencies {
dokka(project(":cmp-shared"))
dokka(project(":cmp-desktop"))
dokka(project(":cmp-android"))
// dokka(project(":cmp-web"))
dokka(project(":cmp-navigation"))
dokka(project(":core:data"))
dokka(project(":core:domain"))
dokka(project(":core:datastore"))
dokka(project(":core:designsystem"))
dokka(project(":core:ui"))
dokka(project(":core:common"))
dokka(project(":core:network"))
dokka(project(":core:model"))
dokka(project(":core:analytics"))
dokka(project(":core:database"))

dokka(project(":feature:home"))
dokka(project(":feature:profile"))
dokka(project(":feature:settings"))

dokka(project(":core-base:common"))
dokka(project(":core-base:database"))
dokka(project(":core-base:network"))
dokka(project(":core-base:designsystem"))
dokka(project(":core-base:platform"))
dokka(project(":core-base:ui"))
dokka(project(":core-base:analytics"))
}

object DynamicVersion {
Expand Down
5 changes: 5 additions & 0 deletions cmp-android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ plugins {
alias(libs.plugins.roborazzi)
alias(libs.plugins.aboutLibraries)
alias(libs.plugins.ksp)
alias(libs.plugins.dokka)
}

val packageNameSpace: String = libs.versions.androidPackageNamespace.get()
Expand Down Expand Up @@ -159,4 +160,8 @@ baselineProfile {

// Make use of Dex Layout Optimizations via Startup Profiles
dexLayoutOptimization = true
}

dokka {
moduleName.set("cmp-android")
}
5 changes: 5 additions & 0 deletions cmp-desktop/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ plugins {
alias(libs.plugins.compose.compiler)
alias(libs.plugins.jetbrainsCompose)
alias(libs.plugins.kotlin.serialization)
alias(libs.plugins.dokka)
}

kotlin {
Expand Down Expand Up @@ -84,3 +85,7 @@ compose.desktop {
}
}
}

dokka {
moduleName.set("cmp-desktop")
}
1 change: 1 addition & 0 deletions cmp-web/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ plugins {
alias(libs.plugins.kotlinMultiplatform)
alias(libs.plugins.jetbrainsCompose)
alias(libs.plugins.compose.compiler)
alias(libs.plugins.dokka)
}

kotlin {
Expand Down
5 changes: 5 additions & 0 deletions core-base/common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/
plugins {
alias(libs.plugins.kmp.core.base.library.convention)
alias(libs.plugins.dokka)
}

android {
Expand Down Expand Up @@ -44,3 +45,7 @@ kotlin {
}
}
}

dokka {
moduleName.set("core-base-common")
}
5 changes: 5 additions & 0 deletions core-base/database/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import org.jetbrains.compose.compose
*/
plugins {
alias(libs.plugins.kmp.core.base.library.convention)
alias(libs.plugins.dokka)
}

android {
Expand All @@ -45,3 +46,7 @@ kotlin {
}
}
}

dokka {
moduleName.set("core-base-database")
}
Empty file.
2 changes: 1 addition & 1 deletion core-base/designsystem/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ compose.resources {
publicResClass = true
generateResClass = always
packageOfResClass = "template.core.base.designsystem.generated.resources"
}
}
5 changes: 5 additions & 0 deletions core-base/network/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/
plugins {
alias(libs.plugins.kmp.core.base.library.convention)
alias(libs.plugins.dokka)
}

android {
Expand Down Expand Up @@ -49,3 +50,7 @@ kotlin {
}
}
}

dokka {
moduleName.set("core-base-network")
}
5 changes: 5 additions & 0 deletions core-base/platform/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ plugins {
alias(libs.plugins.kmp.core.base.library.convention)
alias(libs.plugins.jetbrainsCompose)
alias(libs.plugins.compose.compiler)
alias(libs.plugins.dokka)
}

android {
Expand Down Expand Up @@ -58,3 +59,7 @@ kotlin {
}
}
}

dokka {
moduleName.set("core-base-platform")
}
2 changes: 1 addition & 1 deletion core-base/ui/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ compose.resources {
publicResClass = true
generateResClass = always
packageOfResClass = "template.core.base.ui.generated.resources"
}
}
2 changes: 1 addition & 1 deletion core/ui/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ compose.resources {
publicResClass = true
generateResClass = always
packageOfResClass = "org.mifos.core.ui.generated.resources"
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ kotlin.apple.xcodeCompatibility.nowarn=true
# Config
minSdk=21
targetSdk=36
compileSdk=36
compileSdk=36
4 changes: 4 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ spotlessVersion = "7.0.2"
turbine = "1.2.1"
twitter-detekt-compose = "0.0.26"
moduleGraph = "2.9.0"
dokka = "2.1.0"

# Kotlin KMP Dependencies
kotlin = "2.2.21"
Expand Down Expand Up @@ -179,6 +180,7 @@ okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" }
platform-junit-platform-launcher = { module = "org.junit.platform:junit-platform-launcher", version.ref = "junitPlatformLauncherVersion" }
spotless-gradle = { group = "com.diffplug.spotless", name = "spotless-plugin-gradle", version.ref = "spotlessVersion" }
detekt-gradlePlugin = { group = "io.gitlab.arturbosch.detekt", name = "detekt-gradle-plugin", version.ref = "detekt" }
dokka-gradlePlugin = { group = "org.jetbrains.dokka", name = "dokka-gradle-plugin", version.ref = "dokka" }
turbine = { module = "app.cash.turbine:turbine", version.ref = "turbine" }
twitter-detekt-compose = { group = "com.twitter.compose.rules", name = "detekt", version.ref = "twitter-detekt-compose" }

Expand Down Expand Up @@ -378,12 +380,14 @@ git-hooks-convention = { id = "org.convention.git.hooks", version = "unspecified
ktlint-convention = { id = "org.convention.ktlint.plugin", version = "unspecified" }
spotless-convention = { id = "org.convention.spotless.plugin", version = "unspecified" }
keystore-management = { id = "org.convention.keystore.management", version = "unspecified" }
dokka-convention = { id = "org.convention.dokka.plugin", version = "unspecified"}

dependencyGuard = { id = "com.dropbox.dependency-guard", version.ref = "dependencyGuard" }
moduleGraph = { id = "com.jraska.module.graph.assertion", version.ref = "moduleGraph" }
detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" }
ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlint" }
spotless = { id = "com.diffplug.spotless", version.ref = "spotlessVersion" }
dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }

#Room Plugin
room = { id = "androidx.room", version.ref = "room" }
Expand Down
Loading