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

Lazy jar get.

This commit is contained in:
Cedric Beust 2016-04-07 06:22:58 -08:00
parent 4045add7a7
commit fd2c9a932f
2 changed files with 12 additions and 7 deletions

View file

@ -7,6 +7,8 @@ import com.beust.kobalt.maven.DependencyManager
import com.beust.kobalt.misc.KFiles import com.beust.kobalt.misc.KFiles
import java.io.File import java.io.File
import java.util.* import java.util.*
import java.util.concurrent.Future
import java.util.concurrent.FutureTask
open class Project( open class Project(
@Directive open var name: String = "", @Directive open var name: String = "",
@ -146,14 +148,16 @@ class Dependencies(val project: Project,
val excludedDependencies: ArrayList<IClasspathDependency>) { val excludedDependencies: ArrayList<IClasspathDependency>) {
/** /**
* Add the dependencies to the given ArrayList and return a list of jar files corresponding to * Add the dependencies to the given ArrayList and return a list of future jar files corresponding to
* these dependencies. * these dependencies. Futures are necessary here since this code is invoked from the build file and
* we might not have set up the extra IRepositoryContributors just yet. By the time these
* future tasks receive a get(), the repos will be correct.
*/ */
private fun addToDependencies(project: Project, dependencies: ArrayList<IClasspathDependency>, private fun addToDependencies(project: Project, dependencies: ArrayList<IClasspathDependency>,
dep: Array<out String>): List<File> dep: Array<out String>): List<Future<File>>
= with(dep.map { DependencyManager.create(it, project)}) { = with(dep.map { DependencyManager.create(it, project)}) {
dependencies.addAll(this) dependencies.addAll(this)
this.map { it.jarFile.get() } this.map { FutureTask { it.jarFile.get() } }
} }
@Directive @Directive

View file

@ -41,9 +41,10 @@ class KobaltAether @Inject constructor (val settings: KobaltSettings, val aether
* Create an IClasspathDependency from a Kobalt id. * Create an IClasspathDependency from a Kobalt id.
*/ */
fun create(id: String): IClasspathDependency { fun create(id: String): IClasspathDependency {
val cr = aether.transitiveDependencies(DefaultArtifact(MavenId.toKobaltId(id))) return AetherDependency(DefaultArtifact(id))
return if (cr != null) AetherDependency(cr.root.artifact) // val cr = aether.directDependencies(DefaultArtifact(MavenId.toKobaltId(id)))
else throw KobaltException("Couldn't resolve $id") // return if (cr != null) AetherDependency(cr.root.artifact)
// else throw KobaltException("Couldn't resolve $id")
} }
/** /**