Skip to content

Commit 6901eb9

Browse files
committed
Remove deprecated bintray publishing functionality
1 parent 68843c2 commit 6901eb9

File tree

4 files changed

+2
-177
lines changed

4 files changed

+2
-177
lines changed

main/resources/teamcity/settings.kts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,6 @@ fun Project.deployVersion() = BuildType {
142142
params {
143143
// enable editing of this configuration to set up things
144144
param("teamcity.ui.settings.readOnly", "false")
145-
param("bintray-user", bintrayUserName)
146-
password("bintray-key", bintrayToken)
147145
param(versionSuffixParameter, "dev-%build.counter%")
148146
param("reverse.dep.$BUILD_CREATE_STAGING_REPO_ABSOLUTE_ID.system.libs.repo.description", libraryStagingRepoDescription)
149147
param("env.libs.repository.id", "%dep.$BUILD_CREATE_STAGING_REPO_ABSOLUTE_ID.env.libs.repository.id%")
@@ -158,7 +156,7 @@ fun Project.deployVersion() = BuildType {
158156
gradle {
159157
name = "Verify Gradle Configuration"
160158
tasks = "clean publishPrepareVersion"
161-
gradleParams = "--info --stacktrace -P$versionSuffixParameter=%$versionSuffixParameter% -P$releaseVersionParameter=%$releaseVersionParameter% -PbintrayApiKey=%bintray-key% -PbintrayUser=%bintray-user%"
159+
gradleParams = "--info --stacktrace -P$versionSuffixParameter=%$versionSuffixParameter% -P$releaseVersionParameter=%$releaseVersionParameter%"
162160
buildFile = ""
163161
jdkHome = "%env.$jdk%"
164162
}
@@ -188,8 +186,6 @@ fun Project.deploy(platform: Platform, configureBuild: BuildType) = buildType("D
188186
params {
189187
param(versionSuffixParameter, "${configureBuild.depParamRefs[versionSuffixParameter]}")
190188
param(releaseVersionParameter, "${configureBuild.depParamRefs[releaseVersionParameter]}")
191-
param("bintray-user", bintrayUserName)
192-
password("bintray-key", bintrayToken)
193189
param("env.libs.repository.id", "%dep.$BUILD_CREATE_STAGING_REPO_ABSOLUTE_ID.env.libs.repository.id%")
194190
}
195191

@@ -202,7 +198,7 @@ fun Project.deploy(platform: Platform, configureBuild: BuildType) = buildType("D
202198
name = "Deploy ${platform.buildTypeName()} Binaries"
203199
jdkHome = "%env.$jdk%"
204200
jvmArgs = "-Xmx1g"
205-
gradleParams = "--info --stacktrace -P$versionSuffixParameter=%$versionSuffixParameter% -P$releaseVersionParameter=%$releaseVersionParameter% -PbintrayApiKey=%bintray-key% -PbintrayUser=%bintray-user%"
201+
gradleParams = "--info --stacktrace -P$versionSuffixParameter=%$versionSuffixParameter% -P$releaseVersionParameter=%$releaseVersionParameter%"
206202
tasks = "clean publish"
207203
buildFile = ""
208204
gradleWrapperPath = ""

main/resources/teamcity/utils.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ const val versionSuffixParameter = "versionSuffix"
99
const val teamcitySuffixParameter = "teamcitySuffix"
1010
const val releaseVersionParameter = "releaseVersion"
1111

12-
const val bintrayUserName = "<<BINTRAY_USER>>"
13-
const val bintrayToken = "<<BINTRAY_TOKEN>>"
1412
const val libraryStagingRepoDescription = "<<LIBRARY_STAGING_REPO_DESCRIPTION>>"
1513

1614
val platforms = Platform.values()

main/src/kotlinx/team/infra/Publishing.kt

Lines changed: 0 additions & 158 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import java.text.*
2020
import java.util.*
2121
import javax.inject.Inject
2222

23-
@Suppress("DEPRECATION")
2423
open class PublishingConfiguration @Inject constructor(val objects: ObjectFactory) {
2524
var libraryRepoUrl: String? = null
2625

@@ -30,30 +29,6 @@ open class PublishingConfiguration @Inject constructor(val objects: ObjectFactor
3029
sonatype.isSelected = true
3130
}
3231

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-
5732
var includeProjects: MutableList<String> = mutableListOf()
5833
fun include(vararg name: String) {
5934
includeProjects.addAll(name)
@@ -74,17 +49,6 @@ open class SonatypeConfiguration {
7449

7550
// TODO: Add space configuration
7651

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-
}
8852

8953
fun Project.configureProjectVersion() {
9054
val ext = extensions.getByType(ExtraPropertiesExtension::class.java)
@@ -106,10 +70,7 @@ fun Project.configureProjectVersion() {
10670
logger.infra("Configured root project version as '${project.version}'")
10771
}
10872

109-
@Suppress("DEPRECATION")
11073
internal fun Project.configurePublishing(publishing: PublishingConfiguration) {
111-
val ext = extensions.getByType(ExtraPropertiesExtension::class.java)
112-
11374
val buildLocal = "buildLocal"
11475
val compositeBuildLocal = "publishTo${buildLocal.capitalize()}"
11576
val rootBuildLocal = rootProject.tasks.maybeCreate(compositeBuildLocal).apply {
@@ -134,20 +95,6 @@ internal fun Project.configurePublishing(publishing: PublishingConfiguration) {
13495
subproject.configureSigning()
13596
}
13697
}
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-
}
15198
}
15299

153100
gradle.includedBuilds.forEach { includedBuild ->
@@ -203,63 +150,6 @@ private fun Project.createBuildRepository(name: String, rootBuildLocal: Task) {
203150
}
204151
}
205152

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-
263153
private fun Project.createVersionPrepareTask(publishing: PublishingConfiguration): TaskProvider<DefaultTask> {
264154
return task<DefaultTask>("publishPrepareVersion") {
265155
group = PublishingPlugin.PUBLISH_TASK_GROUP
@@ -272,54 +162,6 @@ private fun Project.createVersionPrepareTask(publishing: PublishingConfiguration
272162
}
273163
}
274164

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-
323165

324166
private fun Project.verifySonatypeConfiguration(): Boolean {
325167
fun missing(what: String): Boolean {

main/src/kotlinx/team/infra/TeamCity.kt

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@ import java.io.*
66
open class TeamCityConfiguration {
77
var libraryStagingRepoDescription: String? = null
88

9-
@Deprecated("Avoid publishing to bintray")
10-
var bintrayUser: String? = null
11-
@Deprecated("Avoid publishing to bintray")
12-
var bintrayToken: String? = null
13-
149
var jdk = "JDK_18_x64"
1510
}
1611

@@ -40,15 +35,9 @@ fun Project.configureTeamCityConfigGenerator(teamcity: TeamCityConfiguration) {
4035
}
4136
@Suppress("DEPRECATION")
4237
copyResource(teamcityDir, "utils.kt") { text ->
43-
val bintrayUser = teamcity.bintrayUser
44-
?: "%env.BINTRAY_USER%" //throw KotlinInfrastructureException("TeamCity configuration should specify `bintrayUser` parameter")
45-
val bintrayToken = teamcity.bintrayToken
46-
?: "%env.BINTRAY_API_KEY%" //throw KotlinInfrastructureException("TeamCity configuration should specify `bintrayToken` parameter")
4738
val libraryStagingRepoDescription = teamcity.libraryStagingRepoDescription
4839
?: throw KotlinInfrastructureException("TeamCity configuration should specify `libraryStagingRepoDescription`: the library description for staging repositories")
4940
text
50-
.replace("<<BINTRAY_USER>>", bintrayUser)
51-
.replace("<<BINTRAY_TOKEN>>", bintrayToken)
5241
.replace("<<LIBRARY_STAGING_REPO_DESCRIPTION>>", libraryStagingRepoDescription)
5342
.replace("<<JDK>>", teamcity.jdk)
5443
}

0 commit comments

Comments
 (0)