From 38b2379227ddb8c693e8811a39a4ddfa3119606d Mon Sep 17 00:00:00 2001 From: Kevin Mas Ruiz Date: Fri, 6 May 2016 20:42:57 +0200 Subject: [PATCH] add classifier when need --- .../kotlin/com/beust/kobalt/maven/LocalRepo.kt | 2 +- .../main/kotlin/com/beust/kobalt/maven/MavenId.kt | 15 ++++++++------- .../kotlin/com/beust/kobalt/maven/PomGenerator.kt | 5 +++-- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/LocalRepo.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/LocalRepo.kt index e42cc75d..5077d5b9 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/LocalRepo.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/LocalRepo.kt @@ -39,7 +39,7 @@ open class LocalRepo @Inject constructor(val kobaltSettings: KobaltSettings) { v2.compareTo(v1) // we want the most recent at position 0 }) val result = directories[0].name - val newDep = LocalDep(MavenId.create(groupId, artifactId, packaging, result), this) + val newDep = LocalDep(MavenId.create(groupId, artifactId, packaging, null, result), this) if (existsPom(newDep, result) && existsJar(newDep, result)) { return result } 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 e80d5925..1ab12db7 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 @@ -14,11 +14,11 @@ import org.eclipse.aether.artifact.DefaultArtifact * usually means "latest version") but it doesn't handle version ranges yet. */ class MavenId private constructor(val groupId: String, val artifactId: String, val packaging: String?, - val version: String?) { + val classifier: String?, val version: String?) { companion object { fun isMavenId(id: String) = with(id.split(":")) { - size == 3 || size == 4 + size >= 3 && size <= 5 } fun isRangedVersion(s: String): Boolean { @@ -29,7 +29,7 @@ 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 = DefaultArtifact(id).run { - MavenId(groupId, artifactId, extension, version) + MavenId(groupId, artifactId, extension, classifier, version) } fun toKobaltId(id: String) = if (id.endsWith(":")) id + "(0,]" else id @@ -51,18 +51,19 @@ class MavenId private constructor(val groupId: String, val artifactId: String, v return interceptedMavenId } - fun create(groupId: String, artifactId: String, packaging: String?, version: String?) = - create(toId(groupId, artifactId, packaging, version)) + fun create(groupId: String, artifactId: String, packaging: String?, classifier: String?, version: String?) = + create(toId(groupId, artifactId, packaging, classifier, version)) - fun toId(groupId: String, artifactId: String, packaging: String? = null, version: String?) = + fun toId(groupId: String, artifactId: String, packaging: String? = null, classifier: String? = null, version: String?) = "$groupId:$artifactId" + (if (packaging != null && packaging != "") ":$packaging" else "") + + (if (classifier != null && classifier != "") ":$classifier" else "") + ":$version" } val hasVersion = version != null - val toId = MavenId.toId(groupId, artifactId, packaging, version) + val toId = MavenId.toId(groupId, artifactId, packaging, classifier, version) } diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/PomGenerator.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/PomGenerator.kt index 460ccc4e..2ccc9250 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/PomGenerator.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/PomGenerator.kt @@ -56,10 +56,11 @@ public class PomGenerator @Inject constructor(@Assisted val project: Project) { val buildDir = KFiles.makeDir(project.directory, project.buildDirectory) val outputDir = KFiles.makeDir(buildDir.path, "libs") - val mavenId = MavenId.create(project.group!!, project.artifactId!!, project.packaging, project.version!!) + val NO_CLASSIFIER = null + val mavenId = MavenId.create(project.group!!, project.artifactId!!, project.packaging, NO_CLASSIFIER, project.version!!) val pomFile = SimpleDep(mavenId).toPomFileName() val outputFile = File(outputDir, pomFile) outputFile.writeText(s.toString(), Charset.defaultCharset()) log(1, " Created $outputFile") } -} \ No newline at end of file +}