34 lines
1.0 KiB
Kotlin
34 lines
1.0 KiB
Kotlin
package com.infendro.plugin
|
|
|
|
import org.gradle.api.Project
|
|
import org.gradle.api.artifacts.dsl.RepositoryHandler
|
|
import org.gradle.api.credentials.HttpHeaderCredentials
|
|
import org.gradle.authentication.http.HttpHeaderAuthentication
|
|
import java.net.URI
|
|
|
|
fun RepositoryHandler.infendro(
|
|
token: String? = null,
|
|
) = maven { repo ->
|
|
repo.name = "infendro"
|
|
repo.url = URI("https://git.infendro.com/api/packages/Infendro/maven")
|
|
if (token != null) {
|
|
repo.authentication {
|
|
it.create("header", HttpHeaderAuthentication::class.java)
|
|
}
|
|
repo.credentials(HttpHeaderCredentials::class.java) {
|
|
it.name = "Authorization"
|
|
it.value = "token $token"
|
|
}
|
|
}
|
|
}
|
|
|
|
val Project.token: String?
|
|
get() {
|
|
val key = "infendro.token"
|
|
val property = findProperty(key) as String?
|
|
val environment = System.getenv(key.toEnvironmentKey())
|
|
return property ?: environment
|
|
}
|
|
|
|
private fun String.toEnvironmentKey() = uppercase().replace(".", "__")
|