Skip to content

Fix Symlinks and Develocity #361

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .puppeteerrc.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const {join} = require('path');

const isCI = process.env.TEAMCITY_VERSION
const isCI = process.env.TEAMCITY_VERSION || process.env.GITHUB_ACTIONS;

if (isCI) {
/**
Expand Down
1 change: 0 additions & 1 deletion compiler-plugin/gradle.properties

This file was deleted.

40 changes: 40 additions & 0 deletions compiler-plugin/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#
# Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
#

kotlin.code.style=official

kotlin.native.ignoreDisabledTargets=true

kotlin.daemon.jvmargs=-Xmx6g -XX:+HeapDumpOnOutOfMemoryError
kotlin.daemon.useFallbackStrategy=false

org.gradle.jvmargs=-Xmx6g -XX:+HeapDumpOnOutOfMemoryError -XX:+UseParallelGC -XX:MaxMetaspaceSize=768m
org.gradle.daemon=true
org.gradle.parallel=true
org.gradle.workers.max=8
org.gradle.caching=true
org.gradle.configuration-cache=true

org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled
org.jetbrains.dokka.experimental.gradle.pluginMode.noWarn=true

# development mode for kotlinx.rpc gradle plugin. Uses local project paths to apply the compiler plugin
kotlinx.rpc.plugin.internalDevelopment=true

# uncomment to debug compilation process
#kotlin.compiler.execution.strategy=in-process

# Uncomment to skip attempts to publish Develocity build scans
# Add this property to ~/.gradle/gradle.properties to avoid polluting git with unwanted changes
#kotlinx.rpc.develocity.skipBuildScans=true

# Uncomment to skip adding git tags to Develocity build scan
# Add this property to ~/.gradle/gradle.properties to avoid polluting git with unwanted changes
#kotlinx.rpc.develocity.skipGitTags=true

# Uncomment to sync IDEA when working with Kotlin master builds
#kotlinx.rpc.kotlinMasterBuild=true

# set to true when building IDE compiler plugin artifacts
kotlinx.rpc.forIdeBuild=false
1 change: 0 additions & 1 deletion dokka-plugin/gradle.properties

This file was deleted.

40 changes: 40 additions & 0 deletions dokka-plugin/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#
# Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
#

kotlin.code.style=official

kotlin.native.ignoreDisabledTargets=true

kotlin.daemon.jvmargs=-Xmx6g -XX:+HeapDumpOnOutOfMemoryError
kotlin.daemon.useFallbackStrategy=false

org.gradle.jvmargs=-Xmx6g -XX:+HeapDumpOnOutOfMemoryError -XX:+UseParallelGC -XX:MaxMetaspaceSize=768m
org.gradle.daemon=true
org.gradle.parallel=true
org.gradle.workers.max=8
org.gradle.caching=true
org.gradle.configuration-cache=true

org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled
org.jetbrains.dokka.experimental.gradle.pluginMode.noWarn=true

# development mode for kotlinx.rpc gradle plugin. Uses local project paths to apply the compiler plugin
kotlinx.rpc.plugin.internalDevelopment=true

# uncomment to debug compilation process
#kotlin.compiler.execution.strategy=in-process

# Uncomment to skip attempts to publish Develocity build scans
# Add this property to ~/.gradle/gradle.properties to avoid polluting git with unwanted changes
#kotlinx.rpc.develocity.skipBuildScans=true

# Uncomment to skip adding git tags to Develocity build scan
# Add this property to ~/.gradle/gradle.properties to avoid polluting git with unwanted changes
#kotlinx.rpc.develocity.skipGitTags=true

# Uncomment to sync IDEA when working with Kotlin master builds
#kotlinx.rpc.kotlinMasterBuild=true

# set to true when building IDE compiler plugin artifacts
kotlinx.rpc.forIdeBuild=false
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ develocity {
server.set(DEVELOCITY_SERVER)

buildScan {
termsOfUseUrl = "https://gradle.com/terms-of-service"
termsOfUseAgree = loadAgreement()

uploadInBackground.set(!isCIRun)

// obfuscate NIC since we don't want to expose user real IP (will be relevant without VPN)
Expand All @@ -35,7 +38,7 @@ develocity {
.getOrElse("false")
.toBooleanStrict()

publishing.onlyIf { !skipBuildScans }
publishing.onlyIf { termsOfUseAgree.get() == "yes" && !skipBuildScans }
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import org.gradle.api.initialization.Settings

@Suppress("UnstableApiUsage")
fun Settings.execute(cmd: String): String {
return settings.providers.exec {
commandLine(cmd.split(" "))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/

import org.gradle.api.GradleException
import org.gradle.api.initialization.Settings
import org.gradle.kotlin.dsl.extra
import java.nio.file.Path
import java.nio.file.StandardOpenOption
import kotlin.io.path.bufferedWriter
import kotlin.io.path.createFile
import kotlin.io.path.exists

private const val TERMS_OF_USE_PROPERTY = "kotlinx.rpc.develocity.termsOfUseAgree"

fun Settings.loadAgreement(): String {
if (isCIRun) {
return "yes"
}

val localProperties = extra["localProperties"] as? java.util.Properties
?: throw GradleException("'local.properties' property not found")

when (val value = localProperties.getProperty(TERMS_OF_USE_PROPERTY)) {
"yes", "no" -> {
return value
}

"" -> {
throw GradleException(
"'$TERMS_OF_USE_PROPERTY' property is not set in file://local.properties'. " +
"Please set this property to 'yes' or 'no'."
)
}

null -> {
val globalRootDir = extra["globalRootDir"] as? String
?: throw GradleException("'globalRootDir' property not found. Contact developers.")

val propFile = Path.of(globalRootDir).resolve("local.properties")
if (!propFile.exists()) {
propFile.createFile()
}

propFile.bufferedWriter(Charsets.UTF_8, bufferSize = 1024, StandardOpenOption.APPEND).use { writer ->
writer.appendLine()
writer.appendLine("# Terms of Gradle use agreement: https://gradle.com/terms-of-service")
writer.appendLine("# Set to yes or no")
writer.appendLine("# Only needed for JetBrains maintainers")
writer.appendLine("$TERMS_OF_USE_PROPERTY=")
}

throw GradleException(
"'$TERMS_OF_USE_PROPERTY' property not found in file://local.properties . " +
"Please add this property and set it to 'yes' or 'no'."
)
}

else -> {
throw GradleException(
"Invalid value for '$TERMS_OF_USE_PROPERTY' property: $value. " +
"Please set this property to 'yes' or 'no'."
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ const val DEVELOCITY_SERVER = "https://ge.jetbrains.com"
const val GITHUB_REPO = "https://github.com/Kotlin/kotlinx-rpc"
const val TEAMCITY_URL = "https://krpc.teamcity.com"

val isCIRun = System.getenv("TEAMCITY_VERSION") != null
val isCIRun = System.getenv("TEAMCITY_VERSION") != null || System.getenv("GITHUB_ACTIONS") != null
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ pluginManagement {
.removeSuffix("/gradle-conventions-settings")
.removeSuffix("/compiler-plugin")
.removeSuffix("/gradle-plugin")
.removeSuffix("/dokka-plugin")
)
val localFile = File(propertiesDir, "local.properties")
if (localFile.exists()) {
Expand Down Expand Up @@ -100,94 +101,99 @@ pluginManagement {
}
}

gradle.rootProject {
fun findGlobalRootDirPath(): java.nio.file.Path {
var path = file(".").toPath().toAbsolutePath()
fun findGlobalRootDirPath(): java.nio.file.Path {
var path = file(".").toPath().toAbsolutePath()

// we assume that the 'versions-root' folder can only be present in the root folder
while (
java.nio.file.Files.newDirectoryStream(path).use { it.toList() }.none {
java.nio.file.Files.isDirectory(it) && it.fileName.toString() == "versions-root"
}
) {
path = path.parent ?: error("Unable to find root path for kotlinx.rpc project")
// we assume that the 'versions-root' folder can only be present in the root folder
while (
java.nio.file.Files.newDirectoryStream(path).use { it.toList() }.none {
java.nio.file.Files.isDirectory(it) && it.fileName.toString() == "versions-root"
}

return path
) {
path = path.parent ?: error("Unable to find root path for kotlinx.rpc project")
}

fun logAbsentProperty(name: String): Nothing? {
logger.info("Property '$name' is not present for repository credentials.")
return path
}

return null
}
fun logAbsentProperty(name: String): Nothing? {
logger.info("Property '$name' is not present for repository credentials.")

fun getEnv(propertyName: String): String? = System.getenv(
propertyName.replace(".", "_").uppercase()
)?.ifEmpty { null }
return null
}

fun getLocalProperties(): java.util.Properties {
return java.util.Properties().apply {
val propertiesDir = File(
rootDir.path
.removeSuffix("/gradle-conventions")
.removeSuffix("/gradle-conventions-settings")
.removeSuffix("/compiler-plugin")
.removeSuffix("/gradle-plugin")
)
val localFile = File(propertiesDir, "local.properties")
if (localFile.exists()) {
localFile.inputStream().use { load(it) }
}
fun getEnv(propertyName: String): String? = System.getenv(
propertyName.replace(".", "_").uppercase()
)?.ifEmpty { null }

fun getLocalProperties(): java.util.Properties {
return java.util.Properties().apply {
val propertiesDir = File(
rootDir.path
.removeSuffix("/gradle-conventions")
.removeSuffix("/gradle-conventions-settings")
.removeSuffix("/compiler-plugin")
.removeSuffix("/gradle-plugin")
.removeSuffix("/dokka-plugin")
)
val localFile = File(propertiesDir, "local.properties")
if (localFile.exists()) {
localFile.inputStream().use { load(it) }
}
}
}

fun java.util.Properties.isUsingProxyRepositories(): Boolean {
val useProxyProperty = this["kotlinx.rpc.useProxyRepositories"] as String?
return useProxyProperty == null || useProxyProperty == "true"
}
fun java.util.Properties.isUsingProxyRepositories(): Boolean {
val useProxyProperty = this["kotlinx.rpc.useProxyRepositories"] as String?
return useProxyProperty == null || useProxyProperty == "true"
}

fun getSpacePassword(): String? {
val password = "kotlinx.rpc.team.space.password"
return getLocalProperties()[password] as String?
?: settings.providers.gradleProperty(password).orNull
?: getEnv(password)
?: logAbsentProperty(password)
}
fun getSpacePassword(): String? {
val password = "kotlinx.rpc.team.space.password"
return getLocalProperties()[password] as String?
?: settings.providers.gradleProperty(password).orNull
?: getEnv(password)
?: logAbsentProperty(password)
}

/**
* Creates a publishing repository targeting Space Packages on jetbrains.team.
*
* @param repoName the name of the Space Packages repository
*/
fun RepositoryHandler.jbTeamPackages(repoName: String) {
maven {
name = repoName.split("-").joinToString("") { it.replaceFirstChar { c -> c.titlecase() } }
url = uri("https://packages.jetbrains.team/maven/p/krpc/$repoName")
/**
* Creates a publishing repository targeting Space Packages on jetbrains.team.
*
* @param repoName the name of the Space Packages repository
*/
fun RepositoryHandler.jbTeamPackages(repoName: String) {
maven {
name = repoName.split("-").joinToString("") { it.replaceFirstChar { c -> c.titlecase() } }
url = uri("https://packages.jetbrains.team/maven/p/krpc/$repoName")

val spacePassword = getSpacePassword()
val spacePassword = getSpacePassword()

if (spacePassword != null) {
credentials(HttpHeaderCredentials::class.java) {
name = "Authorization"
value = "Bearer $spacePassword"
}
if (spacePassword != null) {
credentials(HttpHeaderCredentials::class.java) {
name = "Authorization"
value = "Bearer $spacePassword"
}

authentication {
create<HttpHeaderAuthentication>("http_auth_header")
}
} else {
logger.info("Skipping adding credentials for Space repository '$repoName'")
authentication {
create<HttpHeaderAuthentication>("http_auth_header")
}
} else {
logger.info("Skipping adding credentials for Space repository '$repoName'")
}
}
}

fun RepositoryHandler.buildDeps() = jbTeamPackages(repoName = "build-deps")
fun RepositoryHandler.buildDepsEap() = jbTeamPackages(repoName = "build-deps-eap")
fun RepositoryHandler.buildDeps() = jbTeamPackages(repoName = "build-deps")
fun RepositoryHandler.buildDepsEap() = jbTeamPackages(repoName = "build-deps-eap")

allprojects {
val localProps = getLocalProperties()
val localProps = getLocalProperties()

settings.extra["spacePassword"] = getSpacePassword()
settings.extra["localProperties"] = localProps
settings.extra["useProxyRepositories"] = localProps.isUsingProxyRepositories()

gradle.rootProject {
allprojects {
this.extra["spacePassword"] = getSpacePassword()
this.extra["localProperties"] = localProps
this.extra["useProxyRepositories"] = localProps.isUsingProxyRepositories()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ fun findGlobalRootDirPath(start: Path): Path {
}
}

settings.extra["globalRootDir"] = path.toAbsolutePath().toString()

return path
}

Expand Down
Loading
Loading