@@ -20,7 +20,6 @@ import java.text.*
20
20
import java.util.*
21
21
import javax.inject.Inject
22
22
23
- @Suppress(" DEPRECATION" )
24
23
open class PublishingConfiguration @Inject constructor(val objects : ObjectFactory ) {
25
24
var libraryRepoUrl: String? = null
26
25
@@ -30,30 +29,6 @@ open class PublishingConfiguration @Inject constructor(val objects: ObjectFactor
30
29
sonatype.isSelected = true
31
30
}
32
31
33
- @Deprecated(" Avoid publishing to bintray" )
34
- val bintray = BintrayConfiguration ()
35
- @Deprecated(" Avoid publishing to bintray" )
36
- fun bintray (configure : Action <BintrayConfiguration >) {
37
- configure.execute(bintray)
38
- }
39
- @Deprecated(" Avoid publishing to bintray" )
40
- fun bintray (configureClosure : Closure <BintrayConfiguration >) {
41
- ConfigureUtil .configureSelf(configureClosure, bintray)
42
- }
43
-
44
- @Deprecated(" Avoid publishing to bintray" )
45
- var bintrayDev: BintrayConfiguration ? = null
46
- @Deprecated(" Avoid publishing to bintray" )
47
- fun bintrayDev (configure : Action <BintrayConfiguration >) {
48
- if (bintrayDev == null ) bintrayDev = BintrayConfiguration ()
49
- configure.execute(bintrayDev)
50
- }
51
- @Deprecated(" Avoid publishing to bintray" )
52
- fun bintrayDev (configureClosure : Closure <BintrayConfiguration >) {
53
- if (bintrayDev == null ) bintrayDev = BintrayConfiguration ()
54
- ConfigureUtil .configureSelf(configureClosure, bintrayDev)
55
- }
56
-
57
32
var includeProjects: MutableList <String > = mutableListOf ()
58
33
fun include (vararg name : String ) {
59
34
includeProjects.addAll(name)
@@ -74,17 +49,6 @@ open class SonatypeConfiguration {
74
49
75
50
// TODO: Add space configuration
76
51
77
- // TODO: Remove all bintray-related configuration after migration
78
- open class BintrayConfiguration {
79
- var username: String? = null
80
- var password: String? = null
81
-
82
- var organization: String? = null
83
- var repository: String? = null
84
- var library: String? = null
85
-
86
- var publish: Boolean = false
87
- }
88
52
89
53
fun Project.configureProjectVersion () {
90
54
val ext = extensions.getByType(ExtraPropertiesExtension ::class .java)
@@ -106,10 +70,7 @@ fun Project.configureProjectVersion() {
106
70
logger.infra(" Configured root project version as '${project.version} '" )
107
71
}
108
72
109
- @Suppress(" DEPRECATION" )
110
73
internal fun Project.configurePublishing (publishing : PublishingConfiguration ) {
111
- val ext = extensions.getByType(ExtraPropertiesExtension ::class .java)
112
-
113
74
val buildLocal = " buildLocal"
114
75
val compositeBuildLocal = " publishTo${buildLocal.capitalize()} "
115
76
val rootBuildLocal = rootProject.tasks.maybeCreate(compositeBuildLocal).apply {
@@ -134,20 +95,6 @@ internal fun Project.configurePublishing(publishing: PublishingConfiguration) {
134
95
subproject.configureSigning()
135
96
}
136
97
}
137
- } else {
138
- // If bintray is configured, create version task and configure subprojects
139
- val bintray = if (ext.get(" infra.release" ) == true )
140
- publishing.bintray
141
- else
142
- publishing.bintrayDev ? : publishing.bintray
143
-
144
- val enableBintray = verifyBintrayConfiguration(bintray)
145
- if (enableBintray) {
146
- createBintrayVersionTask(bintray)
147
- includeProjects.forEach { subproject ->
148
- subproject.createBintrayRepository(bintray)
149
- }
150
- }
151
98
}
152
99
153
100
gradle.includedBuilds.forEach { includedBuild ->
@@ -203,63 +150,6 @@ private fun Project.createBuildRepository(name: String, rootBuildLocal: Task) {
203
150
}
204
151
}
205
152
206
- private fun Project.verifyBintrayConfiguration (bintray : BintrayConfiguration ): Boolean {
207
- fun missing (what : String ): Boolean {
208
- logger.warn(" INFRA: Bintray configuration is missing '$what ', publishing will not be possible" )
209
- return false
210
- }
211
-
212
- bintray.username ? : return missing(" username" )
213
- val password = bintray.password ? : return missing(" password" )
214
- if (password.startsWith(" credentialsJSON" )) {
215
- logger.warn(" INFRA: API key secure token was not expanded, publishing is not possible" )
216
- return false
217
- }
218
-
219
- if (password.trim() != password) {
220
- logger.warn(" INFRA: API key secure token was expanded to a value with whitespace around it." )
221
- }
222
-
223
- if (password.trim().isEmpty()) {
224
- logger.warn(" INFRA: API key secure token was expanded to empty string." )
225
- }
226
-
227
- val organization = bintray.organization ? : return missing(" organization" )
228
- val repository = bintray.repository ? : return missing(" repository" )
229
- val library = bintray.library ? : return missing(" library" )
230
-
231
- logger.infra(" Enabling publishing to Bintray for package '$library ' in '$organization /$repository ' repository in $this " )
232
- return true
233
- }
234
-
235
- private fun Project.createBintrayRepository (bintray : BintrayConfiguration ) {
236
- val username = bintray.username
237
- ? : throw KotlinInfrastructureException (" Cannot create version. User has not been specified." )
238
- val password = bintray.password
239
- ? : throw KotlinInfrastructureException (" Cannot create version. Password (API key) has not been specified." )
240
- val publish = if (bintray.publish) " 1" else " 0"
241
- extensions.configure(PublishingExtension ::class .java) { publishing ->
242
- publishing.repositories.maven { repo ->
243
- repo.name = " bintray"
244
- repo.url = URI (" ${bintray.api(" maven" )} /;publish=$publish " )
245
- repo.credentials { credentials ->
246
- credentials.username = username
247
- credentials.password = password.trim()
248
- }
249
- }
250
- }
251
- }
252
-
253
- private fun BintrayConfiguration.api (section : String ): String {
254
- val organization = organization
255
- ? : throw KotlinInfrastructureException (" Cannot create version. Organization has not been specified." )
256
- val repository = repository
257
- ? : throw KotlinInfrastructureException (" Cannot create version. Repository has not been specified." )
258
- val library = library
259
- ? : throw KotlinInfrastructureException (" Cannot create version. Package has not been specified." )
260
- return " https://api.bintray.com/$section /$organization /$repository /$library "
261
- }
262
-
263
153
private fun Project.createVersionPrepareTask (publishing : PublishingConfiguration ): TaskProvider <DefaultTask > {
264
154
return task<DefaultTask >(" publishPrepareVersion" ) {
265
155
group = PublishingPlugin .PUBLISH_TASK_GROUP
@@ -272,54 +162,6 @@ private fun Project.createVersionPrepareTask(publishing: PublishingConfiguration
272
162
}
273
163
}
274
164
275
- private fun Project.createBintrayVersionTask (bintray : BintrayConfiguration ) {
276
- val bintrayCreateVersion = task<DefaultTask >(" publishBintrayCreateVersion" ) {
277
- group = PublishingPlugin .PUBLISH_TASK_GROUP
278
- doFirst {
279
- val username = bintray.username
280
- ? : throw KotlinInfrastructureException (" Cannot create version. User has not been specified." )
281
- val password = bintray.password
282
- ? : throw KotlinInfrastructureException (" Cannot create version. Password (API key) has not been specified." )
283
- val organization = bintray.organization
284
- ? : throw KotlinInfrastructureException (" Cannot create version. Organization has not been specified." )
285
- val repository = bintray.repository
286
- ? : throw KotlinInfrastructureException (" Cannot create version. Repository has not been specified." )
287
- val library = bintray.library
288
- ? : throw KotlinInfrastructureException (" Cannot create version. Package has not been specified." )
289
-
290
- val url = URL (" ${bintray.api(" packages" )} /versions" )
291
- val now = Date ()
292
- val sdf = SimpleDateFormat (" yyyy-MM-dd'T'HH:mm:ss'Z'" ).apply { timeZone = TimeZone .getTimeZone(" UTC" ) }
293
- val date = sdf.format(now)
294
- val versionJson = """ {"name": "${project.version} ", "desc": "", "released":"$date "}"""
295
-
296
- val basicAuthorization = " $username :$password "
297
- val encodedAuthorization = Base64 .getEncoder().encodeToString(basicAuthorization.toByteArray())
298
-
299
- logger.lifecycle(" Creating version ${project.version} for package $library in $organization /$repository on bintray…" )
300
- logger.infra(" URL: $url " )
301
- logger.infra(" User: $username " )
302
- logger.infra(" Sending: $versionJson " )
303
- val connection = (url.openConnection() as HttpURLConnection ).apply {
304
- doOutput = true
305
- requestMethod = " POST"
306
- setRequestProperty(" Authorization" , " Basic $encodedAuthorization " );
307
- setRequestProperty(" Content-Type" , " application/json" )
308
- outputStream.bufferedWriter().use { it.write(versionJson) }
309
- }
310
-
311
- val code = connection.responseCode
312
- if (code >= 400 ) {
313
- val text = connection.errorStream.bufferedReader().readText()
314
- throw KotlinInfrastructureException (" Cannot create version. HTTP response $code : $text " )
315
- }
316
- }
317
- }
318
- tasks.named(" publishPrepareVersion" ).configure {
319
- it.dependsOn(bintrayCreateVersion)
320
- }
321
- }
322
-
323
165
324
166
private fun Project.verifySonatypeConfiguration (): Boolean {
325
167
fun missing (what : String ): Boolean {
0 commit comments