55@file:Suppress(" DuplicatedCode" , " MISSING_DEPENDENCY_CLASS" )
66
77pluginManagement {
8- fun logAbsentProperty (name : String , env : String ): Nothing? {
9- logger.info(" Property '$name ' (or env var '$env ') is not present for repository credentials." )
8+ val isCI = System .getenv(" TEAMCITY_VERSION" ) != null
109
11- return null
10+ fun requiredPropertyError (name : String , env : String ): Nothing {
11+ throw GradleException (" Property '$name ' (or env var '$env ') is not present for repository credentials." )
1212 }
1313
14- @Suppress(" RemoveRedundantQualifierName" )
1514 fun getLocalProperties (): java.util.Properties {
1615 return java.util.Properties ().apply {
1716 val propertiesDir = File (
@@ -29,22 +28,22 @@ pluginManagement {
2928 }
3029 }
3130
32- fun getSpaceUsername (): String? {
31+ fun getSpaceUsername (): String {
3332 val username = " kotlinx.rpc.team.space.username"
3433 val usernameEnv = " kotlinx_rpc_team_space_username"
3534 return getLocalProperties()[username] as String?
3635 ? : settings.providers.gradleProperty(username).orNull
3736 ? : System .getenv(usernameEnv)?.ifEmpty { null }
38- ? : logAbsentProperty (username, usernameEnv)
37+ ? : requiredPropertyError (username, usernameEnv)
3938 }
4039
41- fun getSpacePassword (): String? {
40+ fun getSpacePassword (): String {
4241 val password = " kotlinx.rpc.team.space.password"
4342 val passwordEnv = " kotlinx_rpc_team_space_password"
4443 return getLocalProperties()[password] as String?
4544 ? : settings.providers.gradleProperty(password).orNull
4645 ? : System .getenv(passwordEnv)?.ifEmpty { null }
47- ? : logAbsentProperty (password, passwordEnv)
46+ ? : requiredPropertyError (password, passwordEnv)
4847 }
4948
5049 /* *
@@ -57,14 +56,9 @@ pluginManagement {
5756 name = repoName.split(" -" ).joinToString(" " ) { it.replaceFirstChar { c -> c.titlecase() } }
5857 url = uri(" https://packages.jetbrains.team/maven/p/krpc/$repoName " )
5958
60- val username = getSpaceUsername()
61- val password = getSpacePassword()
62-
63- if (username != null && password != null ) {
64- credentials {
65- this .username = username
66- this .password = password
67- }
59+ credentials {
60+ username = getSpaceUsername()
61+ password = getSpacePassword()
6862 }
6963 }
7064 }
@@ -73,16 +67,21 @@ pluginManagement {
7367 fun RepositoryHandler.buildDepsEap () = jbTeamPackages(repoName = " build-deps-eap" )
7468
7569 repositories {
76- buildDeps()
77- buildDepsEap()
70+ if (isCI) {
71+ buildDeps()
72+ buildDepsEap()
73+ } else {
74+ mavenCentral()
75+ gradlePluginPortal()
76+ }
7877 }
7978}
8079
8180gradle.rootProject {
82- fun logAbsentProperty (name : String , env : String ): Nothing? {
83- logger.info(" Property '$name ' (or env var '$env ') is not present for repository credentials." )
81+ val isCI = System .getenv(" TEAMCITY_VERSION" ) != null
8482
85- return null
83+ fun requiredPropertyError (name : String , env : String ): Nothing {
84+ throw GradleException (" Property '$name ' (or env var '$env ') is not present for repository credentials." )
8685 }
8786
8887 fun getLocalProperties (): java.util.Properties {
@@ -102,22 +101,22 @@ gradle.rootProject {
102101 }
103102 }
104103
105- fun getSpaceUsername (): String? {
104+ fun getSpaceUsername (): String {
106105 val username = " kotlinx.rpc.team.space.username"
107106 val usernameEnv = " kotlinx_rpc_team_space_username"
108107 return getLocalProperties()[username] as String?
109108 ? : settings.providers.gradleProperty(username).orNull
110109 ? : System .getenv(usernameEnv)?.ifEmpty { null }
111- ? : logAbsentProperty (username, usernameEnv)
110+ ? : requiredPropertyError (username, usernameEnv)
112111 }
113112
114- fun getSpacePassword (): String? {
113+ fun getSpacePassword (): String {
115114 val password = " kotlinx.rpc.team.space.password"
116115 val passwordEnv = " kotlinx_rpc_team_space_password"
117116 return getLocalProperties()[password] as String?
118117 ? : settings.providers.gradleProperty(password).orNull
119118 ? : System .getenv(passwordEnv)?.ifEmpty { null }
120- ? : logAbsentProperty (password, passwordEnv)
119+ ? : requiredPropertyError (password, passwordEnv)
121120 }
122121
123122 /* *
@@ -131,14 +130,9 @@ gradle.rootProject {
131130
132131 url = uri(" https://packages.jetbrains.team/maven/p/krpc/$repoName " )
133132
134- val username = getSpaceUsername()
135- val password = getSpacePassword()
136-
137- if (username != null && password != null ) {
138- credentials {
139- this .username = username
140- this .password = password
141- }
133+ credentials {
134+ username = getSpaceUsername()
135+ password = getSpacePassword()
142136 }
143137 }
144138 }
@@ -149,13 +143,27 @@ gradle.rootProject {
149143 allprojects {
150144 buildscript {
151145 repositories {
152- buildDeps()
153- buildDepsEap()
146+ if (isCI) {
147+ buildDeps()
148+ buildDepsEap()
149+ } else {
150+ mavenCentral()
151+ gradlePluginPortal()
152+ }
154153 }
155154 }
155+
156156 repositories {
157- buildDeps()
158- buildDepsEap()
157+ if (isCI) {
158+ buildDeps()
159+ buildDepsEap()
160+ } else {
161+ mavenCentral()
162+ maven(" https://www.jetbrains.com/intellij-repository/releases" )
163+ maven(" https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev" )
164+ maven(" https://maven.pkg.jetbrains.space/public/p/ktor/eap" )
165+ maven(" https://maven.pkg.jetbrains.space/kotlin/p/kotlin/bootstrap" )
166+ }
159167 }
160168 }
161169}
0 commit comments