diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/CheckVersions.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/CheckVersions.kt index 85594423..397f7f98 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/CheckVersions.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/CheckVersions.kt @@ -14,36 +14,36 @@ import javax.inject.Inject public class CheckVersions @Inject constructor(val depManager: DependencyManager, val executors : KobaltExecutors, val aether: Aether) { - fun run(projects: List) { + fun run(projects: List) = projects.forEach { run(it) } + + fun run(project: Project) { val executor = executors.newExecutor("CheckVersions", 5) val newVersions = hashSetOf() - projects.forEach { project -> - listOf(project.compileDependencies, project.testDependencies).forEach { cds -> - cds.forEach { dep -> - if (MavenId.isMavenId(dep.id)) { - try { - val latestDep = depManager.create(dep.shortId, project.directory) - val artifact = (latestDep as AetherDependency).artifact - val versions = aether.resolveVersion(artifact) - val highest = versions?.highestVersion?.toString() - if (highest != null && highest != dep.id - && Versions.toLongVersion(highest) > Versions.toLongVersion(dep.version)) { - newVersions.add(artifact.groupId + ":" + artifact.artifactId + ":" + highest) - } - } catch(e: KobaltException) { - log(1, " Cannot resolve ${dep.shortId}. ignoring") + listOf(project.compileDependencies, project.testDependencies).forEach { cds -> + cds.forEach { dep -> + if (MavenId.isMavenId(dep.id)) { + try { + val latestDep = depManager.create(dep.shortId, project.directory) + val artifact = (latestDep as AetherDependency).artifact + val versions = aether.resolveVersion(artifact) + val highest = versions?.highestVersion?.toString() + if (highest != null && highest != dep.id + && Versions.toLongVersion(highest) > Versions.toLongVersion(dep.version)) { + newVersions.add(artifact.groupId + ":" + artifact.artifactId + ":" + highest) } + } catch(e: KobaltException) { + log(1, " Cannot resolve ${dep.shortId}. ignoring") } } } } if (newVersions.size > 0) { - log(1, "New versions found:") - newVersions.forEach { log(1, " $it") } + log(1, " New versions found:") + newVersions.forEach { log(1, " $it") } } else { - log(1, "All dependencies up to date") + log(1, " All dependencies up to date") } executor.shutdown() } diff --git a/src/main/kotlin/com/beust/kobalt/plugin/KobaltPlugin.kt b/src/main/kotlin/com/beust/kobalt/plugin/KobaltPlugin.kt index 1d555276..d8248b75 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/KobaltPlugin.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/KobaltPlugin.kt @@ -24,7 +24,7 @@ class KobaltPlugin @Inject constructor(val checkVersions: CheckVersions, val upd @Task(name = "checkVersions", description = "Display all the outdated dependencies") fun taskCheckVersions(project: Project) : TaskResult { - checkVersions.run(context.allProjects) + checkVersions.run(project) return TaskResult() }