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

Move Dokka configs for different modules into a common DokkaConfig.kt file #1503

Merged
merged 11 commits into from
Jul 26, 2022
Merged
3 changes: 1 addition & 2 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import org.gradle.kotlin.dsl.`kotlin-dsl`

plugins {
`kotlin-dsl`
}
Expand All @@ -22,4 +20,5 @@ dependencies {
implementation("ca.uhn.hapi.fhir:hapi-fhir-structures-r4:5.4.0")
implementation("com.squareup:kotlinpoet:1.9.0")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.10")
implementation("org.jetbrains.dokka:dokka-gradle-plugin:1.6.10")
}
44 changes: 44 additions & 0 deletions buildSrc/src/main/kotlin/DokkaConfig.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import java.net.URL
import org.gradle.api.Project
import org.gradle.kotlin.dsl.apply
import org.gradle.kotlin.dsl.invoke
import org.gradle.kotlin.dsl.named

fun Project.configureDokka(artifactId: String, version: String) {
apply(plugin = Plugins.BuildPlugins.dokka)

tasks.named<org.jetbrains.dokka.gradle.DokkaTask>("dokkaHtml").configure {
outputDirectory.set(file("../docs/$artifactId"))
suppressInheritedMembers.set(true)
dokkaSourceSets.invoke {
register("main") {
moduleName.set(artifactId)
moduleVersion.set(version)
sourceRoots.from(file("../${project.name}"))
noAndroidSdkLink.set(false)
externalDocumentationLink {
url.set(URL("https://hapifhir.io/hapi-fhir/apidocs/hapi-fhir-structures-r4/"))
packageListUrl.set(
URL("https://hapifhir.io/hapi-fhir/apidocs/hapi-fhir-structures-r4/element-list")
)
}
}
}
}
}
8 changes: 4 additions & 4 deletions buildSrc/src/main/kotlin/Plugins.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ object Plugins {
object BuildPlugins {
const val androidLib = "com.android.library"
const val application = "com.android.application"
// Use Dokka 1.6.10 until https://github.com/Kotlin/dokka/issues/2452 is resolved.
const val dokka = "org.jetbrains.dokka"
const val kotlin = "kotlin"
const val kotlinAndroid = "kotlin-android"
const val kotlinKapt = "kotlin-kapt"
const val mavenPublish = "maven-publish"
const val javaLibrary = "java-library"
const val kotlin = "kotlin"
const val navSafeArgs = "androidx.navigation.safeargs.kotlin"
const val spotless = "com.diffplug.spotless"
const val ruler = "com.spotify.ruler"
const val dokka = "org.jetbrains.dokka"
const val spotless = "com.diffplug.spotless"
}

// classpath plugins
Expand Down
22 changes: 1 addition & 21 deletions datacapture/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import java.net.URL

plugins {
id(Plugins.BuildPlugins.androidLib)
id(Plugins.BuildPlugins.kotlinAndroid)
id(Plugins.BuildPlugins.mavenPublish)
jacoco
// Use Dokka 1.6.10 until https://github.com/Kotlin/dokka/issues/2452 is resolved.
id(Plugins.BuildPlugins.dokka).version(Plugins.Versions.dokka)
}

publishArtifact(Releases.DataCapture)
Expand Down Expand Up @@ -92,20 +88,4 @@ dependencies {
androidTestImplementation(Dependencies.Espresso.espressoCore)
}

tasks.dokkaHtml.configure {
outputDirectory.set(file("../docs/${Releases.DataCapture.artifactId}"))
suppressInheritedMembers.set(true)
dokkaSourceSets {
named("main") {
moduleName.set(Releases.DataCapture.artifactId)
moduleVersion.set(Releases.DataCapture.version)
noAndroidSdkLink.set(false)
externalDocumentationLink {
url.set(URL("https://hapifhir.io/hapi-fhir/apidocs/hapi-fhir-structures-r4/"))
packageListUrl.set(
URL("https://hapifhir.io/hapi-fhir/apidocs/hapi-fhir-structures-r4/element-list")
)
}
}
}
}
configureDokka(Releases.DataCapture.artifactId, Releases.DataCapture.version)
21 changes: 1 addition & 20 deletions engine/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import codegen.GenerateSourcesTask
import java.net.URL

plugins {
id(Plugins.BuildPlugins.androidLib)
id(Plugins.BuildPlugins.kotlinAndroid)
id(Plugins.BuildPlugins.kotlinKapt)
id(Plugins.BuildPlugins.mavenPublish)
jacoco
// Use Dokka 1.6.10 until https://github.com/Kotlin/dokka/issues/2452 is resolved.
id(Plugins.BuildPlugins.dokka).version(Plugins.Versions.dokka)
}

publishArtifact(Releases.Engine)
Expand Down Expand Up @@ -139,20 +136,4 @@ dependencies {
testImplementation(Dependencies.truth)
}

tasks.dokkaHtml.configure {
outputDirectory.set(file("../docs/${Releases.Engine.artifactId}"))
suppressInheritedMembers.set(true)
dokkaSourceSets {
named("main") {
moduleName.set(Releases.Engine.artifactId)
moduleVersion.set(Releases.Engine.version)
noAndroidSdkLink.set(false)
externalDocumentationLink {
url.set(URL("https://hapifhir.io/hapi-fhir/apidocs/hapi-fhir-structures-r4/"))
packageListUrl.set(
URL("https://hapifhir.io/hapi-fhir/apidocs/hapi-fhir-structures-r4/element-list")
)
}
}
}
}
configureDokka(Releases.Engine.artifactId, Releases.Engine.version)
21 changes: 1 addition & 20 deletions workflow/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import java.net.URL

plugins {
id(Plugins.BuildPlugins.androidLib)
id(Plugins.BuildPlugins.kotlinAndroid)
id(Plugins.BuildPlugins.mavenPublish)
jacoco
id(Plugins.BuildPlugins.dokka).version(Plugins.Versions.dokka)
}

publishArtifact(Releases.Workflow)
Expand Down Expand Up @@ -143,20 +140,4 @@ dependencies {
testImplementation(project(":testing"))
}

tasks.dokkaHtml.configure {
outputDirectory.set(file("../docs/${Releases.Workflow.artifactId}"))
suppressInheritedMembers.set(true)
dokkaSourceSets {
named("main") {
moduleName.set(Releases.Workflow.artifactId)
moduleVersion.set(Releases.Workflow.version)
noAndroidSdkLink.set(false)
externalDocumentationLink {
url.set(URL("https://hapifhir.io/hapi-fhir/apidocs/hapi-fhir-structures-r4/"))
packageListUrl.set(
URL("https://hapifhir.io/hapi-fhir/apidocs/hapi-fhir-structures-r4/element-list")
)
}
}
}
}
configureDokka(Releases.Workflow.artifactId, Releases.Workflow.version)