2
2
* Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3
3
*/
4
4
5
- @file:Suppress(" DuplicatedCode" , " MISSING_DEPENDENCY_CLASS" )
6
-
7
- import java.util.*
5
+ @file:Suppress(" DuplicatedCode" )
8
6
9
7
pluginManagement {
10
8
fun logAbsentProperty (name : String ): Nothing? {
@@ -13,36 +11,16 @@ pluginManagement {
13
11
return null
14
12
}
15
13
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
-
34
14
fun getSpaceUsername (): String? {
35
15
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
38
17
? : System .getenv(username)?.ifEmpty { null }
39
18
? : logAbsentProperty(username)
40
19
}
41
20
42
21
fun getSpacePassword (): String? {
43
22
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
46
24
? : System .getenv(password)?.ifEmpty { null }
47
25
? : logAbsentProperty(password)
48
26
}
@@ -56,9 +34,15 @@ pluginManagement {
56
34
maven {
57
35
name = repoName.split(" -" ).joinToString(" " ) { it.replaceFirstChar { c -> c.titlecase() } }
58
36
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
+ }
62
46
}
63
47
}
64
48
}
@@ -79,35 +63,16 @@ gradle.rootProject {
79
63
return null
80
64
}
81
65
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
-
99
66
fun getSpaceUsername (): String? {
100
67
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
103
69
? : System .getenv(username)?.ifEmpty { null }
104
70
? : logAbsentProperty(username)
105
71
}
106
72
107
73
fun getSpacePassword (): String? {
108
74
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
111
76
? : System .getenv(password)?.ifEmpty { null }
112
77
? : logAbsentProperty(password)
113
78
}
@@ -122,9 +87,15 @@ gradle.rootProject {
122
87
name = repoName.split(" -" ).joinToString(" " ) { it.replaceFirstChar { c -> c.titlecase() } }
123
88
124
89
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
+ }
128
99
}
129
100
}
130
101
}
0 commit comments