mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -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.TestConfig
|
||||||
import com.beust.kobalt.api.annotation.Directive
|
import com.beust.kobalt.api.annotation.Directive
|
||||||
import com.beust.kobalt.maven.DependencyManager
|
import com.beust.kobalt.maven.DependencyManager
|
||||||
|
import com.beust.kobalt.maven.aether.KobaltAether
|
||||||
import com.beust.kobalt.misc.KFiles
|
import com.beust.kobalt.misc.KFiles
|
||||||
|
import com.beust.kobalt.misc.log
|
||||||
import org.apache.maven.model.Model
|
import org.apache.maven.model.Model
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
@ -143,10 +145,20 @@ class Dependencies(val project: Project,
|
||||||
*/
|
*/
|
||||||
private fun addToDependencies(project: Project, dependencies: ArrayList<IClasspathDependency>,
|
private fun addToDependencies(project: Project, dependencies: ArrayList<IClasspathDependency>,
|
||||||
dep: Array<out String>): List<Future<File>>
|
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)
|
dependencies.addAll(this)
|
||||||
this.map { FutureTask { it.jarFile.get() } }
|
this.map { FutureTask { it.jarFile.get() } }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Directive
|
@Directive
|
||||||
fun compile(vararg dep: String) = addToDependencies(project, dependencies, dep)
|
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 AetherResult(val artifact: Artifact, val repository: ArtifactRepository)
|
||||||
|
|
||||||
class KobaltAether @Inject constructor (val settings: KobaltSettings, val aether: Aether) {
|
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.
|
* Create an IClasspathDependency from a Kobalt id.
|
||||||
*/
|
*/
|
||||||
|
@ -202,7 +206,7 @@ class Aether(localRepo: File, val settings: KobaltSettings, val eventBus: EventB
|
||||||
try {
|
try {
|
||||||
val scopeFilter = Scope.toFilter(filterScopes)
|
val scopeFilter = Scope.toFilter(filterScopes)
|
||||||
val result =
|
val result =
|
||||||
if (artifact.version.contains(",")) {
|
if (KobaltAether.isRangeVersion(artifact.version)) {
|
||||||
val request = rangeRequest(artifact)
|
val request = rangeRequest(artifact)
|
||||||
val v = system.resolveVersionRange(session, request)
|
val v = system.resolveVersionRange(session, request)
|
||||||
val ar = DefaultArtifact(artifact.groupId, artifact.artifactId, artifact.classifier,
|
val ar = DefaultArtifact(artifact.groupId, artifact.artifactId, artifact.classifier,
|
||||||
|
|
|
@ -180,13 +180,13 @@ private class Main @Inject constructor(
|
||||||
error(buildFile.path.toFile().path + " does not exist")
|
error(buildFile.path.toFile().path + " does not exist")
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
val allProjects = projectFinder.initForBuildFile(buildFile, args)
|
|
||||||
|
|
||||||
// DONOTCOMMIT
|
// DONOTCOMMIT
|
||||||
// val data = dependencyData.dependenciesDataFor(homeDir("kotlin/klaxon/kobalt/src/Build.kt"), Args(),
|
// val data = dependencyData.dependenciesDataFor(homeDir("kotlin/ktor/kobalt/src/Build.kt"), Args(),
|
||||||
// useGraph = true)
|
// useGraph = true)
|
||||||
// println("Data: $data")
|
// println("Data: $data")
|
||||||
|
|
||||||
|
val allProjects = projectFinder.initForBuildFile(buildFile, args)
|
||||||
|
|
||||||
if (args.projectInfo) {
|
if (args.projectInfo) {
|
||||||
// --projectInfo
|
// --projectInfo
|
||||||
allProjects.forEach {
|
allProjects.forEach {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue