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

CheckVersions fix attempt.

This commit is contained in:
Cedric Beust 2017-03-26 12:44:45 -07:00
parent f7673cba46
commit fd5f77d922
3 changed files with 9 additions and 20 deletions

View file

@ -34,7 +34,7 @@ class ResolveDependency @Inject constructor(
private fun latestMavenArtifact(group: String, artifactId: String, extension: String = "jar"): DependencyNode { private fun latestMavenArtifact(group: String, artifactId: String, extension: String = "jar"): DependencyNode {
val artifact = DefaultArtifact(group, artifactId, extension, "(0,]") val artifact = DefaultArtifact(group, artifactId, extension, "(0,]")
val resolved = aether.resolveVersion(artifact) val resolved = aether.resolveRange(artifact)
if (resolved != null) { if (resolved != null) {
val newArtifact = DefaultArtifact(artifact.groupId, artifact.artifactId, artifact.extension, val newArtifact = DefaultArtifact(artifact.groupId, artifact.artifactId, artifact.extension,
resolved.highestVersion.toString()) resolved.highestVersion.toString())

View file

@ -74,7 +74,7 @@ class KobaltMavenResolver @Inject constructor(val settings: KobaltSettings,
directDependencies(id, scope) directDependencies(id, scope)
} }
fun resolveVersion(artifact: Artifact): VersionRangeResult? { fun resolveRange(artifact: Artifact): VersionRangeResult? {
val request = VersionRangeRequest(artifact, kobaltRepositories, null) val request = VersionRangeRequest(artifact, kobaltRepositories, null)
val result = system.resolveVersionRange(session, request) val result = system.resolveVersionRange(session, request)
return result return result

View file

@ -6,7 +6,6 @@ import com.beust.kobalt.maven.DependencyManager
import com.beust.kobalt.maven.MavenId import com.beust.kobalt.maven.MavenId
import com.beust.kobalt.maven.aether.AetherDependency import com.beust.kobalt.maven.aether.AetherDependency
import com.beust.kobalt.maven.aether.KobaltMavenResolver import com.beust.kobalt.maven.aether.KobaltMavenResolver
import java.util.*
import javax.inject.Inject import javax.inject.Inject
/** /**
@ -27,24 +26,14 @@ class CheckVersions @Inject constructor(val depManager: DependencyManager,
try { try {
val latestDep = depManager.create(dep.shortId, false, project.directory) val latestDep = depManager.create(dep.shortId, false, project.directory)
val artifact = (latestDep as AetherDependency).artifact val artifact = (latestDep as AetherDependency).artifact
val versions = resolver.resolveVersion(artifact) val rangeResult = resolver.resolveRange(artifact)
val releases = versions?.versions?.filter { !it.toString().contains("SNAP")}
val highestRelease = if (rangeResult != null) {
if (releases != null) { val highest = rangeResult.highestVersion?.toString()
val strings = releases.map { it.toString() } if (highest != null && highest != dep.id
val c = strings.contains("1.0.8") && StringVersion(highest) > StringVersion(dep.version)) {
val sv = releases.map { StringVersion(it.toString()) } newVersions.add(artifact.groupId + ":" + artifact.artifactId + ":" + highest)
Collections.sort(sv, Collections.reverseOrder())
if (sv.any()) sv[0] else null
} else {
null
} }
val highest = highestRelease ?: versions?.highestVersion.toString()
if (highest != dep.id
&& StringVersion(highest.toString()) > StringVersion(dep.version)) {
newVersions.add(artifact.groupId + ":" + artifact.artifactId + ":" + highest)
} }
} catch(e: KobaltException) { } catch(e: KobaltException) {
kobaltLog(1, " Cannot resolve ${dep.shortId}. ignoring") kobaltLog(1, " Cannot resolve ${dep.shortId}. ignoring")