mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
compile(file()) wasn't honoring the project.directory.
This commit is contained in:
parent
964a5511a9
commit
7badeb1153
3 changed files with 18 additions and 12 deletions
|
@ -7,7 +7,7 @@ interface IDependencyManager {
|
|||
/**
|
||||
* 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.
|
||||
|
|
|
@ -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
|
||||
* these dependencies.
|
||||
*/
|
||||
private fun addToDependencies(dependencies: ArrayList<IClasspathDependency>, dep: Array<out String>)
|
||||
: List<File>
|
||||
= with(dep.map { DependencyManager.create(it)}) {
|
||||
private fun addToDependencies(project: Project, dependencies: ArrayList<IClasspathDependency>,
|
||||
dep: Array<out String>): List<File>
|
||||
= with(dep.map { DependencyManager.create(it, project)}) {
|
||||
dependencies.addAll(this)
|
||||
this.map { it.jarFile.get() }
|
||||
}
|
||||
|
||||
@Directive
|
||||
fun compile(vararg dep: String) = addToDependencies(dependencies, dep)
|
||||
fun compile(vararg dep: String) = addToDependencies(project, dependencies, dep)
|
||||
|
||||
@Directive
|
||||
fun provided(vararg dep: String) = addToDependencies(providedDependencies, dep)
|
||||
fun provided(vararg dep: String) = addToDependencies(project, providedDependencies, dep)
|
||||
|
||||
@Directive
|
||||
fun runtime(vararg dep: String) = addToDependencies(runtimeDependencies, dep)
|
||||
fun runtime(vararg dep: String) = addToDependencies(project, runtimeDependencies, dep)
|
||||
|
||||
@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)
|
||||
|
|
|
@ -7,6 +7,7 @@ import com.beust.kobalt.misc.KFiles
|
|||
import com.beust.kobalt.misc.KobaltExecutors
|
||||
import com.beust.kobalt.misc.log
|
||||
import com.google.common.collect.ArrayListMultimap
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
@ -16,16 +17,21 @@ class DependencyManager @Inject constructor(val executors: KobaltExecutors, val
|
|||
: IDependencyManager {
|
||||
|
||||
companion object {
|
||||
fun create(id: String) =
|
||||
Kobalt.INJECTOR.getInstance(DependencyManager::class.java).create(id)
|
||||
fun create(id: String, project: Project? = null) =
|
||||
Kobalt.INJECTOR.getInstance(DependencyManager::class.java).create(id, project)
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)) {
|
||||
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 {
|
||||
return createMaven(id)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue