mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-27 08:38:13 -07:00
fix org uploading
This commit is contained in:
parent
5109935931
commit
df2a1c61b3
2 changed files with 11 additions and 11 deletions
|
@ -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,
|
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) {
|
override val http: Http, val gpg: Gpg, val executors: KobaltExecutors) : UnauthenticatedJCenterApi(http) {
|
||||||
|
|
||||||
interface IFactory {
|
interface IFactory {
|
||||||
fun create(@Nullable @Assisted("username") username: String,
|
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 {
|
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("/")
|
.joinToString("/")
|
||||||
val jcResponse = parseResponse(http.get(username, password, url))
|
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 ->
|
val fileToPath: (File) -> String = { f: File ->
|
||||||
arrayListOf(
|
arrayListOf(
|
||||||
UnauthenticatedJCenterApi.BINTRAY_URL_API_CONTENT,
|
UnauthenticatedJCenterApi.BINTRAY_URL_API_CONTENT,
|
||||||
username,
|
org ?: username!!,
|
||||||
"maven",
|
"maven",
|
||||||
project.name,
|
project.name,
|
||||||
project.version!!,
|
project.version!!,
|
||||||
|
@ -104,10 +105,9 @@ public class JCenterApi @Inject constructor (@Nullable @Assisted("username") val
|
||||||
return upload(files, config, fileToPath, generateMd5 = true)
|
return upload(files, config, fileToPath, generateMd5 = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun uploadFile(file: File, url: String, config: JCenterConfig, generateMd5: Boolean = false,
|
fun uploadFile(file: File, url: String, config: JCenterConfig, generateMd5: Boolean = false) =
|
||||||
generateAsc: Boolean = false) =
|
|
||||||
upload(arrayListOf(file), config, {
|
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)
|
generateMd5)
|
||||||
|
|
||||||
private fun upload(files: List<File>, config: JCenterConfig?, fileToPath: (File) -> String,
|
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
|
val fileCount = filesToUpload.size
|
||||||
if (fileCount > 0) {
|
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 "")
|
+ if (fileCount > 1) "..." else "")
|
||||||
var i = 1
|
var i = 1
|
||||||
val errorMessages = arrayListOf<String>()
|
val errorMessages = arrayListOf<String>()
|
||||||
|
|
|
@ -93,7 +93,7 @@ public class PublishPlugin @Inject constructor(val files: KFiles, val factory: P
|
||||||
val password = localProperties.get(PROPERTY_BINTRAY_PASSWORD, docUrl)
|
val password = localProperties.get(PROPERTY_BINTRAY_PASSWORD, docUrl)
|
||||||
val org = localProperties.getNoThrows(PROPERTY_BINTRAY_ORG, 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
|
var success = false
|
||||||
val configuration = jcenterConfigurations[project.name]
|
val configuration = jcenterConfigurations[project.name]
|
||||||
val messages = arrayListOf<String>()
|
val messages = arrayListOf<String>()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue