Skip to content

Commit fce617f

Browse files
authored
Parallelize tasks within same project (#482)
Allow tasks within the `library` project to run parallel to each other by enabling CC. This reduces the execution time of `check` builds by allowing work units of the 3 test suites to run parallel. Migration to Dokka v2 is required for CC compatibility. `downloadApiSpec` is made CC-compatible. `localSpecPath` is removed as a `file://` URI could easily be used with `remoteSpecUrl`. PR jobs are fixed for signing key-related error in `dry-run-publish-library`, probably caused by the new publishing plugin (#479) trying to read it at configuration time. ``` * What went wrong: Could not read PGP secret key > secret key ring doesn't start with secret key tag: tag 0xffffffff ``` ([job][1]) #### References - https://www.liutikas.net/2025/07/29/Parallel-Bits.html [1]: https://github.com/gabrielfeo/develocity-api-kotlin/actions/runs/17633648327/job/50106146533
1 parent 7613d5a commit fce617f

File tree

6 files changed

+47
-35
lines changed

6 files changed

+47
-35
lines changed

.github/workflows/pr.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,13 @@ jobs:
3939
uses: ./.github/workflows/publish-javadoc.yml
4040
with:
4141
dry_run: true
42+
secrets: inherit
4243

4344
dry-run-publish-library:
4445
uses: ./.github/workflows/publish-library.yml
4546
with:
4647
dry_run: true
48+
secrets: inherit
4749

4850
dry-run-update-api-spec:
4951
uses: ./.github/workflows/update-api-spec.yml

.github/workflows/publish-javadoc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
uses: ./.github/actions/build
3232
with:
3333
args: >-
34-
dokkaHtml
34+
dokkaGenerate
3535
'-Pversion=${{ github.ref_name }}'
3636
artifact-name: 'docs'
3737
path-to-upload: "library/build/dokka/html/**/*"

build-logic/gradle.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
kotlin.daemon.jvmargs=-Xmx1g
2+
org.gradle.configuration-cache=true
3+
org.gradle.configuration-cache.parallel=true

build-logic/src/main/kotlin/com/gabrielfeo/develocity-api-code-generation.gradle.kts

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,17 @@ plugins {
88
id("org.openapi.generator")
99
}
1010

11-
val localSpecPath = providers.gradleProperty("localSpecPath")
12-
val remoteSpecUrl = providers.gradleProperty("remoteSpecUrl").orElse(
13-
providers.gradleProperty("develocity.version").map { geVersion ->
14-
val majorVersion = geVersion.substringBefore('.').toInt()
15-
val specName = when {
16-
majorVersion <= 2023 -> "gradle-enterprise-$geVersion-api.yaml"
17-
else -> "develocity-$geVersion-api.yaml"
18-
}
19-
"https://docs.gradle.com/enterprise/api-manual/ref/$specName"
20-
}
21-
)
22-
2311
val downloadApiSpec by tasks.registering {
24-
onlyIf { !localSpecPath.isPresent() }
12+
val remoteSpecUrl = providers.gradleProperty("remoteSpecUrl").orElse(
13+
providers.gradleProperty("develocity.version").map { geVersion ->
14+
val majorVersion = geVersion.substringBefore('.').toInt()
15+
val specName = when {
16+
majorVersion <= 2023 -> "gradle-enterprise-$geVersion-api.yaml"
17+
else -> "develocity-$geVersion-api.yaml"
18+
}
19+
"https://docs.gradle.com/enterprise/api-manual/ref/$specName"
20+
}
21+
)
2522
val spec = resources.text.fromUri(remoteSpecUrl)
2623
val specName = remoteSpecUrl.map { it.substringAfterLast('/') }
2724
val outFile = project.layout.buildDirectory.file(specName)
@@ -35,11 +32,7 @@ val downloadApiSpec by tasks.registering {
3532

3633
openApiGenerate {
3734
generatorName = "kotlin"
38-
val spec = when {
39-
localSpecPath.isPresent() -> localSpecPath.map { rootProject.file(it).absolutePath }
40-
else -> downloadApiSpec.map { it.outputs.files.first().absolutePath }
41-
}
42-
inputSpec = spec
35+
inputSpec = downloadApiSpec.map { it.outputs.files.first().absolutePath }
4336
val generateDir = project.layout.buildDirectory.dir("generated-api")
4437
.map { it.asFile.absolutePath }
4538
outputDir = generateDir

build-logic/src/main/kotlin/com/gabrielfeo/published-kotlin-jvm-library.gradle.kts

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package com.gabrielfeo
22

3-
import org.jetbrains.dokka.DokkaConfiguration.Visibility.PUBLIC
4-
import org.jetbrains.dokka.gradle.DokkaTask
5-
import java.net.URL
3+
import org.jetbrains.dokka.gradle.DokkaExtension
4+
import org.jetbrains.dokka.gradle.engine.parameters.VisibilityModifier
5+
import java.net.URI
66

77
plugins {
88
id("com.gabrielfeo.kotlin-jvm-library")
@@ -19,33 +19,44 @@ java {
1919
withJavadocJar()
2020
}
2121

22-
val kotlinSourceRoot = file("src/main/kotlin")
23-
tasks.withType<DokkaTask>().configureEach {
24-
dokkaSourceSets.all {
25-
sourceRoot(kotlinSourceRoot)
22+
23+
configure<DokkaExtension> {
24+
val kotlinSourceRoot = file("src/main/kotlin")
25+
val repoUrlSuffix = "/blob/$version/${kotlinSourceRoot.relativeTo(rootDir)}"
26+
val repoUrl = providers.gradleProperty("repo.url")
27+
.map { URI("$it$repoUrlSuffix").toString() }
28+
dokkaSourceSets.configureEach {
29+
sourceRoots.from(kotlinSourceRoot)
2630
sourceLink {
2731
localDirectory.set(kotlinSourceRoot)
28-
remoteUrl = providers.gradleProperty("repo.url")
29-
.map { URL("$it/blob/$version/${kotlinSourceRoot.relativeTo(rootDir)}") }
32+
remoteUrl(repoUrl)
3033
remoteLineSuffix = "#L"
3134
}
3235
jdkVersion = java.toolchain.languageVersion.map { it.asInt() }
36+
documentedVisibilities.add(VisibilityModifier.Public)
3337
suppressGeneratedFiles = false
34-
documentedVisibilities = setOf(PUBLIC)
3538
perPackageOption {
3639
matchingRegex = """.*\.internal.*"""
3740
suppress = true
3841
}
39-
externalDocumentationLink("https://kotlinlang.org/api/kotlinx.coroutines/")
40-
externalDocumentationLink("https://square.github.io/okhttp/5.x/okhttp/")
41-
externalDocumentationLink("https://square.github.io/retrofit/2.x/retrofit/")
42-
externalDocumentationLink("https://square.github.io/moshi/1.x/moshi/")
43-
externalDocumentationLink("https://square.github.io/moshi/1.x/moshi-kotlin/")
42+
listOf(
43+
"https://kotlinlang.org/api/kotlinx.coroutines",
44+
"https://square.github.io/okhttp/5.x/okhttp",
45+
"https://square.github.io/retrofit/2.x/retrofit",
46+
"https://square.github.io/moshi/1.x/moshi",
47+
"https://square.github.io/moshi/1.x/moshi-kotlin",
48+
).forEach { url ->
49+
val name = url.trim('/').substringAfterLast('/')
50+
externalDocumentationLinks.register(name) {
51+
url(url)
52+
packageListUrl("$url/package-list")
53+
}
54+
}
4455
}
4556
}
4657

4758
tasks.named<Jar>("javadocJar") {
48-
from(tasks.dokkaHtml)
59+
from(tasks.dokkaGenerate)
4960
}
5061

5162
mavenPublishing {

gradle.properties

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@ repo.url=https://github.com/gabrielfeo/develocity-api-kotlin
66
org.gradle.parallel=true
77
org.gradle.jvmargs=-Xmx5g
88
org.gradle.caching=true
9+
org.gradle.configuration-cache=true
10+
org.gradle.configuration-cache.parallel=true
911
# Becomes default in Gradle 9.0
1012
org.gradle.kotlin.dsl.skipMetadataVersionCheck=false
1113
# Explicitly added at different versions, due to Kotlin/kotlin-jupyter#462
1214
kotlin.jupyter.add.api=false
1315
kotlin.jupyter.add.scanner=false
1416
kotlin.jupyter.add.testkit=false
17+
org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled
18+
org.jetbrains.dokka.experimental.gradle.pluginMode.noWarn=true

0 commit comments

Comments
 (0)