Skip to content

Commit

Permalink
refactor dokka script
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentlauvlwj committed Jul 22, 2024
1 parent 912d849 commit ae59ef6
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 24 deletions.
24 changes: 1 addition & 23 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,10 @@ group = "org.ktorm"
version = file("ktorm.version").readLines()[0]

plugins {
id("org.jetbrains.dokka") version "1.9.20"
id("ktorm.dokka")
}

repositories {
mavenCentral()
gradlePluginPortal()
}

tasks.dokkaHtmlMultiModule {
val templatesDir = System.getenv("DOKKA_TEMPLATES_DIR")
if (!templatesDir.isNullOrEmpty()) {
pluginsMapConfiguration.set(mapOf("org.jetbrains.dokka.base.DokkaBase" to """{"templatesDir": "$templatesDir"}"""))
}
}

subprojects {
apply(plugin = "org.jetbrains.dokka")

tasks.named<org.jetbrains.dokka.gradle.DokkaTaskPartial>("dokkaHtmlPartial") {
dokkaSourceSets.named("main") {
suppressGeneratedFiles.set(false)
sourceLink {
localDirectory.set(file("src/main/kotlin"))
remoteUrl.set(java.net.URL("https://github.com/kotlin-orm/ktorm/blob/master/${project.name}/src/main/kotlin"))
remoteLineSuffix.set("#L")
}
}
}
}
2 changes: 2 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ repositories {

dependencies {
api("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.23")
api("org.jetbrains.dokka:dokka-gradle-plugin:1.9.20")
api("org.jetbrains.dokka:dokka-base:1.9.20")
api("org.moditect:moditect:1.0.0.RC1")
api("io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.23.6")
}
29 changes: 29 additions & 0 deletions buildSrc/src/main/kotlin/ktorm.dokka.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import gradle.kotlin.dsl.accessors._f5007bc516eebc049270414be01b92ac.dokkaJavadoc

plugins {
id("org.jetbrains.dokka")
}

tasks.named<org.jetbrains.dokka.gradle.DokkaMultiModuleTask>("dokkaHtmlMultiModule") {
val tmplDir = System.getenv("DOKKA_TEMPLATES_DIR")
if (!tmplDir.isNullOrEmpty()) {
pluginConfiguration<org.jetbrains.dokka.base.DokkaBase, org.jetbrains.dokka.base.DokkaBaseConfiguration> {
templatesDir = File(tmplDir)
}
}
}

subprojects {
apply(plugin = "org.jetbrains.dokka")

tasks.named<org.jetbrains.dokka.gradle.DokkaTaskPartial>("dokkaHtmlPartial") {
dokkaSourceSets.named("main") {
suppressGeneratedFiles.set(false)
sourceLink {
localDirectory.set(file("src/main/kotlin"))
remoteUrl.set(java.net.URL("https://github.com/kotlin-orm/ktorm/blob/master/${project.name}/src/main/kotlin"))
remoteLineSuffix.set("#L")
}
}
}
}
5 changes: 4 additions & 1 deletion buildSrc/src/main/kotlin/ktorm.publish.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@ plugins {
id("kotlin")
id("signing")
id("maven-publish")
id("org.jetbrains.dokka")
}

val jarSources by tasks.registering(Jar::class) {
archiveClassifier.set("sources")
from(sourceSets.main.map { it.allSource })
archiveClassifier.set("sources")
}

val jarJavadoc by tasks.registering(Jar::class) {
dependsOn(tasks.dokkaJavadoc)
from(tasks.dokkaJavadoc.flatMap { it.outputDirectory })
archiveClassifier.set("javadoc")
}

Expand Down
4 changes: 4 additions & 0 deletions buildSrc/src/main/kotlin/ktorm.tuples-codegen.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

plugins {
id("kotlin")
id("org.jetbrains.dokka")
}

val generatedSourceDir = "${project.layout.buildDirectory.asFile.get()}/generated/source/main/kotlin"
Expand Down Expand Up @@ -354,6 +355,9 @@ tasks {
"jarSources" {
dependsOn(generateTuples)
}
dokkaJavadoc {
dependsOn(generateTuples)
}
}

sourceSets.main {
Expand Down
3 changes: 3 additions & 0 deletions ktorm-jackson/ktorm-jackson.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ tasks {
"jarSources" {
dependsOn(generatePackageVersion)
}
dokkaJavadoc {
dependsOn(generatePackageVersion)
}
}

sourceSets.main {
Expand Down

0 comments on commit ae59ef6

Please sign in to comment.