Skip to content

Commit 02dd8cd

Browse files
authored
Merge branch 'main' into renovate/gradle-8.x
2 parents bc2c88c + abbfbfa commit 02dd8cd

File tree

82 files changed

+5113
-87
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+5113
-87
lines changed

.github/workflows/run_publish_maven.yml

-6
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ jobs:
4242
gradle-task: >-
4343
publishAllPublicationsToSonatypeReleaseRepository
4444
--stacktrace
45-
--no-configuration-cache
46-
--no-parallel
4745
checkout-ref: ${{ inputs.checkout-ref }}
4846

4947

@@ -60,8 +58,6 @@ jobs:
6058
gradle-task: >-
6159
publishAllPublicationsToJetBrainsSpaceRepository
6260
--stacktrace
63-
--no-configuration-cache
64-
--no-parallel
6561
checkout-ref: ${{ inputs.checkout-ref }}
6662

6763

@@ -78,6 +74,4 @@ jobs:
7874
gradle-task: >-
7975
publishAllPublicationsToAdamkoDevRepository
8076
--stacktrace
81-
--no-configuration-cache
82-
--no-parallel
8377
checkout-ref: ${{ inputs.checkout-ref }}

build.gradle.kts

+5-31
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import buildsrc.utils.excludeGeneratedGradleDsl
1+
import buildsrc.utils.excludeProjectConfigurationDirs
22
import buildsrc.utils.initIdeProjectLogo
33
import org.gradle.language.base.plugins.LifecycleBasePlugin.VERIFICATION_GROUP
44

