mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
Refactor CheckVersions to work on individual projects.
This commit is contained in:
parent
040bcd173b
commit
edb119c6b1
2 changed files with 20 additions and 20 deletions
|
@ -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<Project>) {
|
||||
fun run(projects: List<Project>) = projects.forEach { run(it) }
|
||||
|
||||
fun run(project: Project) {
|
||||
val executor = executors.newExecutor("CheckVersions", 5)
|
||||
|
||||
val newVersions = hashSetOf<String>()
|
||||
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()
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue