1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-27 00:38:11 -07:00

Refactor CheckVersions to work on individual projects.

This commit is contained in:
Cedric Beust 2016-06-27 02:21:05 -08:00
parent 040bcd173b
commit edb119c6b1
2 changed files with 20 additions and 20 deletions

View file

@ -14,11 +14,12 @@ import javax.inject.Inject
public class CheckVersions @Inject constructor(val depManager: DependencyManager, public class CheckVersions @Inject constructor(val depManager: DependencyManager,
val executors : KobaltExecutors, val aether: Aether) { val executors : KobaltExecutors, val aether: Aether) {
fun run(projects: List<Project>) { fun run(projects: List<Project>) = projects.forEach { run(it) }
fun run(project: Project) {
val executor = executors.newExecutor("CheckVersions", 5) val executor = executors.newExecutor("CheckVersions", 5)
val newVersions = hashSetOf<String>() val newVersions = hashSetOf<String>()
projects.forEach { project ->
listOf(project.compileDependencies, project.testDependencies).forEach { cds -> listOf(project.compileDependencies, project.testDependencies).forEach { cds ->
cds.forEach { dep -> cds.forEach { dep ->
if (MavenId.isMavenId(dep.id)) { if (MavenId.isMavenId(dep.id)) {
@ -37,13 +38,12 @@ public class CheckVersions @Inject constructor(val depManager: DependencyManager
} }
} }
} }
}
if (newVersions.size > 0) { if (newVersions.size > 0) {
log(1, "New versions found:") log(1, " New versions found:")
newVersions.forEach { log(1, " $it") } newVersions.forEach { log(1, " $it") }
} else { } else {
log(1, "All dependencies up to date") log(1, " All dependencies up to date")
} }
executor.shutdown() executor.shutdown()
} }

View file

@ -24,7 +24,7 @@ class KobaltPlugin @Inject constructor(val checkVersions: CheckVersions, val upd
@Task(name = "checkVersions", description = "Display all the outdated dependencies") @Task(name = "checkVersions", description = "Display all the outdated dependencies")
fun taskCheckVersions(project: Project) : TaskResult { fun taskCheckVersions(project: Project) : TaskResult {
checkVersions.run(context.allProjects) checkVersions.run(project)
return TaskResult() return TaskResult()
} }