1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-26 00:17:11 -07:00

Sanitize repo names from repos().

This commit is contained in:
Cedric Beust 2017-04-16 20:13:28 -07:00
parent a7006d5cd7
commit 6816ba8a3b

View file

@ -74,7 +74,7 @@ data class ProxyConfig(val host: String = "", val port: Int = 0, val type: Strin
fun toAetherProxy() = Proxy(type, host, port) // TODO make support for proxy auth
}
data class HostConfig(var url: String = "", var name: String = url, var username: String? = null,
data class HostConfig(var url: String = "", var name: String, var username: String? = null,
var password: String? = null) {
fun hasAuth() : Boolean {
return (! username.isNullOrBlank()) && (! password.isNullOrBlank())
@ -95,8 +95,10 @@ fun repos(vararg repos : String) {
newRepos(*repos)
}
fun createRepoName(url: String) = url.replace("/", "_").replace("\\", "_").replace(":", "_")
fun newRepos(vararg repos: String) {
repos.forEach { Kobalt.addRepo(HostConfig(it)) }
repos.forEach { Kobalt.addRepo(HostConfig(it, createRepoName(it))) }
}
fun buildFileClasspath(vararg deps: String) {
@ -115,7 +117,7 @@ fun authRepos(vararg repos : HostConfig) {
}
@Directive
fun authRepo(init: HostConfig.() -> Unit) = HostConfig().apply { init() }
fun authRepo(init: HostConfig.() -> Unit) = HostConfig(name = "").apply { init() }
@Directive
fun glob(g: String) : IFileSpec.GlobSpec = IFileSpec.GlobSpec(g)