mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-25 07:57:12 -07:00
Remove the random repo number hack.
Fixes https://github.com/cbeust/kobalt/issues/385
This commit is contained in:
parent
ed9c4e6636
commit
f8fbcb912c
4 changed files with 12 additions and 12 deletions
|
@ -74,7 +74,8 @@ 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 username: String? = null, var password: String? = null) {
|
||||
data class HostConfig(var url: String = "", var name: String = url, var username: String? = null,
|
||||
var password: String? = null) {
|
||||
fun hasAuth() : Boolean {
|
||||
return (! username.isNullOrBlank()) && (! password.isNullOrBlank())
|
||||
}
|
||||
|
|
|
@ -11,13 +11,11 @@ object Constants {
|
|||
val BUILD_FILE_PATH = KFiles.joinDir(BUILD_FILE_DIRECTORY, BUILD_FILE_NAME)
|
||||
val KOTLIN_COMPILER_VERSION = "1.1.1"
|
||||
|
||||
internal val DEFAULT_REPOS = listOf<String>(
|
||||
internal val DEFAULT_REPOS = listOf<HostConfig>(
|
||||
// "https://maven-central.storage.googleapis.com/",
|
||||
"http://repo1.maven.org/maven2/",
|
||||
"https://jcenter.bintray.com/",
|
||||
HostConfig("http://repo1.maven.org/maven2/", "Maven"),
|
||||
HostConfig("https://jcenter.bintray.com/", "JCenter")
|
||||
// "http://repository.jetbrains.com/all/", // <-- contains snapshots
|
||||
"https://dl.bintray.com/kotlin/kotlin-eap",
|
||||
"https://dl.bintray.com/kotlin/kotlin-eap-1.1"
|
||||
|
||||
// snapshots
|
||||
// "https://oss.sonatype.org/content/repositories/snapshots/"
|
||||
|
|
|
@ -35,12 +35,12 @@ class Kobalt {
|
|||
*/
|
||||
val repos : Set<HostConfig>
|
||||
get() {
|
||||
val settingsRepos = Kobalt.context?.settings?.defaultRepos ?: emptyList()
|
||||
val settingsRepos = Kobalt.context?.settings?.defaultRepos?.map { HostConfig(it) } ?: emptyList()
|
||||
// Repos from <default-repos> in the settings
|
||||
val result = ArrayList(
|
||||
(if (settingsRepos.isEmpty()) Constants.DEFAULT_REPOS
|
||||
else settingsRepos)
|
||||
.map { HostConfig(it) })
|
||||
)
|
||||
|
||||
// Repo from <kobalt-compiler-repo> in the settings
|
||||
Kobalt.context?.settings?.kobaltCompilerRepo?.let {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.beust.kobalt.maven.aether
|
||||
|
||||
import com.beust.kobalt.Args
|
||||
import com.beust.kobalt.HostConfig
|
||||
import com.beust.kobalt.api.Kobalt
|
||||
import com.beust.kobalt.internal.KobaltSettings
|
||||
import com.beust.kobalt.internal.getProxy
|
||||
|
@ -92,12 +93,12 @@ class KobaltMavenResolver @Inject constructor(val settings: KobaltSettings,
|
|||
private val system = Booter.newRepositorySystem()
|
||||
private val session = Booter.newRepositorySystemSession(system, localRepo.localRepo, settings, eventBus)
|
||||
|
||||
private fun createRepo(url: String) = RemoteRepository.Builder(Random().nextInt().toString(), "default", url)
|
||||
.build()
|
||||
private fun createRepo(hostConfig: HostConfig) =
|
||||
RemoteRepository.Builder(hostConfig.name, "default", hostConfig.url).build()
|
||||
|
||||
private val kobaltRepositories: List<RemoteRepository>
|
||||
get() = Kobalt.repos.map {
|
||||
createRepo(it.url).let { repository ->
|
||||
createRepo(it).let { repository ->
|
||||
val proxyConfigs = settings.proxyConfigs ?: return@map repository
|
||||
RemoteRepository.Builder(repository).apply {
|
||||
setProxy(proxyConfigs.getProxy(repository.protocol)?.toAetherProxy())
|
||||
|
@ -118,6 +119,6 @@ class KobaltMavenResolver @Inject constructor(val settings: KobaltSettings,
|
|||
}
|
||||
|
||||
root = Dependency(DefaultArtifact(MavenId.toMavenId(id)), scope?.scope)
|
||||
repositories = kobaltRepositories + repos.map { createRepo(it) }
|
||||
repositories = kobaltRepositories + repos.map { createRepo(HostConfig(it)) }
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue