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

Fix CheckVersion.

This commit is contained in:
Cedric Beust 2015-11-14 17:47:37 -08:00
parent 293747a38a
commit 76e85eeb1f
2 changed files with 18 additions and 14 deletions

View file

@ -17,6 +17,10 @@ public class MavenId(val id: String) {
var version: String? = null var version: String? = null
companion object { companion object {
fun isMavenId(id: String) = with(id.split(":")) {
size == 3 || size == 4
}
fun create(groupId: String, artifactId: String, packaging: String?, version: String?) = fun create(groupId: String, artifactId: String, packaging: String?, version: String?) =
MavenId(toId(groupId, artifactId, packaging, version)) MavenId(toId(groupId, artifactId, packaging, version))
@ -27,10 +31,10 @@ public class MavenId(val id: String) {
} }
init { init {
val c = id.split(":") if (! isMavenId(id)) {
if (c.size != 3 && c.size != 4) {
throw IllegalArgumentException("Illegal id: $id") throw IllegalArgumentException("Illegal id: $id")
} }
val c = id.split(":")
groupId = c[0] groupId = c[0]
artifactId = c[1] artifactId = c[1]
if (! c[2].isEmpty()) { if (! c[2].isEmpty()) {

View file

@ -1,9 +1,9 @@
package com.beust.kobalt.misc package com.beust.kobalt.misc
import com.beust.kobalt.api.Kobalt
import com.beust.kobalt.api.Project import com.beust.kobalt.api.Project
import com.beust.kobalt.maven.DepFactory import com.beust.kobalt.maven.DepFactory
import com.beust.kobalt.maven.MavenDependency import com.beust.kobalt.maven.MavenDependency
import com.beust.kobalt.maven.MavenId
import javax.inject.Inject import javax.inject.Inject
/** /**
@ -17,16 +17,16 @@ public class CheckVersions @Inject constructor(val depFactory : DepFactory,
val newVersions = hashSetOf<String>() val newVersions = hashSetOf<String>()
projects.forEach { projects.forEach {
val kobaltDependency = arrayListOf( arrayListOf(it.compileDependencies, it.testDependencies).forEach { cds ->
MavenDependency.create("com.beust:kobalt:" + Kobalt.version, executor)) cds.forEach { compileDependency ->
arrayListOf(kobaltDependency, it.compileDependencies, it.testDependencies).forEach { cd -> if (MavenId.isMavenId(compileDependency.id)) {
cd.forEach { val dep = depFactory.create(compileDependency.shortId, executor, false /* go remote */)
val dep = depFactory.create(it.shortId, executor, false /* go remote */) if (dep is MavenDependency) {
if (dep is MavenDependency && it is MavenDependency) { val other = compileDependency as MavenDependency
if (dep.id != it.id if (dep.id != compileDependency.id
&& Versions.toLongVersion(dep.version) && Versions.toLongVersion(dep.version) > Versions.toLongVersion(other.version)) {
> Versions.toLongVersion(it.version)) { newVersions.add(dep.id)
newVersions.add(dep.id) }
} }
} }
} }
@ -35,7 +35,7 @@ public class CheckVersions @Inject constructor(val depFactory : DepFactory,
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")
} }