mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
CheckVersions fix attempt.
This commit is contained in:
parent
f7673cba46
commit
fd5f77d922
3 changed files with 9 additions and 20 deletions
|
@ -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())
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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,25 +26,15 @@ 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 (releases != null) {
|
|
||||||
val strings = releases.map { it.toString() }
|
|
||||||
val c = strings.contains("1.0.8")
|
|
||||||
val sv = releases.map { StringVersion(it.toString()) }
|
|
||||||
Collections.sort(sv, Collections.reverseOrder())
|
|
||||||
if (sv.any()) sv[0] else null
|
|
||||||
} else {
|
|
||||||
null
|
|
||||||
}
|
|
||||||
|
|
||||||
val highest = highestRelease ?: versions?.highestVersion.toString()
|
if (rangeResult != null) {
|
||||||
|
val highest = rangeResult.highestVersion?.toString()
|
||||||
if (highest != dep.id
|
if (highest != null && highest != dep.id
|
||||||
&& StringVersion(highest.toString()) > StringVersion(dep.version)) {
|
&& StringVersion(highest) > StringVersion(dep.version)) {
|
||||||
newVersions.add(artifact.groupId + ":" + artifact.artifactId + ":" + highest)
|
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")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue