mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 16:28:12 -07:00
Fix --checkVersions to work with Aether.
This commit is contained in:
parent
57ed92ca57
commit
539c6cbda3
2 changed files with 32 additions and 23 deletions
|
@ -23,7 +23,6 @@ import org.eclipse.aether.collection.CollectResult
|
||||||
import org.eclipse.aether.graph.Dependency
|
import org.eclipse.aether.graph.Dependency
|
||||||
import org.eclipse.aether.graph.DependencyFilter
|
import org.eclipse.aether.graph.DependencyFilter
|
||||||
import org.eclipse.aether.graph.DependencyNode
|
import org.eclipse.aether.graph.DependencyNode
|
||||||
import org.eclipse.aether.metadata.DefaultMetadata
|
|
||||||
import org.eclipse.aether.repository.RemoteRepository
|
import org.eclipse.aether.repository.RemoteRepository
|
||||||
import org.eclipse.aether.resolution.*
|
import org.eclipse.aether.resolution.*
|
||||||
import org.eclipse.aether.transfer.ArtifactNotFoundException
|
import org.eclipse.aether.transfer.ArtifactNotFoundException
|
||||||
|
@ -119,26 +118,33 @@ class Aether(val localRepo: File, val settings: KobaltSettings, val eventBus: Ev
|
||||||
}
|
}
|
||||||
|
|
||||||
fun resolveVersion(artifact: Artifact): VersionRangeResult? {
|
fun resolveVersion(artifact: Artifact): VersionRangeResult? {
|
||||||
val metadata = DefaultMetadata(artifact.groupId, artifact.artifactId, "maven-metadata.xml",
|
val request = VersionRangeRequest(artifact, kobaltRepositories, null)
|
||||||
org.eclipse.aether.metadata.Metadata.Nature.RELEASE)
|
val result = system.resolveVersionRange(session, request)
|
||||||
|
return result
|
||||||
val r = system.resolveMetadata(session, kobaltRepositories.map {
|
}
|
||||||
MetadataRequest(metadata, it, null).apply {
|
|
||||||
isFavorLocalRepository = false
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
|
private fun oldResolveVErsion() {
|
||||||
|
// val artifact = DefaultArtifact(a.groupId, a.artifactId, null, "[0,)")
|
||||||
|
// val r = system.resolveMetadata(session, kobaltRepositories.map {
|
||||||
|
// MetadataRequest(metadata, it, null).apply {
|
||||||
|
// isFavorLocalRepository = false
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
|
||||||
|
// val metadata = DefaultMetadata(artifact.groupId, artifact.artifactId, "maven-metadata.xml",
|
||||||
|
// org.eclipse.aether.metadata.Metadata.Nature.RELEASE)
|
||||||
|
//
|
||||||
// kobaltRepositories.forEach {
|
// kobaltRepositories.forEach {
|
||||||
// val request = MetadataRequest(metadata, it, null).apply {
|
// val request = MetadataRequest(metadata, it, null).apply {
|
||||||
// isFavorLocalRepository = false
|
// isFavorLocalRepository = false
|
||||||
// }
|
// }
|
||||||
// val r = system.resolveMetadata(session, listOf(request))
|
// val md = system.resolveMetadata(session, listOf(request))
|
||||||
// println("Repo: $it " + r)
|
// if (artifact.groupId.contains("org.testng")) {
|
||||||
|
// println("DONOTCOMMIT")
|
||||||
|
// }
|
||||||
|
// println("Repo: $it " + md)
|
||||||
// }
|
// }
|
||||||
val request = VersionRangeRequest(artifact, kobaltRepositories, null)
|
|
||||||
val result = system.resolveVersionRange(session, request)
|
|
||||||
return result
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun resolve(artifact: Artifact): List<ArtifactResult> {
|
fun resolve(artifact: Artifact): List<ArtifactResult> {
|
||||||
|
|
|
@ -4,6 +4,7 @@ import com.beust.kobalt.KobaltException
|
||||||
import com.beust.kobalt.api.Project
|
import com.beust.kobalt.api.Project
|
||||||
import com.beust.kobalt.maven.DependencyManager
|
import com.beust.kobalt.maven.DependencyManager
|
||||||
import com.beust.kobalt.maven.MavenId
|
import com.beust.kobalt.maven.MavenId
|
||||||
|
import com.beust.kobalt.maven.aether.Aether
|
||||||
import com.beust.kobalt.maven.aether.AetherDependency
|
import com.beust.kobalt.maven.aether.AetherDependency
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
@ -11,7 +12,7 @@ import javax.inject.Inject
|
||||||
* Find out if any newer versions of the dependencies are available.
|
* Find out if any newer versions of the dependencies are available.
|
||||||
*/
|
*/
|
||||||
public class CheckVersions @Inject constructor(val depManager: DependencyManager,
|
public class CheckVersions @Inject constructor(val depManager: DependencyManager,
|
||||||
val executors : KobaltExecutors) {
|
val executors : KobaltExecutors, val aether: Aether) {
|
||||||
|
|
||||||
fun run(projects: List<Project>) {
|
fun run(projects: List<Project>) {
|
||||||
val executor = executors.newExecutor("CheckVersions", 5)
|
val executor = executors.newExecutor("CheckVersions", 5)
|
||||||
|
@ -19,17 +20,19 @@ public class CheckVersions @Inject constructor(val depManager: DependencyManager
|
||||||
val newVersions = hashSetOf<String>()
|
val newVersions = hashSetOf<String>()
|
||||||
projects.forEach { project ->
|
projects.forEach { project ->
|
||||||
listOf(project.compileDependencies, project.testDependencies).forEach { cds ->
|
listOf(project.compileDependencies, project.testDependencies).forEach { cds ->
|
||||||
cds.forEach { compileDependency ->
|
cds.forEach { dep ->
|
||||||
if (MavenId.isMavenId(compileDependency.id)) {
|
if (MavenId.isMavenId(dep.id)) {
|
||||||
try {
|
try {
|
||||||
val dep = depManager.create(compileDependency.shortId, project.directory)
|
val latestDep = depManager.create(dep.shortId, project.directory)
|
||||||
val other = compileDependency as AetherDependency
|
val artifact = (latestDep as AetherDependency).artifact
|
||||||
if (dep.id != compileDependency.id
|
val versions = aether.resolveVersion(artifact)
|
||||||
&& Versions.toLongVersion(dep.version) > Versions.toLongVersion(other.version)) {
|
val highest = versions?.highestVersion?.toString()
|
||||||
newVersions.add(dep.id)
|
if (highest != null && highest != dep.id
|
||||||
|
&& Versions.toLongVersion(highest) > Versions.toLongVersion(dep.version)) {
|
||||||
|
newVersions.add(artifact.groupId + ":" + artifact.artifactId + ":" + highest)
|
||||||
}
|
}
|
||||||
} catch(e: KobaltException) {
|
} catch(e: KobaltException) {
|
||||||
log(1, " Cannot resolve ${compileDependency.shortId}. ignoring")
|
log(1, " Cannot resolve ${dep.shortId}. ignoring")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue