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

compile(file()) wasn't honoring the project.directory.

This commit is contained in:
Cedric Beust 2016-03-30 02:20:58 -08:00
parent 964a5511a9
commit 7badeb1153
3 changed files with 18 additions and 12 deletions

View file

@ -7,7 +7,7 @@ interface IDependencyManager {
/** /**
* Parse the id and return the correct IClasspathDependency * Parse the id and return the correct IClasspathDependency
*/ */
fun create(id: String): IClasspathDependency fun create(id: String, project: Project? = null): IClasspathDependency
/** /**
* Create an IClasspathDependency from a Maven id. * Create an IClasspathDependency from a Maven id.

View file

@ -149,24 +149,24 @@ class Dependencies(val project: Project,
* 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 jar files corresponding to
* these dependencies. * these dependencies.
*/ */
private fun addToDependencies(dependencies: ArrayList<IClasspathDependency>, dep: Array<out String>) private fun addToDependencies(project: Project, dependencies: ArrayList<IClasspathDependency>,
: List<File> dep: Array<out String>): List<File>
= with(dep.map { DependencyManager.create(it)}) { = with(dep.map { DependencyManager.create(it, project)}) {
dependencies.addAll(this) dependencies.addAll(this)
this.map { it.jarFile.get() } this.map { it.jarFile.get() }
} }
@Directive @Directive
fun compile(vararg dep: String) = addToDependencies(dependencies, dep) fun compile(vararg dep: String) = addToDependencies(project, dependencies, dep)
@Directive @Directive
fun provided(vararg dep: String) = addToDependencies(providedDependencies, dep) fun provided(vararg dep: String) = addToDependencies(project, providedDependencies, dep)
@Directive @Directive
fun runtime(vararg dep: String) = addToDependencies(runtimeDependencies, dep) fun runtime(vararg dep: String) = addToDependencies(project, runtimeDependencies, dep)
@Directive @Directive
fun exclude(vararg dep: String) = addToDependencies(excludedDependencies, dep) fun exclude(vararg dep: String) = addToDependencies(project, excludedDependencies, dep)
} }
class Scm(val connection: String, val developerConnection: String, val url: String) class Scm(val connection: String, val developerConnection: String, val url: String)

View file

@ -7,6 +7,7 @@ import com.beust.kobalt.misc.KFiles
import com.beust.kobalt.misc.KobaltExecutors import com.beust.kobalt.misc.KobaltExecutors
import com.beust.kobalt.misc.log import com.beust.kobalt.misc.log
import com.google.common.collect.ArrayListMultimap import com.google.common.collect.ArrayListMultimap
import java.io.File
import java.util.* import java.util.*
import javax.inject.Inject import javax.inject.Inject
import javax.inject.Singleton import javax.inject.Singleton
@ -16,16 +17,21 @@ class DependencyManager @Inject constructor(val executors: KobaltExecutors, val
: IDependencyManager { : IDependencyManager {
companion object { companion object {
fun create(id: String) = fun create(id: String, project: Project? = null) =
Kobalt.INJECTOR.getInstance(DependencyManager::class.java).create(id) Kobalt.INJECTOR.getInstance(DependencyManager::class.java).create(id, project)
} }
/** /**
* Parse the id and return the correct IClasspathDependency * Parse the id and return the correct IClasspathDependency
*/ */
override fun create(id: String) : IClasspathDependency { override fun create(id: String, project: Project?) : IClasspathDependency {
if (id.startsWith(FileDependency.PREFIX_FILE)) { if (id.startsWith(FileDependency.PREFIX_FILE)) {
return createFile(id.substring(FileDependency.PREFIX_FILE.length)) val path = if (project?.directory != null) {
File(project!!.directory, id.substring(FileDependency.PREFIX_FILE.length))
} else {
File(id.substring(FileDependency.PREFIX_FILE.length))
}
return createFile(path.path)
} else { } else {
return createMaven(id) return createMaven(id)
} }