Skip to content

Commit

Permalink
Added build scan
Browse files Browse the repository at this point in the history
(cherry picked from commit 6f203b8)
  • Loading branch information
dkrasnoff committed Oct 10, 2024
1 parent 49c1cac commit ff76969
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 0 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,24 @@ $ ./gradlew build

3) Save branch with the name of the kotlin version. Pattern: `/^[0-9.]+$/` (optional)
4) Bump version on GitHub [releases](https://github.com/JetBrains/kotlin-compiler-server/releases) (optional)

### Gradle Build Scans

[Gradle Build Scans](https://scans.gradle.com/) can provide insights into an Kotlin Compiler Server Build.
JetBrains runs a [Gradle Develocity server](https://ge.jetbrains.com/scans?search.rootProjectNames=kotlinx-atomicfu).
that can be used to automatically upload reports.

To automatically opt in add the following to `$GRADLE_USER_HOME/gradle.properties`.

```properties
org.jetbrains.kotlin.compiler.server.build.scan.enabled=true
# optionally provide a username that will be attached to each report
org.jetbrains..kotlin.compiler.server.build.scan.username=John Wick
```

Also you need to create an access key:
```bash
./gradlew provisionDevelocityAccessKey
```

A Build Scan may contain identifiable information. See the Terms of Use https://gradle.com/legal/terms-of-use/.
4 changes: 4 additions & 0 deletions build-settings-logic/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
plugins {
`kotlin-dsl`
}

dependencies {
implementation(libs.gradle.develocity)
}
5 changes: 5 additions & 0 deletions build-settings-logic/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,9 @@ dependencyResolutionManagement {
mavenCentral()
gradlePluginPortal()
}
versionCatalogs {
create("libs") {
from(files("../gradle/libs.versions.toml"))
}
}
}
34 changes: 34 additions & 0 deletions build-settings-logic/src/main/kotlin/Utils.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright 2014-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/
import org.gradle.api.initialization.Settings
import org.gradle.api.provider.Provider


val buildingOnTeamCity: Boolean = System.getenv("TEAMCITY_VERSION") != null
val buildingOnGitHub: Boolean = System.getenv("GITHUB_ACTION") != null
val buildingOnCi: Boolean = System.getenv("CI") != null || buildingOnTeamCity || buildingOnGitHub

// NOTE: build scan properties are documented in README.md
val Settings.buildScanEnabled: Provider<Boolean>
get() =
kotlinCompilerServerProperty("build.scan.enabled", String::toBoolean)
.orElse(buildingOnCi)

internal const val DEFAULT_KOTLIN_COMPILER_SERVER_USER_NAME = "<default>"

/**
* Optionaly override the default name attached to a Build Scan.
*/
val Settings.buildScanUsername: Provider<String>
get() =
kotlinCompilerServerProperty("build.scan.username")
.orElse(DEFAULT_KOTLIN_COMPILER_SERVER_USER_NAME)
.map(String::trim)

internal fun Settings.kotlinCompilerServerProperty(name: String): Provider<String> =
providers.gradleProperty("org.jetbrains.kotlin.compiler.server.$name")

internal fun <T : Any> Settings.kotlinCompilerServerProperty(name: String, convert: (String) -> T): Provider<T> =
kotlinCompilerServerProperty(name).map(convert)

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// this is a settings convention plugin for Gradle Develocity

plugins {
id("com.gradle.develocity")
}

develocity {
if (buildScanEnabled.get()) {
val overriddenName = buildScanUsername.orNull
server = "https://ge.jetbrains.com/"
buildScan {
publishing.onlyIf { true }
capture {
fileFingerprints = true
buildLogging = true
uploadInBackground = true
}
obfuscation {
ipAddresses { _ -> listOf("0.0.0.0") }
hostname { _ -> "concealed" }
username { originalUsername ->
when {
buildingOnTeamCity -> "TeamCity"
buildingOnGitHub -> "GitHub"
buildingOnCi -> "CI"
!overriddenName.isNullOrBlank() && overriddenName != DEFAULT_KOTLIN_COMPILER_SERVER_USER_NAME -> overriddenName
overriddenName == DEFAULT_KOTLIN_COMPILER_SERVER_USER_NAME -> originalUsername
else -> "unknown"
}
}
}
}
}
}
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ skiko = "0.7.90"
jackson = "2.14.0"
hamcrest = "2.2"
compose = "1.6.0"
gradle-develocity = "3.17.5"

[libraries]
kotlin-reflect = { group = "org.jetbrains.kotlin", name = "kotlin-reflect", version.ref = "kotlin" }
Expand Down Expand Up @@ -62,6 +63,7 @@ compose-foundation = { group = "org.jetbrains.compose.foundation", name = "found
compose-material = { group = "org.jetbrains.compose.material", name = "material", version.ref = "compose" }
compose-components-resources = { group = "org.jetbrains.compose.components", name = "components-resources", version.ref = "compose" }
kotlin-serialization-plugin = {group= "org.jetbrains.kotlin", name="kotlin-serialization-compiler-plugin", version.ref = "kotlin"}
gradle-develocity = {group = "com.gradle", name= "develocity-gradle-plugin", version.ref = "gradle-develocity"}

[bundles]
kotlin-stdlib = ["kotlin-stdlib", "kotlin-stdlib-jdk7", "kotlin-stdlib-jdk8"]
Expand Down
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pluginManagement {
plugins {
id("kotlin-compiler-server-version-catalog")
id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0"
id("kotlin-compiler-server-build-scan")
}

include(":executors")
Expand Down

0 comments on commit ff76969

Please sign in to comment.