mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -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> {
|
vararg allDependencies: List<IClasspathDependency>): List<IClasspathDependency> {
|
||||||
val result = arrayListOf<IClasspathDependency>()
|
val result = arrayListOf<IClasspathDependency>()
|
||||||
allDependencies.forEach { dependencies ->
|
allDependencies.forEach { dependencies ->
|
||||||
result.addAll(transitiveClosure(dependencies))
|
result.addAll(transitiveClosure(dependencies, project?.name))
|
||||||
}
|
}
|
||||||
result.addAll(runClasspathContributors(project, context))
|
result.addAll(runClasspathContributors(project, context))
|
||||||
result.addAll(dependentProjectDependencies(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.
|
* Return the transitive closure of the dependencies *without* running the classpath contributors.
|
||||||
* TODO: This should be private, everyone should be calling calculateDependencies().
|
* 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> {
|
List<IClasspathDependency> {
|
||||||
val executor = executors.newExecutor("JvmCompiler}", 10)
|
val executor = executors.newExecutor("JvmCompiler}", 10)
|
||||||
|
|
||||||
|
@ -122,7 +123,8 @@ class DependencyManager @Inject constructor(val executors: KobaltExecutors, val
|
||||||
result.add(projectDependency)
|
result.add(projectDependency)
|
||||||
projectDependency.id.let {
|
projectDependency.id.let {
|
||||||
result.add(create(it))
|
result.add(create(it))
|
||||||
val downloaded = transitiveClosure(projectDependency.directDependencies(), indent + " ")
|
val downloaded = transitiveClosure(projectDependency.directDependencies(), projectDependency.id,
|
||||||
|
indent + " ")
|
||||||
|
|
||||||
result.addAll(downloaded)
|
result.addAll(downloaded)
|
||||||
}
|
}
|
||||||
|
@ -132,7 +134,8 @@ class DependencyManager @Inject constructor(val executors: KobaltExecutors, val
|
||||||
|
|
||||||
val nonexistent = reordered.filter{ ! it.jarFile.get().exists() }
|
val nonexistent = reordered.filter{ ! it.jarFile.get().exists() }
|
||||||
if (nonexistent.any()) {
|
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 {
|
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)
|
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 buildFile = BuildFile(Paths.get(buildFilePath), "GetDependenciesCommand")
|
||||||
val buildFileCompiler = buildFileCompilerFactory.create(listOf(buildFile), pluginInfo)
|
val buildFileCompiler = buildFileCompilerFactory.create(listOf(buildFile), pluginInfo)
|
||||||
|
@ -46,12 +46,13 @@ class DependencyData @Inject constructor(val executors: KobaltExecutors, val dep
|
||||||
val allTasks = hashSetOf<TaskData>()
|
val allTasks = hashSetOf<TaskData>()
|
||||||
projectResult.projects.withIndex().forEach { wi ->
|
projectResult.projects.withIndex().forEach { wi ->
|
||||||
val project = wi.value
|
val project = wi.value
|
||||||
|
val name = project.name
|
||||||
progressListener?.onProgress(message = "Synchronizing project ${project.name} "
|
progressListener?.onProgress(message = "Synchronizing project ${project.name} "
|
||||||
+ (wi.index + 1) + "/" + projectResult.projects.size)
|
+ (wi.index + 1) + "/" + projectResult.projects.size)
|
||||||
val compileDependencies = pluginDependencies.map { toDependencyData(it, "compile") } +
|
val compileDependencies = pluginDependencies.map { toDependencyData(it, "compile") } +
|
||||||
allDeps(project.compileDependencies).map { toDependencyData(it, "compile") } +
|
allDeps(project.compileDependencies, name).map { toDependencyData(it, "compile") } +
|
||||||
allDeps(project.compileProvidedDependencies).map { toDependencyData(it, "compile") }
|
allDeps(project.compileProvidedDependencies, name).map { toDependencyData(it, "compile") }
|
||||||
val testDependencies = allDeps(project.testDependencies).map { toDependencyData(it, "testCompile") }
|
val testDependencies = allDeps(project.testDependencies, name).map { toDependencyData(it, "testCompile") }
|
||||||
|
|
||||||
val dependentProjects = project.dependsOn.map { it.name }
|
val dependentProjects = project.dependsOn.map { it.name }
|
||||||
|
|
||||||
|
|
|
@ -144,7 +144,7 @@ class KotlinCompiler @Inject constructor(
|
||||||
val executor = executors.newExecutor("KotlinCompiler", 10)
|
val executor = executors.newExecutor("KotlinCompiler", 10)
|
||||||
val compilerVersion = settings.kobaltCompilerVersion
|
val compilerVersion = settings.kobaltCompilerVersion
|
||||||
val compilerDep = dependencyManager.create("org.jetbrains.kotlin:kotlin-compiler-embeddable:$compilerVersion")
|
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
|
// Force a download of the compiler dependencies
|
||||||
deps.forEach { it.jarFile.get() }
|
deps.forEach { it.jarFile.get() }
|
||||||
|
|
|
@ -160,7 +160,7 @@ class DownloadTest @Inject constructor(
|
||||||
@Test
|
@Test
|
||||||
fun variablesShouldBeExpanded() {
|
fun variablesShouldBeExpanded() {
|
||||||
val dep = dependencyManager.createMaven("org.mapdb:mapdb:3.0.0-M3")
|
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")}
|
val d = closure.filter { it.id.contains("eclipse-collections-api")}
|
||||||
Assert.assertEquals(d.size, 1)
|
Assert.assertEquals(d.size, 1)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue