mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
readd support for auto-publishing
This commit is contained in:
parent
3ca7b95584
commit
634e319e5c
1 changed files with 8 additions and 17 deletions
|
@ -60,13 +60,14 @@ class BintrayApi @Inject constructor(val http: Http,
|
||||||
fun createPackage(@Path("owner") owner: String,
|
fun createPackage(@Path("owner") owner: String,
|
||||||
@Body content: JsonObject): Call<BintrayResponse>
|
@Body content: JsonObject): Call<BintrayResponse>
|
||||||
|
|
||||||
@PUT("/content/{owner}/maven/{repo}/{version}/{group}/{artifact}/{version}/{name}")
|
@PUT("/content/{owner}/maven/{repo}/{version}/{group}/{artifact}/{version}/{name};publish={publish}")
|
||||||
fun uploadArtifact(@Path("owner") owner: String,
|
fun uploadArtifact(@Path("owner") owner: String,
|
||||||
@Path("repo") repo: String,
|
@Path("repo") repo: String,
|
||||||
@Path("group", encoded = true) group: String,
|
@Path("group", encoded = true) group: String,
|
||||||
@Path("artifact") artifact: String,
|
@Path("artifact") artifact: String,
|
||||||
@Path("version") version: String,
|
@Path("version") version: String,
|
||||||
@Path("name") name: String,
|
@Path("name") name: String,
|
||||||
|
@Path("publish") publish: Int,
|
||||||
@Body file: File): Call<BintrayResponse>
|
@Body file: File): Call<BintrayResponse>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,18 +123,18 @@ class BintrayApi @Inject constructor(val http: Http,
|
||||||
return jsonObject
|
return jsonObject
|
||||||
}
|
}
|
||||||
|
|
||||||
fun uploadMaven(project: Project, files: List<File>, config: BintrayConfig?): TaskResult {
|
fun uploadMaven(project: Project, files: List<File>, config: BintrayConfig): TaskResult {
|
||||||
validatePackage(project)
|
validatePackage(project)
|
||||||
return upload(project, files, config, generateMd5 = true)
|
return upload(project, files, config, generateMd5 = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun uploadFile(project: Project, file: File, config: BintrayConfig?, generateMd5: Boolean = false) =
|
fun uploadFile(project: Project, file: File, config: BintrayConfig, generateMd5: Boolean = false) =
|
||||||
upload(project, arrayListOf(file), config, generateMd5)
|
upload(project, arrayListOf(file), config, generateMd5)
|
||||||
|
|
||||||
private fun upload(project: Project, files: List<File>, config: BintrayConfig?, generateMd5: Boolean = false): TaskResult {
|
private fun upload(project: Project, files: List<File>, config: BintrayConfig, generateMd5: Boolean): TaskResult {
|
||||||
val filesToUpload = arrayListOf<File>()
|
val filesToUpload = arrayListOf<File>()
|
||||||
|
|
||||||
if (config != null && config.sign) {
|
if (config.sign) {
|
||||||
// Create the .asc files
|
// Create the .asc files
|
||||||
filesToUpload.addAll(gpg.runGpg(files))
|
filesToUpload.addAll(gpg.runGpg(files))
|
||||||
}
|
}
|
||||||
|
@ -150,17 +151,6 @@ class BintrayApi @Inject constructor(val http: Http,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// If any configuration was given, apply them so the URL reflects them, e.g. ?publish=1
|
|
||||||
//
|
|
||||||
val options = arrayListOf<String>()
|
|
||||||
if (config?.publish == true) options.add("publish=1")
|
|
||||||
|
|
||||||
val optionPath = StringBuffer()
|
|
||||||
if (options.size > 0) {
|
|
||||||
optionPath.append("?" + options.joinToString("&"))
|
|
||||||
}
|
|
||||||
|
|
||||||
val fileCount = filesToUpload.size
|
val fileCount = filesToUpload.size
|
||||||
if (fileCount > 0) {
|
if (fileCount > 0) {
|
||||||
log(1, " Found $fileCount artifacts to upload")
|
log(1, " Found $fileCount artifacts to upload")
|
||||||
|
@ -180,7 +170,8 @@ class BintrayApi @Inject constructor(val http: Http,
|
||||||
val artifact = project.artifactId!!
|
val artifact = project.artifactId!!
|
||||||
val version = project.version!!
|
val version = project.version!!
|
||||||
|
|
||||||
val result = service.uploadArtifact(owner, repo, group, artifact, version, file.name, file)
|
val result = service.uploadArtifact(owner, repo, group, artifact, version, file.name,
|
||||||
|
if (config.publish) 1 else 0, file)
|
||||||
.execute()
|
.execute()
|
||||||
val error = result.errorBody()?.string()
|
val error = result.errorBody()?.string()
|
||||||
if (result.errorBody() != null) {
|
if (result.errorBody() != null) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue