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

Merge pull request #94 from Levelmoney/master

fix org uploading
This commit is contained in:
Cedric Beust 2016-01-06 23:01:47 -08:00
commit 706700f293
2 changed files with 11 additions and 11 deletions

View file

@ -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<File>, 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<String>()

View file

@ -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<String>()