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

Rely on Aether to parse Maven coordinates.

This commit is contained in:
Cedric Beust 2016-03-27 09:46:45 -07:00
parent 391df0c4a3
commit cc73131a3d

View file

@ -1,6 +1,7 @@
package com.beust.kobalt.maven package com.beust.kobalt.maven
import com.beust.kobalt.api.Kobalt import com.beust.kobalt.api.Kobalt
import org.eclipse.aether.artifact.DefaultArtifact
/** /**
* Encapsulate a Maven id captured in one string, as used by Gradle or Ivy, e.g. "org.testng:testng:6.9.9". * Encapsulate a Maven id captured in one string, as used by Gradle or Ivy, e.g. "org.testng:testng:6.9.9".
@ -35,29 +36,10 @@ class MavenId private constructor(val groupId: String, val artifactId: String, v
/** /**
* Similar to create(MavenId) but don't run IMavenIdInterceptors. * Similar to create(MavenId) but don't run IMavenIdInterceptors.
*/ */
fun createNoInterceptors(id: String) : MavenId { fun createNoInterceptors(id: String) : MavenId = DefaultArtifact(id).run {
var groupId: String? = null MavenId(groupId, artifactId, extension, version)
var artifactId: String? = null
var version: String? = null
var packaging: String? = null
if (!isMavenId(id)) {
throw IllegalArgumentException("Illegal id: $id")
} }
val c = id.split(":")
groupId = c[0]
artifactId = c[1]
if (!c[2].isEmpty()) {
val split = c[2].split('@')
if (isVersion(split[0], id)) {
version = split[0]
}
packaging = if (split.size == 2) split[1] else null
}
return MavenId(groupId, artifactId, packaging, version)
}
/** /**
* The main entry point to create Maven Id's. Id's created by this function * The main entry point to create Maven Id's. Id's created by this function
* will run through IMavenIdInterceptors. * will run through IMavenIdInterceptors.