mirror of https://github.com/sbt/sbt.git
Move ModuleID toString out
This commit is contained in:
parent
4ca5b5ae0a
commit
a87ed10dc7
|
|
@ -257,9 +257,7 @@
|
|||
{ "name": "branchName", "type": "Option[String]", "default": "None", "since": "0.0.1" }
|
||||
],
|
||||
"toString": [
|
||||
"organization + \":\" + name + \":\" + revision +",
|
||||
" (configurations match { case Some(s) => \":\" + s; case None => \"\" }) +",
|
||||
" (if (extraAttributes.isEmpty) \"\" else \" \" + extraString)"
|
||||
"this.toStringImpl"
|
||||
],
|
||||
"parentsCompanion": "sbt.librarymanagement.ModuleIDFunctions"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ package sbt.librarymanagement
|
|||
import java.net.URL
|
||||
|
||||
import sbt.internal.librarymanagement.mavenint.SbtPomExtraProperties
|
||||
import scala.collection.mutable.ListBuffer
|
||||
|
||||
abstract class ModuleIDExtra {
|
||||
def organization: String
|
||||
|
|
@ -38,6 +39,31 @@ abstract class ModuleIDExtra {
|
|||
branchName: Option[String] = branchName
|
||||
): ModuleID
|
||||
|
||||
protected def toStringImpl: String =
|
||||
s"""$organization:$name:$revision""" +
|
||||
(configurations match { case Some(s) => ":" + s; case None => "" }) +
|
||||
{
|
||||
val attr = attributeString
|
||||
if (attr == "") ""
|
||||
else " " + attr
|
||||
} +
|
||||
(if (extraAttributes.isEmpty) "" else " " + extraString)
|
||||
|
||||
protected def attributeString: String =
|
||||
{
|
||||
val buffer = ListBuffer.empty[String]
|
||||
if (isChanging) {
|
||||
buffer += "changing"
|
||||
}
|
||||
if (!isTransitive) {
|
||||
buffer += "intransitive"
|
||||
}
|
||||
if (isForce) {
|
||||
buffer += "force"
|
||||
}
|
||||
buffer.toList.mkString(";")
|
||||
}
|
||||
|
||||
/** String representation of the extra attributes, excluding any information only attributes. */
|
||||
def extraString: String = extraDependencyAttributes.map { case (k, v) => k + "=" + v } mkString ("(", ", ", ")")
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue