mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 00:17:11 -07:00
Fix CheckVersion.
This commit is contained in:
parent
293747a38a
commit
76e85eeb1f
2 changed files with 18 additions and 14 deletions
|
@ -17,6 +17,10 @@ public class MavenId(val id: String) {
|
|||
var version: String? = null
|
||||
|
||||
companion object {
|
||||
fun isMavenId(id: String) = with(id.split(":")) {
|
||||
size == 3 || size == 4
|
||||
}
|
||||
|
||||
fun create(groupId: String, artifactId: String, packaging: String?, version: String?) =
|
||||
MavenId(toId(groupId, artifactId, packaging, version))
|
||||
|
||||
|
@ -27,10 +31,10 @@ public class MavenId(val id: String) {
|
|||
}
|
||||
|
||||
init {
|
||||
val c = id.split(":")
|
||||
if (c.size != 3 && c.size != 4) {
|
||||
if (! isMavenId(id)) {
|
||||
throw IllegalArgumentException("Illegal id: $id")
|
||||
}
|
||||
val c = id.split(":")
|
||||
groupId = c[0]
|
||||
artifactId = c[1]
|
||||
if (! c[2].isEmpty()) {
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package com.beust.kobalt.misc
|
||||
|
||||
import com.beust.kobalt.api.Kobalt
|
||||
import com.beust.kobalt.api.Project
|
||||
import com.beust.kobalt.maven.DepFactory
|
||||
import com.beust.kobalt.maven.MavenDependency
|
||||
import com.beust.kobalt.maven.MavenId
|
||||
import javax.inject.Inject
|
||||
|
||||
/**
|
||||
|
@ -17,16 +17,16 @@ public class CheckVersions @Inject constructor(val depFactory : DepFactory,
|
|||
|
||||
val newVersions = hashSetOf<String>()
|
||||
projects.forEach {
|
||||
val kobaltDependency = arrayListOf(
|
||||
MavenDependency.create("com.beust:kobalt:" + Kobalt.version, executor))
|
||||
arrayListOf(kobaltDependency, it.compileDependencies, it.testDependencies).forEach { cd ->
|
||||
cd.forEach {
|
||||
val dep = depFactory.create(it.shortId, executor, false /* go remote */)
|
||||
if (dep is MavenDependency && it is MavenDependency) {
|
||||
if (dep.id != it.id
|
||||
&& Versions.toLongVersion(dep.version)
|
||||
> Versions.toLongVersion(it.version)) {
|
||||
newVersions.add(dep.id)
|
||||
arrayListOf(it.compileDependencies, it.testDependencies).forEach { cds ->
|
||||
cds.forEach { compileDependency ->
|
||||
if (MavenId.isMavenId(compileDependency.id)) {
|
||||
val dep = depFactory.create(compileDependency.shortId, executor, false /* go remote */)
|
||||
if (dep is MavenDependency) {
|
||||
val other = compileDependency as MavenDependency
|
||||
if (dep.id != compileDependency.id
|
||||
&& Versions.toLongVersion(dep.version) > Versions.toLongVersion(other.version)) {
|
||||
newVersions.add(dep.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ public class CheckVersions @Inject constructor(val depFactory : DepFactory,
|
|||
|
||||
if (newVersions.size > 0) {
|
||||
log(1, "New versions found:")
|
||||
newVersions.forEach { log(1, " ${it}") }
|
||||
newVersions.forEach { log(1, " $it") }
|
||||
} else {
|
||||
log(1, "All dependencies up to date")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue