1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-26 08:27:12 -07:00

afaik this should work for bintray orgs

This commit is contained in:
Aaron Sarazan 2015-12-28 13:06:02 -08:00
parent 7cdb4b1a9c
commit 6cef3a3308
2 changed files with 9 additions and 6 deletions

View file

@ -53,16 +53,17 @@ open public class UnauthenticatedJCenterApi @Inject constructor(open val http: H
}
public class JCenterApi @Inject constructor (@Nullable @Assisted("username") val username: String?,
@Nullable @Assisted("password") val password: String?,
@Nullable @Assisted("password") val password: String?, @Nullable @Assisted("org") val org: String?,
override val http: Http, val gpg: Gpg, val executors: KobaltExecutors) : UnauthenticatedJCenterApi(http) {
interface IFactory {
fun create(@Nullable @Assisted("username") username: String?,
@Nullable @Assisted("password") password: String?) : JCenterApi
@Nullable @Assisted("password") password: String?,
@Nullable @Assisted("org") org: String?) : JCenterApi
}
fun packageExists(packageName: String) : Boolean {
val url = arrayListOf(UnauthenticatedJCenterApi.BINTRAY_URL_API, "packages", username!!, "maven", packageName)
val url = arrayListOf(UnauthenticatedJCenterApi.BINTRAY_URL_API, "packages", org ?: username!!, "maven", packageName)
.joinToString("/")
val jcResponse = parseResponse(http.get(username, password, url))
@ -90,7 +91,7 @@ public class JCenterApi @Inject constructor (@Nullable @Assisted("username") val
val fileToPath: (File) -> String = { f: File ->
arrayListOf(
UnauthenticatedJCenterApi.BINTRAY_URL_API_CONTENT,
username!!,
org ?: username!!,
"maven",
project.name,
project.version!!,
@ -107,7 +108,7 @@ public class JCenterApi @Inject constructor (@Nullable @Assisted("username") val
fun uploadFile(file: File, url: String, config: JCenterConfig, generateMd5: Boolean = false,
generateAsc: Boolean = false) =
upload(arrayListOf(file), config, {
f: File -> "${UnauthenticatedJCenterApi.BINTRAY_URL_API_CONTENT}/$username/generic/$url"},
f: File -> "${UnauthenticatedJCenterApi.BINTRAY_URL_API_CONTENT}/${org ?: username}/generic/$url"},
generateMd5, generateAsc)
private fun upload(files: List<File>, config: JCenterConfig?, fileToPath: (File) -> String,

View file

@ -29,6 +29,7 @@ public class PublishPlugin @Inject constructor(val files: KFiles, val factory: P
private const val PROPERTY_BINTRAY_USER = "bintray.user"
private const val PROPERTY_BINTRAY_PASSWORD = "bintray.apikey"
private const val PROPERTY_BINTRAY_ORG = "bintray.organization"
}
@Suppress("UNUSED_FUNCTION_LITERAL")
@ -90,8 +91,9 @@ public class PublishPlugin @Inject constructor(val files: KFiles, val factory: P
val docUrl = DocUrl.PUBLISH_PLUGIN_URL
val user = localProperties.get(PROPERTY_BINTRAY_USER, docUrl)
val password = localProperties.get(PROPERTY_BINTRAY_PASSWORD, docUrl)
val org = localProperties.get(PROPERTY_BINTRAY_ORG, docUrl)
val jcenter = jcenterFactory.create(user, password)
val jcenter = jcenterFactory.create(user, password, org)
var success = false
val configuration = jcenterConfigurations[project.name]
val messages = arrayListOf<String>()