mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 00:17:11 -07:00
Better message when a dependency can't be resolved.
This commit is contained in:
parent
e6efdc2f75
commit
3ac313b7bf
4 changed files with 14 additions and 10 deletions
|
@ -90,7 +90,7 @@ class DependencyManager @Inject constructor(val executors: KobaltExecutors, val
|
|||
vararg allDependencies: List<IClasspathDependency>): List<IClasspathDependency> {
|
||||
val result = arrayListOf<IClasspathDependency>()
|
||||
allDependencies.forEach { dependencies ->
|
||||
result.addAll(transitiveClosure(dependencies))
|
||||
result.addAll(transitiveClosure(dependencies, project?.name))
|
||||
}
|
||||
result.addAll(runClasspathContributors(project, context))
|
||||
result.addAll(dependentProjectDependencies(project, context))
|
||||
|
@ -111,7 +111,8 @@ class DependencyManager @Inject constructor(val executors: KobaltExecutors, val
|
|||
* Return the transitive closure of the dependencies *without* running the classpath contributors.
|
||||
* TODO: This should be private, everyone should be calling calculateDependencies().
|
||||
*/
|
||||
fun transitiveClosure(dependencies : List<IClasspathDependency>, indent : String = " "):
|
||||
fun transitiveClosure(dependencies : List<IClasspathDependency>, requiredBy: String? = null,
|
||||
indent : String = " "):
|
||||
List<IClasspathDependency> {
|
||||
val executor = executors.newExecutor("JvmCompiler}", 10)
|
||||
|
||||
|
@ -122,7 +123,8 @@ class DependencyManager @Inject constructor(val executors: KobaltExecutors, val
|
|||
result.add(projectDependency)
|
||||
projectDependency.id.let {
|
||||
result.add(create(it))
|
||||
val downloaded = transitiveClosure(projectDependency.directDependencies(), indent + " ")
|
||||
val downloaded = transitiveClosure(projectDependency.directDependencies(), projectDependency.id,
|
||||
indent + " ")
|
||||
|
||||
result.addAll(downloaded)
|
||||
}
|
||||
|
@ -132,7 +134,8 @@ class DependencyManager @Inject constructor(val executors: KobaltExecutors, val
|
|||
|
||||
val nonexistent = reordered.filter{ ! it.jarFile.get().exists() }
|
||||
if (nonexistent.any()) {
|
||||
log(2, "[Warning] Nonexistent dependencies: $nonexistent")
|
||||
throw KobaltException("Couldn't resolve dependency $nonexistent"
|
||||
+ (if (requiredBy != null) " required by $requiredBy" else ""))
|
||||
}
|
||||
|
||||
val result2 = reordered.filter {
|
||||
|
|
|
@ -33,7 +33,7 @@ class DependencyData @Inject constructor(val executors: KobaltExecutors, val dep
|
|||
return DependencyData(d.id, scope, dep.jarFile.get().absolutePath)
|
||||
}
|
||||
|
||||
fun allDeps(l: List<IClasspathDependency>) = dependencyManager.transitiveClosure(l)
|
||||
fun allDeps(l: List<IClasspathDependency>, name: String) = dependencyManager.transitiveClosure(l, name)
|
||||
|
||||
val buildFile = BuildFile(Paths.get(buildFilePath), "GetDependenciesCommand")
|
||||
val buildFileCompiler = buildFileCompilerFactory.create(listOf(buildFile), pluginInfo)
|
||||
|
@ -46,12 +46,13 @@ class DependencyData @Inject constructor(val executors: KobaltExecutors, val dep
|
|||
val allTasks = hashSetOf<TaskData>()
|
||||
projectResult.projects.withIndex().forEach { wi ->
|
||||
val project = wi.value
|
||||
val name = project.name
|
||||
progressListener?.onProgress(message = "Synchronizing project ${project.name} "
|
||||
+ (wi.index + 1) + "/" + projectResult.projects.size)
|
||||
val compileDependencies = pluginDependencies.map { toDependencyData(it, "compile") } +
|
||||
allDeps(project.compileDependencies).map { toDependencyData(it, "compile") } +
|
||||
allDeps(project.compileProvidedDependencies).map { toDependencyData(it, "compile") }
|
||||
val testDependencies = allDeps(project.testDependencies).map { toDependencyData(it, "testCompile") }
|
||||
allDeps(project.compileDependencies, name).map { toDependencyData(it, "compile") } +
|
||||
allDeps(project.compileProvidedDependencies, name).map { toDependencyData(it, "compile") }
|
||||
val testDependencies = allDeps(project.testDependencies, name).map { toDependencyData(it, "testCompile") }
|
||||
|
||||
val dependentProjects = project.dependsOn.map { it.name }
|
||||
|
||||
|
|
|
@ -144,7 +144,7 @@ class KotlinCompiler @Inject constructor(
|
|||
val executor = executors.newExecutor("KotlinCompiler", 10)
|
||||
val compilerVersion = settings.kobaltCompilerVersion
|
||||
val compilerDep = dependencyManager.create("org.jetbrains.kotlin:kotlin-compiler-embeddable:$compilerVersion")
|
||||
val deps = dependencyManager.transitiveClosure(listOf(compilerDep))
|
||||
val deps = dependencyManager.transitiveClosure(listOf(compilerDep), project?.name ?: "")
|
||||
|
||||
// Force a download of the compiler dependencies
|
||||
deps.forEach { it.jarFile.get() }
|
||||
|
|
|
@ -160,7 +160,7 @@ class DownloadTest @Inject constructor(
|
|||
@Test
|
||||
fun variablesShouldBeExpanded() {
|
||||
val dep = dependencyManager.createMaven("org.mapdb:mapdb:3.0.0-M3")
|
||||
val closure = dependencyManager.transitiveClosure(listOf(dep))
|
||||
val closure = dependencyManager.transitiveClosure(listOf(dep), "<testProject>")
|
||||
val d = closure.filter { it.id.contains("eclipse-collections-api")}
|
||||
Assert.assertEquals(d.size, 1)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue