From 609576be638ab248a6689bb81028e7e279b2754b Mon Sep 17 00:00:00 2001 From: Graham Date: Wed, 15 Apr 2020 22:45:56 +0100 Subject: [PATCH] Add Dokka task to the root project Signed-off-by: Graham --- build.gradle.kts | 42 +++++++++++++++++++++++++++++- buildSrc/src/main/java/Versions.kt | 1 + 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index efe016fa0f..bad5a4518e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,16 +1,23 @@ import org.jetbrains.kotlin.gradle.plugin.KotlinPluginWrapper import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import java.io.ByteArrayOutputStream +import java.nio.charset.StandardCharsets defaultTasks("build") plugins { base id("com.github.ben-manes.versions") version Versions.versionsPlugin + id("org.jetbrains.dokka") version Versions.dokka + kotlin("jvm") version Versions.kotlin id("com.github.jk1.dependency-license-report") version Versions.dependencyLicenseReport apply false id("com.github.johnrengelman.shadow") version Versions.shadowPlugin apply false id("org.jmailen.kotlinter") version Versions.kotlinter apply false - kotlin("jvm") version Versions.kotlin apply false +} + +repositories { + jcenter() } allprojects { @@ -194,6 +201,39 @@ tasks.dependencyUpdates { } } +fun commitHash(): String { + val out = ByteArrayOutputStream() + exec { + commandLine("git", "rev-parse", "HEAD") + standardOutput = out + }.assertNormalExitValue() + return String(out.toByteArray(), StandardCharsets.UTF_8).trim() +} + +tasks.dokka { + outputDirectory = "${project.buildDir}/dokka" + outputFormat = "html" + + subProjects = subprojects.filter { it.free && it.name != "deob-annotations" }.map { it.name } + + configuration { + includeNonPublic = true + + /* + * XXX(gpe): ideally we'd use 11 here, but we're blocked on + * https://github.com/Kotlin/dokka/issues/294. 9 is the most recent + * working version for now. + */ + jdkVersion = 9 + + sourceLink { + path = "." + url = "https://git.openrs2.dev/openrs2/openrs2/src/commit/${commitHash()}" + lineSuffix = "#L" + } + } +} + tasks.wrapper { distributionType = Wrapper.DistributionType.ALL } diff --git a/buildSrc/src/main/java/Versions.kt b/buildSrc/src/main/java/Versions.kt index e73538e2af..b3a327ea92 100644 --- a/buildSrc/src/main/java/Versions.kt +++ b/buildSrc/src/main/java/Versions.kt @@ -4,6 +4,7 @@ object Versions { const val clikt = "2.6.0" const val commonsCompress = "1.20" const val dependencyLicenseReport = "1.13" + const val dokka = "0.10.1" const val fastutil = "8.3.1" const val fernflower = "1.0.4-SNAPSHOT" const val guava = "29.0-jre"