initial commit
This commit is contained in:
8
src/main/kotlin/com/infendro/plugin/Plugin.kt
Normal file
8
src/main/kotlin/com/infendro/plugin/Plugin.kt
Normal file
@@ -0,0 +1,8 @@
|
||||
package com.infendro.plugin
|
||||
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
|
||||
class InfendroPlugin : Plugin<Project> {
|
||||
override fun apply(project: Project) {}
|
||||
}
|
||||
33
src/main/kotlin/com/infendro/plugin/Repository.kt
Normal file
33
src/main/kotlin/com/infendro/plugin/Repository.kt
Normal file
@@ -0,0 +1,33 @@
|
||||
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(".", "__")
|
||||
Reference in New Issue
Block a user