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

Merge pull request #191 from kmruiz/bug/190-classifier

Add classifier to MavenId
This commit is contained in:
Cedric Beust 2016-05-06 12:34:42 -07:00
commit 89adedd800
3 changed files with 12 additions and 10 deletions

View file

@ -39,7 +39,7 @@ open class LocalRepo @Inject constructor(val kobaltSettings: KobaltSettings) {
v2.compareTo(v1) // we want the most recent at position 0 v2.compareTo(v1) // we want the most recent at position 0
}) })
val result = directories[0].name 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)) { if (existsPom(newDep, result) && existsJar(newDep, result)) {
return result return result
} }

View file

@ -14,11 +14,11 @@ import org.eclipse.aether.artifact.DefaultArtifact
* usually means "latest version") but it doesn't handle version ranges yet. * 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?, class MavenId private constructor(val groupId: String, val artifactId: String, val packaging: String?,
val version: String?) { val classifier: String?, val version: String?) {
companion object { companion object {
fun isMavenId(id: String) = with(id.split(":")) { fun isMavenId(id: String) = with(id.split(":")) {
size == 3 || size == 4 size >= 3 && size <= 5
} }
fun isRangedVersion(s: String): Boolean { 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. * Similar to create(MavenId) but don't run IMavenIdInterceptors.
*/ */
fun createNoInterceptors(id: String) : MavenId = DefaultArtifact(id).run { 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 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 return interceptedMavenId
} }
fun create(groupId: String, artifactId: String, packaging: String?, version: String?) = fun create(groupId: String, artifactId: String, packaging: String?, classifier: String?, version: String?) =
create(toId(groupId, artifactId, packaging, version)) 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" + "$groupId:$artifactId" +
(if (packaging != null && packaging != "") ":$packaging" else "") + (if (packaging != null && packaging != "") ":$packaging" else "") +
(if (classifier != null && classifier != "") ":$classifier" else "") +
":$version" ":$version"
} }
val hasVersion = version != null val hasVersion = version != null
val toId = MavenId.toId(groupId, artifactId, packaging, version) val toId = MavenId.toId(groupId, artifactId, packaging, classifier, version)
} }

View file

@ -56,10 +56,11 @@ public class PomGenerator @Inject constructor(@Assisted val project: Project) {
val buildDir = KFiles.makeDir(project.directory, project.buildDirectory) val buildDir = KFiles.makeDir(project.directory, project.buildDirectory)
val outputDir = KFiles.makeDir(buildDir.path, "libs") 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 pomFile = SimpleDep(mavenId).toPomFileName()
val outputFile = File(outputDir, pomFile) val outputFile = File(outputDir, pomFile)
outputFile.writeText(s.toString(), Charset.defaultCharset()) outputFile.writeText(s.toString(), Charset.defaultCharset())
log(1, " Created $outputFile") log(1, " Created $outputFile")
} }
} }