mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 00:17:11 -07:00
Resolve range versions as soon as possible.
This commit is contained in:
parent
e8f7d2bce8
commit
eef34e66da
3 changed files with 22 additions and 6 deletions
|
@ -3,7 +3,9 @@ package com.beust.kobalt.api
|
|||
import com.beust.kobalt.TestConfig
|
||||
import com.beust.kobalt.api.annotation.Directive
|
||||
import com.beust.kobalt.maven.DependencyManager
|
||||
import com.beust.kobalt.maven.aether.KobaltAether
|
||||
import com.beust.kobalt.misc.KFiles
|
||||
import com.beust.kobalt.misc.log
|
||||
import org.apache.maven.model.Model
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
|
@ -143,10 +145,20 @@ class Dependencies(val project: Project,
|
|||
*/
|
||||
private fun addToDependencies(project: Project, dependencies: ArrayList<IClasspathDependency>,
|
||||
dep: Array<out String>): List<Future<File>>
|
||||
= with(dep.map { DependencyManager.create(it, project.directory)}) {
|
||||
= with(dep.map {
|
||||
val resolved =
|
||||
if (KobaltAether.isRangeVersion(it)) {
|
||||
val result = Kobalt.INJECTOR.getInstance(KobaltAether::class.java).resolve(it).dependency.id
|
||||
log(2, "Resolved range id $it to $result")
|
||||
result
|
||||
} else {
|
||||
it
|
||||
}
|
||||
DependencyManager.create(resolved, project.directory)
|
||||
}) {
|
||||
dependencies.addAll(this)
|
||||
this.map { FutureTask { it.jarFile.get() } }
|
||||
}
|
||||
}
|
||||
|
||||
@Directive
|
||||
fun compile(vararg dep: String) = addToDependencies(project, dependencies, dep)
|
||||
|
|
|
@ -77,6 +77,10 @@ class DependencyResult(val dependency: IClasspathDependency, val repoUrl: String
|
|||
class AetherResult(val artifact: Artifact, val repository: ArtifactRepository)
|
||||
|
||||
class KobaltAether @Inject constructor (val settings: KobaltSettings, val aether: Aether) {
|
||||
companion object {
|
||||
fun isRangeVersion(id: String) = id.contains(",")
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an IClasspathDependency from a Kobalt id.
|
||||
*/
|
||||
|
@ -202,7 +206,7 @@ class Aether(localRepo: File, val settings: KobaltSettings, val eventBus: EventB
|
|||
try {
|
||||
val scopeFilter = Scope.toFilter(filterScopes)
|
||||
val result =
|
||||
if (artifact.version.contains(",")) {
|
||||
if (KobaltAether.isRangeVersion(artifact.version)) {
|
||||
val request = rangeRequest(artifact)
|
||||
val v = system.resolveVersionRange(session, request)
|
||||
val ar = DefaultArtifact(artifact.groupId, artifact.artifactId, artifact.classifier,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue