mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
Improve IClasspathDependency.
This commit is contained in:
parent
8871c47561
commit
40305af8b1
4 changed files with 11 additions and 10 deletions
|
@ -19,6 +19,9 @@ interface IClasspathDependency {
|
|||
/** Version for this identifier */
|
||||
val version: String
|
||||
|
||||
/** @return true if this dependency represents a Maven coordinate */
|
||||
val isMaven: Boolean
|
||||
|
||||
/** Absolute path to the jar file on the local file system */
|
||||
val jarFile: Future<File>
|
||||
|
||||
|
|
|
@ -21,14 +21,6 @@ class MavenId private constructor(val groupId: String, val artifactId: String, v
|
|||
size == 3 || size == 4
|
||||
}
|
||||
|
||||
private fun isVersion(s: String, id: String): Boolean {
|
||||
try {
|
||||
return s[0] == 'v' || Character.isDigit(s[0]) || isRangedVersion(s)
|
||||
} catch(ex: Exception) {
|
||||
error("Illegal version found in id \"$id\"")
|
||||
}
|
||||
}
|
||||
|
||||
fun isRangedVersion(s: String): Boolean {
|
||||
return s.first() in listOf('[', '(') && s.last() in listOf(']', ')')
|
||||
}
|
||||
|
@ -41,6 +33,7 @@ class MavenId private constructor(val groupId: String, val artifactId: String, v
|
|||
}
|
||||
|
||||
fun toKobaltId(id: String) = if (id.endsWith(":")) id + "(0,]" else id
|
||||
|
||||
/**
|
||||
* The main entry point to create Maven Id's. Id's created by this function
|
||||
* will run through IMavenIdInterceptors.
|
||||
|
@ -62,8 +55,9 @@ class MavenId private constructor(val groupId: String, val artifactId: String, v
|
|||
create(toId(groupId, artifactId, packaging, version))
|
||||
|
||||
fun toId(groupId: String, artifactId: String, packaging: String? = null, version: String?) =
|
||||
"$groupId:$artifactId:$version" +
|
||||
(if (packaging != null && packaging != "") "@$packaging" else "")
|
||||
"$groupId:$artifactId" +
|
||||
(if (packaging != null && packaging != "") ":$packaging" else "") +
|
||||
":$version"
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -186,6 +186,8 @@ class AetherDependency(val artifact: Artifact): IClasspathDependency, Comparable
|
|||
|
||||
override val version: String = artifact.version
|
||||
|
||||
override val isMaven = true
|
||||
|
||||
private fun toId(a: Artifact) = with(a) {
|
||||
groupId + ":" + artifactId + ":" + version
|
||||
}
|
||||
|
|
|
@ -14,6 +14,8 @@ open public class FileDependency(open val fileName: String) : IClasspathDependen
|
|||
|
||||
override val version = "0.0"
|
||||
|
||||
override val isMaven = false
|
||||
|
||||
override val jarFile = CompletedFuture(File(fileName))
|
||||
|
||||
override fun toMavenDependencies(): Dependency {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue