From 0bab7db6d61f815a2398ac1fd3fb1189f9cffccb Mon Sep 17 00:00:00 2001 From: Ignat Beresnev Date: Tue, 18 Apr 2023 12:10:33 +0200 Subject: [PATCH 1/3] Add source links to the dokka-multimodule-example project --- .../parentProject/build.gradle.kts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/examples/gradle/dokka-multimodule-example/parentProject/build.gradle.kts b/examples/gradle/dokka-multimodule-example/parentProject/build.gradle.kts index da7b382e31..509026578d 100644 --- a/examples/gradle/dokka-multimodule-example/parentProject/build.gradle.kts +++ b/examples/gradle/dokka-multimodule-example/parentProject/build.gradle.kts @@ -1,5 +1,6 @@ import org.jetbrains.dokka.DokkaConfiguration.Visibility import org.jetbrains.dokka.gradle.DokkaTaskPartial +import java.net.URL plugins { kotlin("jvm") @@ -17,6 +18,19 @@ subprojects { Visibility.PUBLIC, Visibility.PROTECTED )) + + // In multi-project builds, `remoteUrl` must point to that project's dir specifically, so if you + // want to configure sourceLinks at once in `subprojects {}`, you have to find the relative path. + // Alternatively, you can move this configuration up into subproject build scripts, + // and just hardcode the exact paths as demonstrated in the basic dokka-gradle-example. + sourceLink { + val exampleDir = "https://github.com/Kotlin/dokka/tree/master/examples/gradle/dokka-multimodule-example" + val projectRelativePath = rootProject.projectDir.toPath().relativize(projectDir.toPath()) + + localDirectory.set(file("src")) + remoteUrl.set(URL("$exampleDir/$projectRelativePath/src")) + remoteLineSuffix.set("#L") + } } } } From 1e923ae81c8daab7c21ff46deb7bd3ff434de9ce Mon Sep 17 00:00:00 2001 From: Ignat Beresnev Date: Tue, 18 Apr 2023 12:15:41 +0200 Subject: [PATCH 2/3] Use `projectDir.resolve()` instead of relying on `file()` --- .../dokka-multimodule-example/parentProject/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/gradle/dokka-multimodule-example/parentProject/build.gradle.kts b/examples/gradle/dokka-multimodule-example/parentProject/build.gradle.kts index 509026578d..f82cb029e3 100644 --- a/examples/gradle/dokka-multimodule-example/parentProject/build.gradle.kts +++ b/examples/gradle/dokka-multimodule-example/parentProject/build.gradle.kts @@ -27,7 +27,7 @@ subprojects { val exampleDir = "https://github.com/Kotlin/dokka/tree/master/examples/gradle/dokka-multimodule-example" val projectRelativePath = rootProject.projectDir.toPath().relativize(projectDir.toPath()) - localDirectory.set(file("src")) + localDirectory.set(projectDir.resolve("src")) remoteUrl.set(URL("$exampleDir/$projectRelativePath/src")) remoteLineSuffix.set("#L") } From 5cf87e8668c2c723fb23d3dacfad4968e1f3c62f Mon Sep 17 00:00:00 2001 From: Ignat Beresnev Date: Fri, 21 Apr 2023 18:44:48 +0200 Subject: [PATCH 3/3] Add a link to kotlinlang documentation --- .../dokka-multimodule-example/parentProject/build.gradle.kts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/gradle/dokka-multimodule-example/parentProject/build.gradle.kts b/examples/gradle/dokka-multimodule-example/parentProject/build.gradle.kts index f82cb029e3..7fb7c11542 100644 --- a/examples/gradle/dokka-multimodule-example/parentProject/build.gradle.kts +++ b/examples/gradle/dokka-multimodule-example/parentProject/build.gradle.kts @@ -23,6 +23,8 @@ subprojects { // want to configure sourceLinks at once in `subprojects {}`, you have to find the relative path. // Alternatively, you can move this configuration up into subproject build scripts, // and just hardcode the exact paths as demonstrated in the basic dokka-gradle-example. + // + // Read docs for more details: https://kotlinlang.org/docs/dokka-gradle.html#source-link-configuration sourceLink { val exampleDir = "https://github.com/Kotlin/dokka/tree/master/examples/gradle/dokka-multimodule-example" val projectRelativePath = rootProject.projectDir.toPath().relativize(projectDir.toPath())