@@ -10,47 +10,21 @@ plugins {
1010
group = "dev.adamko.dokkatoo"
1111
version = "2.4.0-SNAPSHOT"
1212

13+
excludeProjectConfigurationDirs(idea)
1314

14-
idea {
15-
module {
16-
excludeGeneratedGradleDsl(layout)
17-
18-
excludeDirs.apply {
19-
// exclude .gradle, IDE dirs from nested projects (e.g. example & template projects)
20-
// so IntelliJ project-wide search isn't cluttered with irrelevant files
21-
val excludedDirs = setOf(
22-
".idea",
23-
".gradle",
24-
"build",
25-
"gradle/wrapper",
26-
"ANDROID_SDK",
27-
"examples/versioning-multimodule-example/dokkatoo/previousDocVersions",
28-
"examples/versioning-multimodule-example/dokka/previousDocVersions",
29-
"modules/dokkatoo-plugin-integration-tests/example-project-data",
30-
)
31-
addAll(
32-
projectDir.walk().filter { file ->
33-
excludedDirs.any {
34-
file.invariantSeparatorsPath.endsWith("/$it")
35-
}
36-
}
37-
)
38-
}
39-
}
15+
tasks.prepareKotlinBuildScriptModel {
16+
initIdeProjectLogo("documentation/media/kayray-logo.svg")
4017
}
4118

42-
initIdeProjectLogo("modules/docs/images/logo-icon.svg")
43-
4419
val dokkatooVersion by tasks.registering {
4520
description = "prints the Dokkatoo project version (used during release to verify the version)"
4621
group = "help"
47-
val version = providers.provider { project.version }
22+
val version = providers.provider { project.version.toString() }
4823
doLast {
4924
logger.quiet("${version.orNull}")
5025
}
5126
}
5227

53-
5428
val verifyVersionCatalogKotlinVersion by tasks.registering {
5529
description = "Verify the Version Catalog Kotlin version matches Gradle's embedded Kotlin version"
5630
// https://docs.gradle.org/current/userguide/compatibility.html#kotlin

buildSrc/src/main/kotlin/buildsrc/conventions/base.gradle.kts

+3
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ tasks.withType<AbstractCopyTask>().configureEach {
4545
includeEmptyDirs = false
4646
}
4747

48+
49+
//region Gradle test report dark mode
4850
val updateTestReportCss by tasks.registering {
4951
description = "Hack so the Gradle test reports have dark mode"
5052
// the CSS is based on https://github.com/gradle/gradle/pull/12177
@@ -153,3 +155,4 @@ tasks.matching { it.name == "validatePlugins" }.configureEach {
153155
// Task ':validatePlugins' uses this output of task ':updateTestReportCss' without declaring an explicit or implicit dependency.
154156
mustRunAfter(updateTestReportCss)
155157
}
158+
//endregion

buildSrc/src/main/kotlin/buildsrc/conventions/maven-publishing.gradle.kts

+15-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ publishing {
1717
pom {
1818
name.convention("Dokkatoo")
1919
description.convention("Dokkatoo is a Gradle plugin that generates documentation for your Kotlin projects")
20-
url.convention("https://github.com/adamko-dev/dokkatoo")
20+
url.convention("https://adamko-dev.github.io/dokkatoo/")
2121

2222
scm {
2323
connection.convention("scm:git:https://github.com/adamko-dev/dokkatoo")
@@ -151,6 +151,20 @@ tasks.withType<AbstractPublishToMaven>().configureEach {
151151
//endregion
152152

153153

154+
//region Maven Central can't handle parallel uploads, so limit parallel uploads with a service.
155+
abstract class MavenPublishLimiter : BuildService<BuildServiceParameters.None>
156+
157+
val mavenPublishLimiter =
158+
gradle.sharedServices.registerIfAbsent("mavenPublishLimiter", MavenPublishLimiter::class) {
159+
maxParallelUsages = 1
160+
}
161+
162+
tasks.withType<PublishToMavenRepository>().configureEach {
163+
usesService(mavenPublishLimiter)
164+
}
165+
//endregion
166+
167+
154168
//region IJ workarounds
155169
// manually define the Kotlin DSL accessors because IntelliJ _still_ doesn't load them properly
156170
fun Project.publishing(configure: PublishingExtension.() -> Unit): Unit =
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,130 @@
11
package buildsrc.utils
22

3+
import java.io.File
4+
import javax.inject.Inject
35
import org.gradle.api.Project
4-
import org.gradle.api.file.ProjectLayout
5-
import org.gradle.plugins.ide.idea.model.IdeaModule
6+
import org.gradle.api.Task
7+
import org.gradle.api.file.DirectoryProperty
8+
import org.gradle.api.file.FileSystemOperations
9+
import org.gradle.api.file.RegularFileProperty
10+
import org.gradle.api.provider.ValueSource
11+
import org.gradle.api.provider.ValueSourceParameters
12+
import org.gradle.configurationcache.extensions.serviceOf
13+
import org.gradle.kotlin.dsl.*
14+
import org.gradle.plugins.ide.idea.model.IdeaModel
615

716

8-
/** exclude generated Gradle code, so it doesn't clog up search results */
9-
fun IdeaModule.excludeGeneratedGradleDsl(layout: ProjectLayout) {
17+
/**
18+
* Exclude directories containing
19+
*
20+
* - generated Gradle code,
21+
* - IDE files,
22+
* - Gradle config,
23+
*
24+
* so they don't clog up search results.
25+
*/
26+
fun Project.excludeProjectConfigurationDirs(
27+
idea: IdeaModel
28+
) {
29+
val excludedDirs = providers.of(IdeaExcludedDirectoriesSource::class) {
30+
parameters.projectDir.set(layout.projectDirectory)
31+
}.get()
32+
33+
idea.module.excludeDirs.addAll(excludedDirs)
34+
}
1035

11-
val generatedSrcDirs = listOf(
12-
"kotlin-dsl-accessors",
13-
"kotlin-dsl-external-plugin-spec-builders",
14-
"kotlin-dsl-plugins",
15-
)
36+
// Have to use a ValueSource to find the files, otherwise Gradle
37+
// considers _all files_ an input for configuration cache 🙄
38+
internal abstract class IdeaExcludedDirectoriesSource :
39+
ValueSource<Set<File>, IdeaExcludedDirectoriesSource.Parameters> {
40+
41+
interface Parameters : ValueSourceParameters {
42+
val projectDir: DirectoryProperty
43+
}
1644

17-
excludeDirs.addAll(
18-
layout.projectDirectory.asFile.walk()
19-
.filter { it.isDirectory && it.parentFile.name in generatedSrcDirs }
45+
override fun obtain(): Set<File> {
46+
val projectDir = parameters.projectDir.get().asFile
47+
48+
val doNotWalkDirs = setOf(
49+
".git",
50+
".kotlin",
51+
)
52+
53+
val generatedSrcDirs = listOf(
54+
"kotlin-dsl-accessors",
55+
"kotlin-dsl-external-plugin-spec-builders",
56+
"kotlin-dsl-plugins",
57+
)
58+
59+
val generatedDirs = projectDir
60+
.walk()
61+
.onEnter { it.name !in doNotWalkDirs && it.parentFile.name !in generatedSrcDirs }
62+
.filter { it.isDirectory }
63+
.filter { it.parentFile.name in generatedSrcDirs }
2064
.flatMap { file ->
2165
file.walk().maxDepth(1).filter { it.isDirectory }.toList()
2266
}
23-
)
67+
.toSet()
68+
69+
// exclude .gradle, IDE dirs from nested projects (e.g. example & template projects)
70+
// so IntelliJ project-wide search isn't cluttered with irrelevant files
71+
val projectDirsToExclude = setOf(
72+
".idea",
73+
".gradle",
74+
"build",
75+
"gradle/wrapper",
76+
"ANDROID_SDK",
77+
"examples/versioning-multimodule-example/dokkatoo/previousDocVersions",
78+
"examples/versioning-multimodule-example/dokka/previousDocVersions",
79+
"modules/dokkatoo-plugin-integration-tests/example-project-data",
80+
)
81+
82+
val excludedProjectDirs = projectDir
83+
.walk()
84+
.onEnter { it.name !in doNotWalkDirs }
85+
// .filter { it.isDirectory }
86+
.filter { dir ->
87+
projectDirsToExclude.any {
88+
dir.invariantSeparatorsPath.endsWith("/$it")
89+
}
90+
}
91+
.toSet()
92+
93+
// can't use buildSet {} https://github.com/gradle/gradle/issues/28325
94+
return mutableSetOf<File>().apply {
95+
addAll(generatedDirs)
96+
addAll(excludedProjectDirs)
97+
}
98+
}
2499
}
25100

26101

27-
/** Sets a logo for project IDEs */
28-
fun Project.initIdeProjectLogo(
102+
/**
103+
* Sets a logo for project IDEs.
104+
*
105+
* (Avoid updating the logo during project configuration,
106+
* instead piggyback off a random task that runs on IJ import.)
107+
*/
108+
fun Task.initIdeProjectLogo(
29109
svgLogoPath: String
30110
) {
31-
val logoSvg = rootProject.layout.projectDirectory.file(svgLogoPath)
32-
val ideaDir = rootProject.layout.projectDirectory.dir(".idea")
33-
34-
if (
35-
logoSvg.asFile.exists()
36-
&& ideaDir.asFile.exists()
37-
&& !ideaDir.file("icon.png").asFile.exists()
38-
&& !ideaDir.file("icon.svg").asFile.exists()
39-
) {
40-
copy {
41-
from(logoSvg) { rename { "icon.svg" } }
42-
into(ideaDir)
111+
val fs = project.serviceOf<FileSystemOperations>()
112+
113+
val logoSvg = project.layout.projectDirectory.file(svgLogoPath)
114+
val ideaDir = project.layout.projectDirectory.dir(".idea")
115+
// don't register task inputs, we don't really care about up-to-date checks
116+
117+
doLast("initIdeProjectLogo") {
118+
if (
119+
logoSvg.asFile.exists()
120+
&& ideaDir.asFile.exists()
121+
&& !ideaDir.file("icon.png").asFile.exists()
122+
&& !ideaDir.file("icon.svg").asFile.exists()
123+
) {
124+
fs.copy {
125+
from(logoSvg) { rename { "icon.svg" } }
126+
into(ideaDir)
127+
}
43128
}
44129
}
45130
}

examples/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ The Dokka examples are synced automatically from the Dokka source code.
1010

1111
### Run locally
1212

13-
To run locally the examples locally you must first run `./gradlew assemble`
13+
To run locally the examples locally you must first run `./gradlew assemble publishToTestMavenRepo`
1414
in the root Dokkatoo repository project directory.
1515

1616
### Tests

examples/composite-build-example/dokkatoo/README.md

+14-7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
This project demonstrates how to use Dokkatoo to aggregate modules across a
44
[composite build projects](https://docs.gradle.org/current/userguide/composite_builds.html).
55

6-
> [!WARN]
6+
> [!WARNING]
77
> HTML is the only format that correctly supports multimodule aggregation.
88
> This is a limitation of Dokka.
99
@@ -21,18 +21,25 @@ There are 4 included builds.
2121

2222
To run locally, follow these steps.
2323

24-
1. In the root Dokkatoo project directory, run `./gradlew assemble`.
24+
1. In the root Dokkatoo project directory, run `./gradlew assemble publishToTestMavenRepo`.
2525
2. Either open the example project in an IDE, or `cd` into it.
2626
3. In the example project, run `gradle build`.
2727

2828
The docs will be generated into [`./docs/build/dokka/`](./docs/build/dokka/).
2929

30+
## Distinct module paths
31+
3032
> [!IMPORTANT]
3133
> When Dokkatoo aggregates modules, each module **must** have a distinct `modulePath`.
32-
> By default, this path is set to be the project path. With composite builds these
33-
> paths may not be distinct, causing Dokkatoo to overwrite modules.
3434
>
3535
> When using composite builds, project paths may clash, so make sure to set a distinct `modulePath`.
36-
>
37-
> This can be achieved in a convention plugin.
38-
> [build-logic/src/main/kotlin/dokka-convention.gradle.kts](./build-logic/src/main/kotlin/dokka-convention.gradle.kts).
36+
37+
The module path determines where each Dokka Module will be located within an aggregated
38+
Dokka Publication.
39+
40+
By default, the module path is set to be the project path, which are distinct for a single
41+
Gradle build. With composite builds the project paths may not be distinct, causing Dokkatoo
42+
to overwrite modules.
43+
44+
This can be achieved in a convention plugin.
45+
[build-logic/src/main/kotlin/dokka-convention.gradle.kts](./build-logic/src/main/kotlin/dokka-convention.gradle.kts).

examples/java-example/dokkatoo/README.md

+9
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
This project demonstrates how Dokkatoo can be applied to a pure Java project
44
to generate documentation.
55

6+
This project has multiple modules.
7+
8+
* [my-java-application](./my-java-application) is a Java Application
9+
* [my-java-application](./my-java-features) is a Java Library, demonstrating
10+
[feature variants](https://docs.gradle.org/current/userguide/feature_variants.html).
11+
* [my-java-application](./my-java-library) is a Java Library
12+
613
### Demonstration
714

815
To generate HTML documentation, run
@@ -11,6 +18,8 @@ To generate HTML documentation, run
1118
gradle :dokkatooGeneratePublicationHtml
1219
```
1320

21+
The HTML documentation will be generated into [build/dokka/html](./build/dokka/html/).
22+
1423
### Implementation details
1524

1625
Note that the `org.jetbrains.dokka:kotlin-as-java-plugin` Dokka Plugin

examples/java-example/dokkatoo/build.gradle.kts

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ plugins {
44

55
dependencies {
66
dokkatoo(project(":my-java-application"))
7+
dokkatoo(project(":my-java-features"))
78
dokkatoo(project(":my-java-library"))
89

910
dokkatooPluginHtml("org.jetbrains.dokka:templating-plugin")

examples/java-example/dokkatoo/buildSrc/src/main/kotlin/dokka-convention.gradle.kts

+1-4
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,5 @@ dokkatoo {
1717
}
1818

1919
dependencies {
20-
dokkatooPluginHtml("org.jetbrains.dokka:kotlin-as-java-plugin")
21-
dokkatooPluginJavadoc("org.jetbrains.dokka:kotlin-as-java-plugin")
22-
dokkatooPluginJekyll("org.jetbrains.dokka:kotlin-as-java-plugin")
23-
dokkatooPluginGfm("org.jetbrains.dokka:kotlin-as-java-plugin")
20+
dokkatooPlugin("org.jetbrains.dokka:kotlin-as-java-plugin")
2421
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
plugins {
2+
`java-library`
3+
}
4+
5+
val mongodbSourceSet = sourceSets.create("mongodbSupport") {
6+
java {
7+
srcDir("src/mongodb/java")
8+
}
9+
}
10+
11+
java {
12+
registerFeature("mongodbSupport") {
13+
usingSourceSet(mongodbSourceSet)
14+
}
15+
}

0 commit comments

Comments
 (0)