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
97pluginManagement {
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 }
0 commit comments