Skip to content

Commit 1bc1c4e

Browse files
committed
Fix Symlinks and Develocity (#361)
1 parent 023b7b3 commit 1bc1c4e

File tree

14 files changed

+317
-77
lines changed

14 files changed

+317
-77
lines changed

.puppeteerrc.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const {join} = require('path');
22

3-
const isCI = process.env.TEAMCITY_VERSION
3+
const isCI = process.env.TEAMCITY_VERSION || process.env.GITHUB_ACTIONS;
44

55
if (isCI) {
66
/**

compiler-plugin/gradle.properties

Lines changed: 0 additions & 1 deletion
This file was deleted.

compiler-plugin/gradle.properties

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#
2+
# Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3+
#
4+
5+
kotlin.code.style=official
6+
7+
kotlin.native.ignoreDisabledTargets=true
8+
9+
kotlin.daemon.jvmargs=-Xmx6g -XX:+HeapDumpOnOutOfMemoryError
10+
kotlin.daemon.useFallbackStrategy=false
11+
12+
org.gradle.jvmargs=-Xmx6g -XX:+HeapDumpOnOutOfMemoryError -XX:+UseParallelGC -XX:MaxMetaspaceSize=768m
13+
org.gradle.daemon=true
14+
org.gradle.parallel=true
15+
org.gradle.workers.max=8
16+
org.gradle.caching=true
17+
org.gradle.configuration-cache=true
18+
19+
org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled
20+
org.jetbrains.dokka.experimental.gradle.pluginMode.noWarn=true
21+
22+
# development mode for kotlinx.rpc gradle plugin. Uses local project paths to apply the compiler plugin
23+
kotlinx.rpc.plugin.internalDevelopment=true
24+
25+
# uncomment to debug compilation process
26+
#kotlin.compiler.execution.strategy=in-process
27+
28+
# Uncomment to skip attempts to publish Develocity build scans
29+
# Add this property to ~/.gradle/gradle.properties to avoid polluting git with unwanted changes
30+
#kotlinx.rpc.develocity.skipBuildScans=true
31+
32+
# Uncomment to skip adding git tags to Develocity build scan
33+
# Add this property to ~/.gradle/gradle.properties to avoid polluting git with unwanted changes
34+
#kotlinx.rpc.develocity.skipGitTags=true
35+
36+
# Uncomment to sync IDEA when working with Kotlin master builds
37+
#kotlinx.rpc.kotlinMasterBuild=true
38+
39+
# set to true when building IDE compiler plugin artifacts
40+
kotlinx.rpc.forIdeBuild=false

dokka-plugin/gradle.properties

Lines changed: 0 additions & 1 deletion
This file was deleted.

dokka-plugin/gradle.properties

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#
2+
# Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3+
#
4+
5+
kotlin.code.style=official
6+
7+
kotlin.native.ignoreDisabledTargets=true
8+
9+
kotlin.daemon.jvmargs=-Xmx6g -XX:+HeapDumpOnOutOfMemoryError
10+
kotlin.daemon.useFallbackStrategy=false
11+
12+
org.gradle.jvmargs=-Xmx6g -XX:+HeapDumpOnOutOfMemoryError -XX:+UseParallelGC -XX:MaxMetaspaceSize=768m
13+
org.gradle.daemon=true
14+
org.gradle.parallel=true
15+
org.gradle.workers.max=8
16+
org.gradle.caching=true
17+
org.gradle.configuration-cache=true
18+
19+
org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled
20+
org.jetbrains.dokka.experimental.gradle.pluginMode.noWarn=true
21+
22+
# development mode for kotlinx.rpc gradle plugin. Uses local project paths to apply the compiler plugin
23+
kotlinx.rpc.plugin.internalDevelopment=true
24+
25+
# uncomment to debug compilation process
26+
#kotlin.compiler.execution.strategy=in-process
27+
28+
# Uncomment to skip attempts to publish Develocity build scans
29+
# Add this property to ~/.gradle/gradle.properties to avoid polluting git with unwanted changes
30+
#kotlinx.rpc.develocity.skipBuildScans=true
31+
32+
# Uncomment to skip adding git tags to Develocity build scan
33+
# Add this property to ~/.gradle/gradle.properties to avoid polluting git with unwanted changes
34+
#kotlinx.rpc.develocity.skipGitTags=true
35+
36+
# Uncomment to sync IDEA when working with Kotlin master builds
37+
#kotlinx.rpc.kotlinMasterBuild=true
38+
39+
# set to true when building IDE compiler plugin artifacts
40+
kotlinx.rpc.forIdeBuild=false

gradle-conventions-settings/develocity/src/main/kotlin/conventions-develocity.settings.gradle.kts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ develocity {
1616
server.set(DEVELOCITY_SERVER)
1717

1818
buildScan {
19+
termsOfUseUrl = "https://gradle.com/terms-of-service"
20+
termsOfUseAgree = loadAgreement()
21+
1922
uploadInBackground.set(!isCIRun)
2023

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

38-
publishing.onlyIf { !skipBuildScans }
41+
publishing.onlyIf { termsOfUseAgree.get() == "yes" && !skipBuildScans }
3942
}
4043
}
4144

gradle-conventions-settings/develocity/src/main/kotlin/execute.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import org.gradle.api.initialization.Settings
66

7-
@Suppress("UnstableApiUsage")
87
fun Settings.execute(cmd: String): String {
98
return settings.providers.exec {
109
commandLine(cmd.split(" "))
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
* Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3+
*/
4+
5+
import org.gradle.api.GradleException
6+
import org.gradle.api.initialization.Settings
7+
import org.gradle.kotlin.dsl.extra
8+
import java.nio.file.Path
9+
import java.nio.file.StandardOpenOption
10+
import kotlin.io.path.bufferedWriter
11+
import kotlin.io.path.createFile
12+
import kotlin.io.path.exists
13+
14+
private const val TERMS_OF_USE_PROPERTY = "kotlinx.rpc.develocity.termsOfUseAgree"
15+
16+
fun Settings.loadAgreement(): String {
17+
if (isCIRun) {
18+
return "yes"
19+
}
20+
21+
val localProperties = extra["localProperties"] as? java.util.Properties
22+
?: throw GradleException("'local.properties' property not found")
23+
24+
when (val value = localProperties.getProperty(TERMS_OF_USE_PROPERTY)) {
25+
"yes", "no" -> {
26+
return value
27+
}
28+
29+
"" -> {
30+
throw GradleException(
31+
"'$TERMS_OF_USE_PROPERTY' property is not set in file://local.properties'. " +
32+
"Please set this property to 'yes' or 'no'."
33+
)
34+
}
35+
36+
null -> {
37+
val globalRootDir = extra["globalRootDir"] as? String
38+
?: throw GradleException("'globalRootDir' property not found. Contact developers.")
39+
40+
val propFile = Path.of(globalRootDir).resolve("local.properties")
41+
if (!propFile.exists()) {
42+
propFile.createFile()
43+
}
44+
45+
propFile.bufferedWriter(Charsets.UTF_8, bufferSize = 1024, StandardOpenOption.APPEND).use { writer ->
46+
writer.appendLine()
47+
writer.appendLine("# Terms of Gradle use agreement: https://gradle.com/terms-of-service")
48+
writer.appendLine("# Set to yes or no")
49+
writer.appendLine("# Only needed for JetBrains maintainers")
50+
writer.appendLine("$TERMS_OF_USE_PROPERTY=")
51+
}
52+
53+
throw GradleException(
54+
"'$TERMS_OF_USE_PROPERTY' property not found in file://local.properties . " +
55+
"Please add this property and set it to 'yes' or 'no'."
56+
)
57+
}
58+
59+
else -> {
60+
throw GradleException(
61+
"Invalid value for '$TERMS_OF_USE_PROPERTY' property: $value. " +
62+
"Please set this property to 'yes' or 'no'."
63+
)
64+
}
65+
}
66+
}

gradle-conventions-settings/develocity/src/main/kotlin/params.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ const val DEVELOCITY_SERVER = "https://ge.jetbrains.com"
66
const val GITHUB_REPO = "https://github.com/Kotlin/kotlinx-rpc"
77
const val TEAMCITY_URL = "https://krpc.teamcity.com"
88

9-
val isCIRun = System.getenv("TEAMCITY_VERSION") != null
9+
val isCIRun = System.getenv("TEAMCITY_VERSION") != null || System.getenv("GITHUB_ACTIONS") != null

gradle-conventions-settings/src/main/kotlin/conventions-repositories.settings.gradle.kts

Lines changed: 73 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ pluginManagement {
3838
.removeSuffix("/gradle-conventions-settings")
3939
.removeSuffix("/compiler-plugin")
4040
.removeSuffix("/gradle-plugin")
41+
.removeSuffix("/dokka-plugin")
4142
)
4243
val localFile = File(propertiesDir, "local.properties")
4344
if (localFile.exists()) {
@@ -100,94 +101,99 @@ pluginManagement {
100101
}
101102
}
102103

103-
gradle.rootProject {
104-
fun findGlobalRootDirPath(): java.nio.file.Path {
105-
var path = file(".").toPath().toAbsolutePath()
104+
fun findGlobalRootDirPath(): java.nio.file.Path {
105+
var path = file(".").toPath().toAbsolutePath()
106106

107-
// we assume that the 'versions-root' folder can only be present in the root folder
108-
while (
109-
java.nio.file.Files.newDirectoryStream(path).use { it.toList() }.none {
110-
java.nio.file.Files.isDirectory(it) && it.fileName.toString() == "versions-root"
111-
}
112-
) {
113-
path = path.parent ?: error("Unable to find root path for kotlinx.rpc project")
107+
// we assume that the 'versions-root' folder can only be present in the root folder
108+
while (
109+
java.nio.file.Files.newDirectoryStream(path).use { it.toList() }.none {
110+
java.nio.file.Files.isDirectory(it) && it.fileName.toString() == "versions-root"
114111
}
115-
116-
return path
112+
) {
113+
path = path.parent ?: error("Unable to find root path for kotlinx.rpc project")
117114
}
118115

119-
fun logAbsentProperty(name: String): Nothing? {
120-
logger.info("Property '$name' is not present for repository credentials.")
116+
return path
117+
}
121118

122-
return null
123-
}
119+
fun logAbsentProperty(name: String): Nothing? {
120+
logger.info("Property '$name' is not present for repository credentials.")
124121

125-
fun getEnv(propertyName: String): String? = System.getenv(
126-
propertyName.replace(".", "_").uppercase()
127-
)?.ifEmpty { null }
122+
return null
123+
}
128124

129-
fun getLocalProperties(): java.util.Properties {
130-
return java.util.Properties().apply {
131-
val propertiesDir = File(
132-
rootDir.path
133-
.removeSuffix("/gradle-conventions")
134-
.removeSuffix("/gradle-conventions-settings")
135-
.removeSuffix("/compiler-plugin")
136-
.removeSuffix("/gradle-plugin")
137-
)
138-
val localFile = File(propertiesDir, "local.properties")
139-
if (localFile.exists()) {
140-
localFile.inputStream().use { load(it) }
141-
}
125+
fun getEnv(propertyName: String): String? = System.getenv(
126+
propertyName.replace(".", "_").uppercase()
127+
)?.ifEmpty { null }
128+
129+
fun getLocalProperties(): java.util.Properties {
130+
return java.util.Properties().apply {
131+
val propertiesDir = File(
132+
rootDir.path
133+
.removeSuffix("/gradle-conventions")
134+
.removeSuffix("/gradle-conventions-settings")
135+
.removeSuffix("/compiler-plugin")
136+
.removeSuffix("/gradle-plugin")
137+
.removeSuffix("/dokka-plugin")
138+
)
139+
val localFile = File(propertiesDir, "local.properties")
140+
if (localFile.exists()) {
141+
localFile.inputStream().use { load(it) }
142142
}
143143
}
144+
}
144145

145-
fun java.util.Properties.isUsingProxyRepositories(): Boolean {
146-
val useProxyProperty = this["kotlinx.rpc.useProxyRepositories"] as String?
147-
return useProxyProperty == null || useProxyProperty == "true"
148-
}
146+
fun java.util.Properties.isUsingProxyRepositories(): Boolean {
147+
val useProxyProperty = this["kotlinx.rpc.useProxyRepositories"] as String?
148+
return useProxyProperty == null || useProxyProperty == "true"
149+
}
149150

150-
fun getSpacePassword(): String? {
151-
val password = "kotlinx.rpc.team.space.password"
152-
return getLocalProperties()[password] as String?
153-
?: settings.providers.gradleProperty(password).orNull
154-
?: getEnv(password)
155-
?: logAbsentProperty(password)
156-
}
151+
fun getSpacePassword(): String? {
152+
val password = "kotlinx.rpc.team.space.password"
153+
return getLocalProperties()[password] as String?
154+
?: settings.providers.gradleProperty(password).orNull
155+
?: getEnv(password)
156+
?: logAbsentProperty(password)
157+
}
157158

158-
/**
159-
* Creates a publishing repository targeting Space Packages on jetbrains.team.
160-
*
161-
* @param repoName the name of the Space Packages repository
162-
*/
163-
fun RepositoryHandler.jbTeamPackages(repoName: String) {
164-
maven {
165-
name = repoName.split("-").joinToString("") { it.replaceFirstChar { c -> c.titlecase() } }
166-
url = uri("https://packages.jetbrains.team/maven/p/krpc/$repoName")
159+
/**
160+
* Creates a publishing repository targeting Space Packages on jetbrains.team.
161+
*
162+
* @param repoName the name of the Space Packages repository
163+
*/
164+
fun RepositoryHandler.jbTeamPackages(repoName: String) {
165+
maven {
166+
name = repoName.split("-").joinToString("") { it.replaceFirstChar { c -> c.titlecase() } }
167+
url = uri("https://packages.jetbrains.team/maven/p/krpc/$repoName")
167168

168-
val spacePassword = getSpacePassword()
169+
val spacePassword = getSpacePassword()
169170

170-
if (spacePassword != null) {
171-
credentials(HttpHeaderCredentials::class.java) {
172-
name = "Authorization"
173-
value = "Bearer $spacePassword"
174-
}
171+
if (spacePassword != null) {
172+
credentials(HttpHeaderCredentials::class.java) {
173+
name = "Authorization"
174+
value = "Bearer $spacePassword"
175+
}
175176

176-
authentication {
177-
create<HttpHeaderAuthentication>("http_auth_header")
178-
}
179-
} else {
180-
logger.info("Skipping adding credentials for Space repository '$repoName'")
177+
authentication {
178+
create<HttpHeaderAuthentication>("http_auth_header")
181179
}
180+
} else {
181+
logger.info("Skipping adding credentials for Space repository '$repoName'")
182182
}
183183
}
184+
}
184185

185-
fun RepositoryHandler.buildDeps() = jbTeamPackages(repoName = "build-deps")
186-
fun RepositoryHandler.buildDepsEap() = jbTeamPackages(repoName = "build-deps-eap")
186+
fun RepositoryHandler.buildDeps() = jbTeamPackages(repoName = "build-deps")
187+
fun RepositoryHandler.buildDepsEap() = jbTeamPackages(repoName = "build-deps-eap")
187188

188-
allprojects {
189-
val localProps = getLocalProperties()
189+
val localProps = getLocalProperties()
190+
191+
settings.extra["spacePassword"] = getSpacePassword()
192+
settings.extra["localProperties"] = localProps
193+
settings.extra["useProxyRepositories"] = localProps.isUsingProxyRepositories()
190194

195+
gradle.rootProject {
196+
allprojects {
191197
this.extra["spacePassword"] = getSpacePassword()
192198
this.extra["localProperties"] = localProps
193199
this.extra["useProxyRepositories"] = localProps.isUsingProxyRepositories()

gradle-conventions-settings/src/main/kotlin/conventions-version-resolution.settings.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ fun findGlobalRootDirPath(start: Path): Path {
6464
}
6565
}
6666

67+
settings.extra["globalRootDir"] = path.toAbsolutePath().toString()
68+
6769
return path
6870
}
6971

0 commit comments

Comments
 (0)