intellij-plugin-structure/build.gradle.kts [234:282]: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - val packSonatypeCentralBundle by registering(Zip::class) { group = "publishing" dependsOn(":publishAllPublicationsToArtifactsRepository") from(layout.buildDirectory.dir("artifacts/maven")) archiveFileName.set("bundle.zip") destinationDirectory.set(layout.buildDirectory) } val publishMavenToCentralPortal by registering { group = "publishing" dependsOn(packSonatypeCentralBundle) doLast { val uriBase = "https://central.sonatype.com/api/v1/publisher/upload" val publishingType = "USER_MANAGED" val deploymentName = "${project.name}-$version" val uri = "$uriBase?name=$deploymentName&publishingType=$publishingType" val centralPortalUserName: String? by project val centralPortalToken: String? by project val base64Auth = Base64 .getEncoder() .encode("$centralPortalUserName:$centralPortalToken".toByteArray()) .toString(Charsets.UTF_8) val bundleFile = packSonatypeCentralBundle.get().archiveFile.get().asFile println("Sending request to $uri...") val client = OkHttpClient() val request = Request.Builder() .url(uri) .header("Authorization", "Bearer $base64Auth") .post( MultipartBody.Builder() .setType(MultipartBody.FORM) .addFormDataPart("bundle", bundleFile.name, bundleFile.asRequestBody()) .build() ) .build() client.newCall(request).execute().use { response -> val statusCode = response.code println("Upload status code: $statusCode") println("Upload result: ${response.body!!.string()}") if (statusCode != 201) { error("Upload error to Central repository. Status code $statusCode.") - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - intellij-plugin-verifier/build.gradle.kts [185:233]: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - val packSonatypeCentralBundle by registering(Zip::class) { group = "publishing" dependsOn(":publishAllPublicationsToArtifactsRepository") from(layout.buildDirectory.dir("artifacts/maven")) archiveFileName.set("bundle.zip") destinationDirectory.set(layout.buildDirectory) } val publishMavenToCentralPortal by registering { group = "publishing" dependsOn(packSonatypeCentralBundle) doLast { val uriBase = "https://central.sonatype.com/api/v1/publisher/upload" val publishingType = "USER_MANAGED" val deploymentName = "${project.name}-$version" val uri = "$uriBase?name=$deploymentName&publishingType=$publishingType" val centralPortalUserName: String? by project val centralPortalToken: String? by project val base64Auth = Base64 .getEncoder() .encode("$centralPortalUserName:$centralPortalToken".toByteArray()) .toString(Charsets.UTF_8) val bundleFile = packSonatypeCentralBundle.get().archiveFile.get().asFile println("Sending request to $uri...") val client = OkHttpClient() val request = Request.Builder() .url(uri) .header("Authorization", "Bearer $base64Auth") .post( MultipartBody.Builder() .setType(MultipartBody.FORM) .addFormDataPart("bundle", bundleFile.name, bundleFile.asRequestBody()) .build() ) .build() client.newCall(request).execute().use { response -> val statusCode = response.code println("Upload status code: $statusCode") println("Upload result: ${response.body!!.string()}") if (statusCode != 201) { error("Upload error to Central repository. Status code $statusCode.") - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -