diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/DependencyManager.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/DependencyManager.kt index 58f837ae..1bcb7b67 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/DependencyManager.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/DependencyManager.kt @@ -90,7 +90,7 @@ class DependencyManager @Inject constructor(val executors: KobaltExecutors, val vararg allDependencies: List): List { val result = arrayListOf() 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, indent : String = " "): + fun transitiveClosure(dependencies : List, requiredBy: String? = null, + indent : String = " "): List { 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 { diff --git a/src/main/kotlin/com/beust/kobalt/app/remote/DependencyData.kt b/src/main/kotlin/com/beust/kobalt/app/remote/DependencyData.kt index 77455f8a..67e1e438 100644 --- a/src/main/kotlin/com/beust/kobalt/app/remote/DependencyData.kt +++ b/src/main/kotlin/com/beust/kobalt/app/remote/DependencyData.kt @@ -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) = dependencyManager.transitiveClosure(l) + fun allDeps(l: List, 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() 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 } diff --git a/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinCompiler.kt b/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinCompiler.kt index 1190baf3..e34f0a0b 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinCompiler.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinCompiler.kt @@ -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() } diff --git a/src/test/kotlin/com/beust/kobalt/maven/DownloadTest.kt b/src/test/kotlin/com/beust/kobalt/maven/DownloadTest.kt index 3a03ee5a..a3f73325 100644 --- a/src/test/kotlin/com/beust/kobalt/maven/DownloadTest.kt +++ b/src/test/kotlin/com/beust/kobalt/maven/DownloadTest.kt @@ -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), "") val d = closure.filter { it.id.contains("eclipse-collections-api")} Assert.assertEquals(d.size, 1) }