mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
Simplify the publish org/username logic.
This commit is contained in:
parent
e7fe61be7c
commit
1636d4f4eb
2 changed files with 10 additions and 11 deletions
|
@ -52,18 +52,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("org") val org: String?,
|
||||
public class JCenterApi @Inject constructor (@Nullable @Assisted("username") val username: String,
|
||||
@Nullable @Assisted("password") val password: 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?,
|
||||
@Nullable @Assisted("org") org: String?) : JCenterApi
|
||||
fun create(@Nullable @Assisted("username") username: String,
|
||||
@Nullable @Assisted("password") password: String) : JCenterApi
|
||||
}
|
||||
|
||||
fun packageExists(packageName: String) : Boolean {
|
||||
val url = arrayListOf(UnauthenticatedJCenterApi.BINTRAY_URL_API, "packages", org ?: username!!, "maven", packageName)
|
||||
val url = arrayListOf(UnauthenticatedJCenterApi.BINTRAY_URL_API, "packages", username, "maven", packageName)
|
||||
.joinToString("/")
|
||||
val jcResponse = parseResponse(http.get(username, password, url))
|
||||
|
||||
|
@ -91,7 +90,7 @@ public class JCenterApi @Inject constructor (@Nullable @Assisted("username") val
|
|||
val fileToPath: (File) -> String = { f: File ->
|
||||
arrayListOf(
|
||||
UnauthenticatedJCenterApi.BINTRAY_URL_API_CONTENT,
|
||||
org ?: username!!,
|
||||
username,
|
||||
"maven",
|
||||
project.name,
|
||||
project.version!!,
|
||||
|
@ -108,7 +107,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}/${org ?: username}/generic/$url"},
|
||||
f: File -> "${UnauthenticatedJCenterApi.BINTRAY_URL_API_CONTENT}/$username/generic/$url"},
|
||||
generateMd5, generateAsc)
|
||||
|
||||
private fun upload(files: List<File>, config: JCenterConfig?, fileToPath: (File) -> String,
|
||||
|
@ -148,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.get(0)
|
||||
log(1, " Found $fileCount artifacts to upload: " + filesToUpload[0]
|
||||
+ if (fileCount > 1) "..." else "")
|
||||
var i = 1
|
||||
val errorMessages = arrayListOf<String>()
|
||||
|
|
|
@ -91,9 +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 org = localProperties.getNoThrows(PROPERTY_BINTRAY_ORG, docUrl)
|
||||
|
||||
val jcenter = jcenterFactory.create(user, password, org)
|
||||
val jcenter = jcenterFactory.create(org ?: user, password)
|
||||
var success = false
|
||||
val configuration = jcenterConfigurations[project.name]
|
||||
val messages = arrayListOf<String>()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue