Skip to content

Commit 6f203b8

Browse files
committed
Added build scan
1 parent 8c5c311 commit 6f203b8

File tree

7 files changed

+101
-0
lines changed

7 files changed

+101
-0
lines changed

README.md

+21
Original file line numberDiff line numberDiff line change
@@ -129,3 +129,24 @@ $ ./gradlew build
129129

130130
3) Save branch with the name of the kotlin version. Pattern: `/^[0-9.]+$/` (optional)
131131
4) Bump version on GitHub [releases](https://github.com/JetBrains/kotlin-compiler-server/releases) (optional)
132+
133+
### Gradle Build Scans
134+
135+
[Gradle Build Scans](https://scans.gradle.com/) can provide insights into an Kotlin Compiler Server Build.
136+
JetBrains runs a [Gradle Develocity server](https://ge.jetbrains.com/scans?search.rootProjectNames=kotlinx-atomicfu).
137+
that can be used to automatically upload reports.
138+
139+
To automatically opt in add the following to `$GRADLE_USER_HOME/gradle.properties`.
140+
141+
```properties
142+
org.jetbrains.kotlin.compiler.server.build.scan.enabled=true
143+
# optionally provide a username that will be attached to each report
144+
org.jetbrains..kotlin.compiler.server.build.scan.username=John Wick
145+
```
146+
147+
Also you need to create an access key:
148+
```bash
149+
./gradlew provisionDevelocityAccessKey
150+
```
151+
152+
A Build Scan may contain identifiable information. See the Terms of Use https://gradle.com/legal/terms-of-use/.

build-settings-logic/build.gradle.kts

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
plugins {
22
`kotlin-dsl`
3+
}
4+
5+
dependencies {
6+
implementation(libs.gradle.develocity)
37
}

build-settings-logic/settings.gradle.kts

+5
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,9 @@ dependencyResolutionManagement {
77
mavenCentral()
88
gradlePluginPortal()
99
}
10+
versionCatalogs {
11+
create("libs") {
12+
from(files("../gradle/libs.versions.toml"))
13+
}
14+
}
1015
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright 2014-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3+
*/
4+
import org.gradle.api.initialization.Settings
5+
import org.gradle.api.provider.Provider
6+
7+
8+
val buildingOnTeamCity: Boolean = System.getenv("TEAMCITY_VERSION") != null
9+
val buildingOnGitHub: Boolean = System.getenv("GITHUB_ACTION") != null
10+
val buildingOnCi: Boolean = System.getenv("CI") != null || buildingOnTeamCity || buildingOnGitHub
11+
12+
// NOTE: build scan properties are documented in README.md
13+
val Settings.buildScanEnabled: Provider<Boolean>
14+
get() =
15+
kotlinCompilerServerProperty("build.scan.enabled", String::toBoolean)
16+
.orElse(buildingOnCi)
17+
18+
internal const val DEFAULT_KOTLIN_COMPILER_SERVER_USER_NAME = "<default>"
19+
20+
/**
21+
* Optionaly override the default name attached to a Build Scan.
22+
*/
23+
val Settings.buildScanUsername: Provider<String>
24+
get() =
25+
kotlinCompilerServerProperty("build.scan.username")
26+
.orElse(DEFAULT_KOTLIN_COMPILER_SERVER_USER_NAME)
27+
.map(String::trim)
28+
29+
internal fun Settings.kotlinCompilerServerProperty(name: String): Provider<String> =
30+
providers.gradleProperty("org.jetbrains.kotlin.compiler.server.$name")
31+
32+
internal fun <T : Any> Settings.kotlinCompilerServerProperty(name: String, convert: (String) -> T): Provider<T> =
33+
kotlinCompilerServerProperty(name).map(convert)
34+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// this is a settings convention plugin for Gradle Develocity
2+
3+
plugins {
4+
id("com.gradle.develocity")
5+
}
6+
7+
develocity {
8+
if (buildScanEnabled.get()) {
9+
val overriddenName = buildScanUsername.orNull
10+
server = "https://ge.jetbrains.com/"
11+
buildScan {
12+
publishing.onlyIf { true }
13+
capture {
14+
fileFingerprints = true
15+
buildLogging = true
16+
uploadInBackground = true
17+
}
18+
obfuscation {
19+
ipAddresses { _ -> listOf("0.0.0.0") }
20+
hostname { _ -> "concealed" }
21+
username { originalUsername ->
22+
when {
23+
buildingOnTeamCity -> "TeamCity"
24+
buildingOnGitHub -> "GitHub"
25+
buildingOnCi -> "CI"
26+
!overriddenName.isNullOrBlank() && overriddenName != DEFAULT_KOTLIN_COMPILER_SERVER_USER_NAME -> overriddenName
27+
overriddenName == DEFAULT_KOTLIN_COMPILER_SERVER_USER_NAME -> originalUsername
28+
else -> "unknown"
29+
}
30+
}
31+
}
32+
}
33+
}
34+
}

gradle/libs.versions.toml

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ skiko = "0.7.90"
1919
jackson = "2.14.0"
2020
hamcrest = "2.2"
2121
compose = "1.6.0"
22+
gradle-develocity = "3.17.5"
2223

2324
[libraries]
2425
kotlin-reflect = { group = "org.jetbrains.kotlin", name = "kotlin-reflect", version.ref = "kotlin" }
@@ -62,6 +63,7 @@ compose-foundation = { group = "org.jetbrains.compose.foundation", name = "found
6263
compose-material = { group = "org.jetbrains.compose.material", name = "material", version.ref = "compose" }
6364
compose-components-resources = { group = "org.jetbrains.compose.components", name = "components-resources", version.ref = "compose" }
6465
kotlin-serialization-plugin = {group= "org.jetbrains.kotlin", name="kotlin-serialization-compiler-plugin", version.ref = "kotlin"}
66+
gradle-develocity = {group = "com.gradle", name= "develocity-gradle-plugin", version.ref = "gradle-develocity"}
6567

6668
[bundles]
6769
kotlin-stdlib = ["kotlin-stdlib", "kotlin-stdlib-jdk7", "kotlin-stdlib-jdk8"]

settings.gradle.kts

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ pluginManagement {
1010
plugins {
1111
id("kotlin-compiler-server-version-catalog")
1212
id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0"
13+
id("kotlin-compiler-server-build-scan")
1314
}
1415

1516
include(":executors")

0 commit comments

Comments
 (0)