mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 00:17:11 -07:00
Relative compile dependencies should be resolved correctly.
Related to https://github.com/cbeust/kobalt-intellij-plugin/issues/24
This commit is contained in:
parent
f100f9bd62
commit
268b9a400f
4 changed files with 38 additions and 2 deletions
|
@ -7,6 +7,7 @@ import com.beust.kobalt.internal.KobaltSettings
|
|||
import com.beust.kobalt.internal.PluginInfo
|
||||
import com.beust.kobalt.maven.DependencyManager
|
||||
import com.beust.kobalt.misc.KobaltExecutors
|
||||
import java.io.File
|
||||
|
||||
class KobaltContext(val args: Args) {
|
||||
var variant: Variant = Variant()
|
||||
|
@ -47,4 +48,9 @@ class InternalContext {
|
|||
* will be disabled.
|
||||
*/
|
||||
var buildFileOutOfDate: Boolean = false
|
||||
|
||||
/**
|
||||
* The absolute directory of the current project.
|
||||
*/
|
||||
var absoluteDir: File? = null
|
||||
}
|
|
@ -23,4 +23,9 @@ class BuildFile(val path: Path, val name: String, val realPath: Path = path) {
|
|||
val dotKobaltDir: File get() = File(directory.parentFile.parentFile, KFiles.KOBALT_DOT_DIR).apply {
|
||||
mkdirs()
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the absolute directory of this build file, assuming the build file is in $project/kobalt/src/Build.kt
|
||||
*/
|
||||
val absoluteDir = path.parent.parent.parent.toFile()
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import com.beust.kobalt.maven.dependency.FileDependency
|
|||
import com.beust.kobalt.misc.KFiles
|
||||
import com.beust.kobalt.misc.KobaltExecutors
|
||||
import com.beust.kobalt.misc.log
|
||||
import com.beust.kobalt.misc.warn
|
||||
import com.google.common.collect.ArrayListMultimap
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
|
@ -30,7 +31,15 @@ class DependencyManager @Inject constructor(val executors: KobaltExecutors, val
|
|||
val path = if (project?.directory != null) {
|
||||
val idPath = id.substring(FileDependency.PREFIX_FILE.length)
|
||||
if (! File(idPath).isAbsolute) {
|
||||
File(project!!.directory, idPath)
|
||||
// If the project directory is relative, we might not be in the correct directory to locate
|
||||
// that file, so we'll use the absolute directory deduced from the build file path. Pick
|
||||
// the first one that produces an actual file
|
||||
val result = listOf(File(project!!.directory), Kobalt.context?.internalContext?.absoluteDir).map {
|
||||
File(it, idPath)
|
||||
}.first {
|
||||
it.exists()
|
||||
}
|
||||
result
|
||||
} else {
|
||||
File(idPath)
|
||||
}
|
||||
|
@ -119,7 +128,14 @@ class DependencyManager @Inject constructor(val executors: KobaltExecutors, val
|
|||
}
|
||||
}
|
||||
|
||||
val result2 = reorderDependencies(result).filter {
|
||||
val reordered = reorderDependencies(result)
|
||||
|
||||
val nonexistent = reordered.filter{ ! it.jarFile.get().exists() }
|
||||
if (nonexistent.any()) {
|
||||
warn("Nonexistent dependencies: $nonexistent")
|
||||
}
|
||||
|
||||
val result2 = reordered.filter {
|
||||
// Only keep existent files (nonexistent files are probably optional dependencies or parent poms
|
||||
// that point to other poms but don't have a jar file themselves)
|
||||
it.jarFile.get().exists()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue