Skip to content

Commit 73ec3a6

Browse files
committed
Update Gradle Distribution url, added CI checks for yarn and npm distros
1 parent e10c87f commit 73ec3a6

File tree

9 files changed

+67
-104
lines changed

9 files changed

+67
-104
lines changed

build.gradle.kts

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44

55
import org.jetbrains.kotlin.gradle.plugin.getKotlinPluginVersion
6-
import util.kotlinVersionParsed
6+
import util.getSpacePassword
77
import util.libs
88

99
plugins {
@@ -64,34 +64,38 @@ val executeNpmLogin by tasks.registering {
6464

6565
// To prevent leaking of credentials in VCS on dev machine use the build directory config file
6666
val buildYarnConfigFile = File(project.rootDir, "build/js/.yarnrc")
67-
val buildYarnYmlConfigFile = File(project.rootDir, "build/js/.yarnrc.yml")
67+
val buildNpmConfigFile = File(project.rootDir, "build/js/.npmrc")
6868

69-
val spaceUsername: String? = getSpaceUsername()
7069
val spacePassword: String? = getSpacePassword()
7170

7271
doLast {
73-
if (spaceUsername == null || spacePassword == null) {
74-
return@doLast
75-
}
76-
77-
if (spacePassword.split(".").size != 3) {
78-
error("Unexpected Space Token format")
79-
}
72+
val outputYarnText = """
73+
registry: "$registryUrl"
74+
""".trimIndent()
8075

81-
val outputYarnYmlText = """
82-
npmRegistryServer: "$registryUrl"
83-
npmAlwaysAuth: true
84-
npmAuthToken: "$spacePassword"
76+
var outputNpmText = """
77+
registry: "$registryUrl"
8578
""".trimIndent()
8679

80+
if (spacePassword != null) {
81+
if (spacePassword.split(".").size != 3) {
82+
throw GradleException("Unexpected Space Token format")
83+
}
84+
85+
outputNpmText += System.lineSeparator() + """
86+
always-auth: true
87+
${registryUrl.removePrefix("https:")}:_authToken=$spacePassword
88+
""".trimIndent()
89+
}
90+
8791
buildYarnConfigFile.createNewFile()
88-
buildYarnConfigFile.writeText("registry: $registryUrl")
89-
buildYarnYmlConfigFile.createNewFile()
90-
buildYarnYmlConfigFile.writeText(outputYarnYmlText)
92+
buildYarnConfigFile.writeText(outputYarnText)
93+
buildNpmConfigFile.createNewFile()
94+
buildNpmConfigFile.writeText(outputNpmText)
9195
}
9296

9397
outputs.file(buildYarnConfigFile).withPropertyName("buildOutputYarnFile")
94-
outputs.file(buildYarnYmlConfigFile).withPropertyName("buildOutputYarnYmlFile")
98+
outputs.file(buildNpmConfigFile).withPropertyName("buildOutputNpmFile")
9599
}
96100

97101
plugins.withType(org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin::class.java).configureEach {

gradle-conventions-settings/develocity/build.gradle.kts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,6 @@ configurations.configureEach {
1515
}
1616
}
1717

18-
repositories {
19-
mavenCentral()
20-
gradlePluginPortal()
21-
}
22-
2318
dependencies {
2419
implementation("com.gradle:develocity-gradle-plugin:3.17")
2520
implementation("com.gradle:common-custom-user-data-gradle-plugin:2.0.2")

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

Lines changed: 23 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
* Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

5-
@file:Suppress("DuplicatedCode", "MISSING_DEPENDENCY_CLASS")
6-
7-
import java.util.*
5+
@file:Suppress("DuplicatedCode")
86

97
pluginManagement {
108
fun logAbsentProperty(name: String): Nothing? {
@@ -13,36 +11,16 @@ pluginManagement {
1311
return null
1412
}
1513

16-
@Suppress("RemoveRedundantQualifierName")
17-
fun getLocalProperties(): java.util.Properties {
18-
return java.util.Properties().apply {
19-
val propertiesDir = File(
20-
rootDir.path
21-
.removeSuffix("/gradle-conventions")
22-
.removeSuffix("/gradle-conventions-settings")
23-
.removeSuffix("/ksp-plugin")
24-
.removeSuffix("/compiler-plugin")
25-
.removeSuffix("/gradle-plugin")
26-
)
27-
val localFile = File(propertiesDir, "local.properties")
28-
if (localFile.exists()) {
29-
localFile.inputStream().use { load(it) }
30-
}
31-
}
32-
}
33-
3414
fun getSpaceUsername(): String? {
3515
val username = "kotlinx.rpc.team.space.username"
36-
return getLocalProperties()[username] as String?
37-
?: settings.providers.gradleProperty(username).orNull
16+
return settings.providers.gradleProperty(username).orNull
3817
?: System.getenv(username)?.ifEmpty { null }
3918
?: logAbsentProperty(username)
4019
}
4120

4221
fun getSpacePassword(): String? {
4322
val password = "kotlinx.rpc.team.space.password"
44-
return getLocalProperties()[password] as String?
45-
?: settings.providers.gradleProperty(password).orNull
23+
return settings.providers.gradleProperty(password).orNull
4624
?: System.getenv(password)?.ifEmpty { null }
4725
?: logAbsentProperty(password)
4826
}
@@ -56,9 +34,15 @@ pluginManagement {
5634
maven {
5735
name = repoName.split("-").joinToString("") { it.replaceFirstChar { c -> c.titlecase() } }
5836
url = uri("https://packages.jetbrains.team/maven/p/krpc/$repoName")
59-
credentials {
60-
username = getSpaceUsername()
61-
password = getSpacePassword()
37+
38+
val spaceUsername = getSpaceUsername()
39+
val spacePassword = getSpacePassword()
40+
41+
if (spaceUsername != null && spacePassword != null) {
42+
credentials {
43+
username = spaceUsername
44+
password = spacePassword
45+
}
6246
}
6347
}
6448
}
@@ -79,35 +63,16 @@ gradle.rootProject {
7963
return null
8064
}
8165

82-
fun getLocalProperties(): Properties {
83-
return Properties().apply {
84-
val propertiesDir = File(
85-
rootDir.path
86-
.removeSuffix("/gradle-conventions")
87-
.removeSuffix("/gradle-conventions-settings")
88-
.removeSuffix("/ksp-plugin")
89-
.removeSuffix("/compiler-plugin")
90-
.removeSuffix("/gradle-plugin")
91-
)
92-
val localFile = File(propertiesDir, "local.properties")
93-
if (localFile.exists()) {
94-
localFile.inputStream().use { load(it) }
95-
}
96-
}
97-
}
98-
9966
fun getSpaceUsername(): String? {
10067
val username = "kotlinx.rpc.team.space.username"
101-
return getLocalProperties()[username] as String?
102-
?: settings.providers.gradleProperty(username).orNull
68+
return settings.providers.gradleProperty(username).orNull
10369
?: System.getenv(username)?.ifEmpty { null }
10470
?: logAbsentProperty(username)
10571
}
10672

10773
fun getSpacePassword(): String? {
10874
val password = "kotlinx.rpc.team.space.password"
109-
return getLocalProperties()[password] as String?
110-
?: settings.providers.gradleProperty(password).orNull
75+
return settings.providers.gradleProperty(password).orNull
11176
?: System.getenv(password)?.ifEmpty { null }
11277
?: logAbsentProperty(password)
11378
}
@@ -122,9 +87,15 @@ gradle.rootProject {
12287
name = repoName.split("-").joinToString("") { it.replaceFirstChar { c -> c.titlecase() } }
12388

12489
url = uri("https://packages.jetbrains.team/maven/p/krpc/$repoName")
125-
credentials {
126-
username = getSpaceUsername()
127-
password = getSpacePassword()
90+
91+
val spaceUsername = getSpaceUsername()
92+
val spacePassword = getSpacePassword()
93+
94+
if (spaceUsername != null && spacePassword != null) {
95+
credentials {
96+
username = spaceUsername
97+
password = spacePassword
98+
}
12899
}
129100
}
130101
}

gradle-conventions-settings/src/main/kotlin/util/properties.kt

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,43 +7,25 @@
77
package util
88

99
import org.gradle.api.Project
10-
import java.io.File
1110

1211
fun Project.logAbsentProperty(name: String): Nothing? {
1312
logger.info("Property '$name' is not present.")
1413

1514
return null
1615
}
1716

18-
fun Project.getLocalProperties(): java.util.Properties {
19-
return java.util.Properties().apply {
20-
val propertiesDir = File(
21-
rootDir.path
22-
.removeSuffix("/gradle-conventions")
23-
.removeSuffix("/gradle-conventions-settings")
24-
.removeSuffix("/ksp-plugin")
25-
.removeSuffix("/compiler-plugin")
26-
.removeSuffix("/gradle-plugin")
27-
)
28-
val localFile = File(propertiesDir, "local.properties")
29-
if (localFile.exists()) {
30-
localFile.inputStream().use { load(it) }
31-
}
32-
}
33-
}
17+
private const val SPACE_USERNAME = "kotlinx.rpc.team.space.username"
3418

3519
fun Project.getSpaceUsername(): String? {
36-
val username = "kotlinx.rpc.team.space.username"
37-
return getLocalProperties()[username] as String?
38-
?: providers.gradleProperty(username).orNull
39-
?: System.getenv(username)?.ifEmpty { null }
40-
?: logAbsentProperty(username)
20+
return providers.gradleProperty(SPACE_USERNAME).orNull
21+
?: System.getenv(SPACE_USERNAME)?.ifEmpty { null }
22+
?: logAbsentProperty(SPACE_USERNAME)
4123
}
4224

25+
private const val SPACE_PASSWORD = "kotlinx.rpc.team.space.password"
26+
4327
fun Project.getSpacePassword(): String? {
44-
val password = "kotlinx.rpc.team.space.password"
45-
return getLocalProperties()[password] as String?
46-
?: providers.gradleProperty(password).orNull
47-
?: System.getenv(password)?.ifEmpty { null }
48-
?: logAbsentProperty(password)
28+
return providers.gradleProperty(SPACE_PASSWORD).orNull
29+
?: System.getenv(SPACE_PASSWORD)?.ifEmpty { null }
30+
?: logAbsentProperty(SPACE_USERNAME)
4931
}

gradle-conventions/src/main/kotlin/compiler-specific-module.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ fun NamedDomainObjectContainer<KotlinSourceSet>.applyCompilerSpecificSourceSets(
3535

3636
logger.lifecycle(
3737
"${project.name}: included version specific source sets: " +
38-
"${core.name}${mostSpecificApplicable?.let { ", $name" } ?: ""}"
38+
"[${core.name}${mostSpecificApplicable?.let { ", $name" } ?: ""}]"
3939
)
4040

4141
val newSourceDirectories = listOfNotNull(core, mostSpecificApplicable)

gradle/wrapper/gradle-wrapper.properties

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

55
distributionBase=GRADLE_USER_HOME
66
distributionPath=wrapper/dists
7-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
7+
distributionUrl=https\://packages.jetbrains.team/files/p/krpc/build-deps/distributions/gradle-8.10.2-bin.zip
88
zipStoreBase=GRADLE_USER_HOME
99
zipStorePath=wrapper/dists

krpc/krpc-test/build.gradle.kts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ applyAtomicfuPlugin()
1818

1919
kotlin {
2020
sourceSets {
21+
commonMain {
22+
dependencies {
23+
// Workaround for
24+
// KLIB resolver: Could not find "org.jetbrains.kotlinx:atomicfu"
25+
api(libs.atomicfu)
26+
}
27+
}
28+
2129
jvmMain {
2230
dependencies {
2331
api(projects.krpc.krpcCore)

settings.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ pluginManagement {
1111

1212
includeBuild("gradle-plugin")
1313

14+
apply(from = "gradle-conventions-settings/src/main/kotlin/conventions-repositories.settings.gradle.kts")
15+
1416
resolutionStrategy {
1517
eachPlugin {
1618
if (requested.id.id == "kotlinx-atomicfu") {

versions-root/libs.versions.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ kotlin-js-wrappers = { module = "org.jetbrains.kotlin-wrappers:kotlin-js", versi
9696
gradle-kotlin-dsl-pluigns = { module = "org.gradle.kotlin:gradle-kotlin-dsl-plugins", version.ref = "gradle-kotlin-dsl" }
9797
intellij-util = { module = "com.jetbrains.intellij.platform:util", version.ref = "intellij" }
9898
gradle-doctor-plugin = { module = "com.osacky.doctor:doctor-plugin", version.ref = "gradle-doctor" }
99+
atomicfu = { module = "org.jetbrains.kotlinx:atomicfu", version.ref = "atomicfu" }
99100

100101
[plugins]
101102
kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin-lang" }

0 commit comments

Comments
 (0)