diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/Project.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/Project.kt index 374fb90d..77aa6df3 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/Project.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/Project.kt @@ -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, dep: Array): List> - = 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) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/aether/Aether.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/aether/Aether.kt index 006088ce..3ccadb13 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/aether/Aether.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/aether/Aether.kt @@ -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, diff --git a/src/main/kotlin/com/beust/kobalt/Main.kt b/src/main/kotlin/com/beust/kobalt/Main.kt index 2f5a6b38..b0b04fc2 100644 --- a/src/main/kotlin/com/beust/kobalt/Main.kt +++ b/src/main/kotlin/com/beust/kobalt/Main.kt @@ -180,13 +180,13 @@ private class Main @Inject constructor( error(buildFile.path.toFile().path + " does not exist") } else { - val allProjects = projectFinder.initForBuildFile(buildFile, args) - // 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) // println("Data: $data") + val allProjects = projectFinder.initForBuildFile(buildFile, args) + if (args.projectInfo) { // --projectInfo allProjects.forEach {