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

Always resolve to the latest version.

Fixes https://github.com/cbeust/kobalt/issues/71.
This commit is contained in:
Cedric Beust 2015-12-13 07:45:37 -08:00
parent 91eeb9cbae
commit 84aa5bc412

View file

@ -3,10 +3,7 @@ package com.beust.kobalt.maven
import com.beust.kobalt.HostConfig import com.beust.kobalt.HostConfig
import com.beust.kobalt.api.Kobalt import com.beust.kobalt.api.Kobalt
import com.beust.kobalt.maven.dependency.FileDependency import com.beust.kobalt.maven.dependency.FileDependency
import com.beust.kobalt.misc.KobaltExecutors import com.beust.kobalt.misc.*
import com.beust.kobalt.misc.Strings
import com.beust.kobalt.misc.log
import com.beust.kobalt.misc.warn
import com.google.common.cache.CacheBuilder import com.google.common.cache.CacheBuilder
import com.google.common.cache.CacheLoader import com.google.common.cache.CacheLoader
import com.google.common.cache.LoadingCache import com.google.common.cache.LoadingCache
@ -44,6 +41,7 @@ public class RepoFinder @Inject constructor(val executors: KobaltExecutors) {
val executor = executors.newExecutor("RepoFinder-$id", Kobalt.repos.size) val executor = executors.newExecutor("RepoFinder-$id", Kobalt.repos.size)
val cs = ExecutorCompletionService<RepoResult>(executor) val cs = ExecutorCompletionService<RepoResult>(executor)
val results = arrayListOf<RepoResult>()
try { try {
log(2, "Looking for $id") log(2, "Looking for $id")
Kobalt.repos.forEach { cs.submit(RepoFinderCallable(id, it)) } Kobalt.repos.forEach { cs.submit(RepoFinderCallable(id, it)) }
@ -53,16 +51,22 @@ public class RepoFinder @Inject constructor(val executors: KobaltExecutors) {
log(2, " Result for repo #$i: $result") log(2, " Result for repo #$i: $result")
if (result.found) { if (result.found) {
log(2, "Located $id in ${result.hostConfig.url}") log(2, "Located $id in ${result.hostConfig.url}")
return result results.add(result)
} }
} catch(ex: Exception) { } catch(ex: Exception) {
warn("Error: $ex") warn("Error: $ex")
} }
} }
return RepoResult(HostConfig(""), false, id)
} finally { } finally {
executor.shutdownNow() executor.shutdownNow()
} }
if (results.size > 0) {
results.sortByDescending { Versions.toLongVersion(it.version) }
return results[0]
} else {
return RepoResult(HostConfig(""), false, id)
}
} }
/** /**