diff --git a/src/main/kotlin/com/beust/kobalt/plugin/publish/JCenterApi.kt b/src/main/kotlin/com/beust/kobalt/plugin/publish/JCenterApi.kt index fb11f44f..8af0a967 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/publish/JCenterApi.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/publish/JCenterApi.kt @@ -52,17 +52,18 @@ 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, +public class JCenterApi @Inject constructor (@Nullable @Assisted("username") val username: 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 + fun create(@Nullable @Assisted("username") username: String?, + @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!!, @@ -104,10 +105,9 @@ public class JCenterApi @Inject constructor (@Nullable @Assisted("username") val return upload(files, config, fileToPath, generateMd5 = true) } - fun uploadFile(file: File, url: String, config: JCenterConfig, generateMd5: Boolean = false, - generateAsc: Boolean = false) = + fun uploadFile(file: File, url: String, config: JCenterConfig, generateMd5: 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) private fun upload(files: List, config: JCenterConfig?, fileToPath: (File) -> String, @@ -147,7 +147,7 @@ public class JCenterApi @Inject constructor (@Nullable @Assisted("username") val // val fileCount = filesToUpload.size if (fileCount > 0) { - log(1, " Found $fileCount artifacts to upload: " + filesToUpload[0] + log(1, " Found $fileCount artifacts to upload: " + filesToUpload.get(0) + if (fileCount > 1) "..." else "") var i = 1 val errorMessages = arrayListOf() diff --git a/src/main/kotlin/com/beust/kobalt/plugin/publish/PublishPlugin.kt b/src/main/kotlin/com/beust/kobalt/plugin/publish/PublishPlugin.kt index 5178469c..d8714abd 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/publish/PublishPlugin.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/publish/PublishPlugin.kt @@ -93,7 +93,7 @@ public class PublishPlugin @Inject constructor(val files: KFiles, val factory: P val password = localProperties.get(PROPERTY_BINTRAY_PASSWORD, docUrl) val org = localProperties.getNoThrows(PROPERTY_BINTRAY_ORG, docUrl) - val jcenter = jcenterFactory.create(org ?: user, password) + val jcenter = jcenterFactory.create(user, password, org) var success = false val configuration = jcenterConfigurations[project.name] val messages = arrayListOf()