From cc73131a3d65ea4830b087ea7f1fd73b68e5a3d8 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Sun, 27 Mar 2016 09:46:45 -0700 Subject: [PATCH] Rely on Aether to parse Maven coordinates. --- .../kotlin/com/beust/kobalt/maven/MavenId.kt | 24 +++---------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/MavenId.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/MavenId.kt index 3bd3276d..e3f4b0f5 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/MavenId.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/MavenId.kt @@ -1,6 +1,7 @@ package com.beust.kobalt.maven 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". @@ -35,29 +36,10 @@ class MavenId private constructor(val groupId: String, val artifactId: String, v /** * Similar to create(MavenId) but don't run IMavenIdInterceptors. */ - fun createNoInterceptors(id: String) : MavenId { - var groupId: String? = null - var artifactId: String? = null - var version: String? = null - var packaging: String? = null - if (!isMavenId(id)) { - throw IllegalArgumentException("Illegal id: $id") + fun createNoInterceptors(id: String) : MavenId = DefaultArtifact(id).run { + MavenId(groupId, artifactId, extension, version) } - 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 * will run through IMavenIdInterceptors.