mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 16:28:12 -07:00
Return list of RepoResults.
Preparation for support of container poms.
This commit is contained in:
parent
82f5236d0c
commit
4bfe42545e
1 changed files with 24 additions and 18 deletions
|
@ -60,7 +60,7 @@ class RepoFinder @Inject constructor(val executors: KobaltExecutors) {
|
||||||
*/
|
*/
|
||||||
private fun loadCorrectRepo(id: String): RepoResult {
|
private fun loadCorrectRepo(id: String): RepoResult {
|
||||||
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<List<RepoResult>>(executor)
|
||||||
|
|
||||||
val results = arrayListOf<RepoResult>()
|
val results = arrayListOf<RepoResult>()
|
||||||
try {
|
try {
|
||||||
|
@ -68,13 +68,15 @@ class RepoFinder @Inject constructor(val executors: KobaltExecutors) {
|
||||||
Kobalt.repos.forEach { cs.submit(RepoFinderCallable(id, it)) }
|
Kobalt.repos.forEach { cs.submit(RepoFinderCallable(id, it)) }
|
||||||
for (i in 0..Kobalt.repos.size - 1) {
|
for (i in 0..Kobalt.repos.size - 1) {
|
||||||
try {
|
try {
|
||||||
val result = cs.take().get(2000, TimeUnit.MILLISECONDS)
|
val repos = cs.take().get(2000, TimeUnit.MILLISECONDS)
|
||||||
|
repos.forEach { result ->
|
||||||
if (result.found) {
|
if (result.found) {
|
||||||
log(2, "Located $id in ${result.hostConfig.url}")
|
log(2, "Located $id in ${result.hostConfig.url}")
|
||||||
results.add(result)
|
results.add(result)
|
||||||
} else {
|
} else {
|
||||||
log(3, " Result for repo #$i: $result")
|
log(3, " Result for repo #$i: $result")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch(ex: Exception) {
|
} catch(ex: Exception) {
|
||||||
warn("Error: $ex")
|
warn("Error: $ex")
|
||||||
}
|
}
|
||||||
|
@ -93,10 +95,13 @@ class RepoFinder @Inject constructor(val executors: KobaltExecutors) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute a single HTTP request to one repo.
|
* Execute a single HTTP request to one repo. This Callable can return more than one RepoResult
|
||||||
|
* if the artifact we're tying to locate is a container pom (in which case, we'll return one
|
||||||
|
* positive RepoResult for each of the artifacts listed in that .pom file). For example:
|
||||||
|
* http://repo1.maven.org/maven2/nl/komponents/kovenant/kovenant/3.0.0/
|
||||||
*/
|
*/
|
||||||
inner class RepoFinderCallable(val id: String, val repo: HostConfig) : Callable<RepoResult> {
|
inner class RepoFinderCallable(val id: String, val repo: HostConfig) : Callable<List<RepoResult>> {
|
||||||
override fun call(): RepoResult {
|
override fun call(): List<RepoResult> {
|
||||||
val repoUrl = repo.url
|
val repoUrl = repo.url
|
||||||
log(2, " Checking $repoUrl for $id")
|
log(2, " Checking $repoUrl for $id")
|
||||||
|
|
||||||
|
@ -110,9 +115,9 @@ class RepoFinder @Inject constructor(val executors: KobaltExecutors) {
|
||||||
val path = ud.toMetadataXmlPath(false, isLocal)
|
val path = ud.toMetadataXmlPath(false, isLocal)
|
||||||
val foundVersion = findCorrectVersionRelease(path, repoUrl)
|
val foundVersion = findCorrectVersionRelease(path, repoUrl)
|
||||||
if (foundVersion != null) {
|
if (foundVersion != null) {
|
||||||
return RepoResult(repo, Version.of(foundVersion), repoUrl + path)
|
return listOf(RepoResult(repo, Version.of(foundVersion), repoUrl + path))
|
||||||
} else {
|
} else {
|
||||||
return RepoResult(repo)
|
return listOf(RepoResult(repo))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
val version = Version.of(mavenId.version)
|
val version = Version.of(mavenId.version)
|
||||||
|
@ -127,28 +132,29 @@ class RepoFinder @Inject constructor(val executors: KobaltExecutors) {
|
||||||
val url = repoUrl + dep.toDirectory(fileSystem = false, v = dep.version) +
|
val url = repoUrl + dep.toDirectory(fileSystem = false, v = dep.version) +
|
||||||
dep.artifactId + "-" + snapshotVersion.noSnapshotVersion +
|
dep.artifactId + "-" + snapshotVersion.noSnapshotVersion +
|
||||||
"-" + snapshotVersion.snapshotTimestamp + ".jar"
|
"-" + snapshotVersion.snapshotTimestamp + ".jar"
|
||||||
return RepoResult(repo, version, url, snapshotVersion)
|
return listOf(RepoResult(repo, version, url, snapshotVersion))
|
||||||
} else {
|
} else {
|
||||||
return RepoResult(repo)
|
return listOf(RepoResult(repo))
|
||||||
}
|
}
|
||||||
} else if (version.isRangedVersion() ) {
|
} else if (version.isRangedVersion() ) {
|
||||||
val foundVersion = findRangedVersion(SimpleDep(mavenId), repoUrl)
|
val foundVersion = findRangedVersion(SimpleDep(mavenId), repoUrl)
|
||||||
if (foundVersion != null) {
|
if (foundVersion != null) {
|
||||||
return RepoResult(repo, foundVersion)
|
return listOf(RepoResult(repo, foundVersion))
|
||||||
} else {
|
} else {
|
||||||
return RepoResult(repo)
|
return listOf(RepoResult(repo))
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
val dep = SimpleDep(mavenId)
|
val dep = SimpleDep(mavenId)
|
||||||
// Try to find the jar file
|
// Try to find the jar file
|
||||||
val attemptPaths = listOf(dep.toJarFile(dep.version), dep.toAarFile(dep.version))
|
val attemptPaths = listOf(dep.toJarFile(dep.version), dep.toAarFile(dep.version),
|
||||||
|
dep.toPomFile(dep.version))
|
||||||
val attemptUrls = attemptPaths.map { repo.copy(url = repo.url + it )} +
|
val attemptUrls = attemptPaths.map { repo.copy(url = repo.url + it )} +
|
||||||
attemptPaths.map { repo.copy(url = repo.url + File(it).parentFile.path.replace("\\", "/")) }
|
attemptPaths.map { repo.copy(url = repo.url + File(it).parentFile.path.replace("\\", "/")) }
|
||||||
|
|
||||||
val firstFound = attemptUrls.map { Kurl(it)}.firstOrNull { it.exists }
|
val firstFound = attemptUrls.map { Kurl(it)}.firstOrNull { it.exists }
|
||||||
log(3, "Result for $repoUrl for $id: $firstFound")
|
log(3, "Result for $repoUrl for $id: $firstFound")
|
||||||
return RepoResult(repo, Version.of(dep.version), firstFound?.hostInfo?.url)
|
return listOf(RepoResult(repo, Version.of(dep.version), firstFound?.hostInfo?.url))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue