mirror of https://github.com/sbt/sbt.git
Merge pull request #390 from eed3si9n/wip/configref
intern/flyweight ConfigRef
This commit is contained in:
commit
cb41524fbe
|
|
@ -1,36 +0,0 @@
|
||||||
/**
|
|
||||||
* This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
|
|
||||||
*/
|
|
||||||
|
|
||||||
// DO NOT EDIT MANUALLY
|
|
||||||
package sbt.librarymanagement
|
|
||||||
/**
|
|
||||||
* A reference to Configuration.
|
|
||||||
* @param name The name of the configuration that eventually get used by Maven.
|
|
||||||
*/
|
|
||||||
final class ConfigRef private (
|
|
||||||
val name: String) extends Serializable {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
override def equals(o: Any): Boolean = this.eq(o.asInstanceOf[AnyRef]) || (o match {
|
|
||||||
case x: ConfigRef => (this.name == x.name)
|
|
||||||
case _ => false
|
|
||||||
})
|
|
||||||
override def hashCode: Int = {
|
|
||||||
37 * (37 * (17 + "sbt.librarymanagement.ConfigRef".##) + name.##)
|
|
||||||
}
|
|
||||||
override def toString: String = {
|
|
||||||
name
|
|
||||||
}
|
|
||||||
private[this] def copy(name: String = name): ConfigRef = {
|
|
||||||
new ConfigRef(name)
|
|
||||||
}
|
|
||||||
def withName(name: String): ConfigRef = {
|
|
||||||
copy(name = name)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
object ConfigRef extends sbt.librarymanagement.ConfigRefFunctions {
|
|
||||||
|
|
||||||
def apply(name: String): ConfigRef = new ConfigRef(name)
|
|
||||||
}
|
|
||||||
|
|
@ -1,27 +0,0 @@
|
||||||
/**
|
|
||||||
* This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
|
|
||||||
*/
|
|
||||||
|
|
||||||
// DO NOT EDIT MANUALLY
|
|
||||||
package sbt.librarymanagement
|
|
||||||
import _root_.sjsonnew.{ Unbuilder, Builder, JsonFormat, deserializationError }
|
|
||||||
trait ConfigRefFormats { self: sjsonnew.BasicJsonProtocol =>
|
|
||||||
implicit lazy val ConfigRefFormat: JsonFormat[sbt.librarymanagement.ConfigRef] = new JsonFormat[sbt.librarymanagement.ConfigRef] {
|
|
||||||
override def read[J](__jsOpt: Option[J], unbuilder: Unbuilder[J]): sbt.librarymanagement.ConfigRef = {
|
|
||||||
__jsOpt match {
|
|
||||||
case Some(__js) =>
|
|
||||||
unbuilder.beginObject(__js)
|
|
||||||
val name = unbuilder.readField[String]("name")
|
|
||||||
unbuilder.endObject()
|
|
||||||
sbt.librarymanagement.ConfigRef(name)
|
|
||||||
case None =>
|
|
||||||
deserializationError("Expected JsObject but found None")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
override def write[J](obj: sbt.librarymanagement.ConfigRef, builder: Builder[J]): Unit = {
|
|
||||||
builder.beginObject()
|
|
||||||
builder.addField("name", obj.name)
|
|
||||||
builder.endObject()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -4,8 +4,8 @@
|
||||||
|
|
||||||
// DO NOT EDIT MANUALLY
|
// DO NOT EDIT MANUALLY
|
||||||
package sbt.librarymanagement
|
package sbt.librarymanagement
|
||||||
trait LibraryManagementCodec extends sjsonnew.BasicJsonProtocol
|
trait LibraryManagementCodec extends sbt.librarymanagement.ConfigRefFormats
|
||||||
with sbt.librarymanagement.ConfigRefFormats
|
with sjsonnew.BasicJsonProtocol
|
||||||
with sbt.librarymanagement.RetrieveConfigurationFormats
|
with sbt.librarymanagement.RetrieveConfigurationFormats
|
||||||
with sbt.librarymanagement.UpdateLoggingFormats
|
with sbt.librarymanagement.UpdateLoggingFormats
|
||||||
with sbt.internal.librarymanagement.formats.LogicalClockFormats
|
with sbt.internal.librarymanagement.formats.LogicalClockFormats
|
||||||
|
|
|
||||||
|
|
@ -192,24 +192,6 @@
|
||||||
],
|
],
|
||||||
"toString": "s\"$caller\""
|
"toString": "s\"$caller\""
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "ConfigRef",
|
|
||||||
"namespace": "sbt.librarymanagement",
|
|
||||||
"target": "Scala",
|
|
||||||
"type": "record",
|
|
||||||
"doc": [
|
|
||||||
"A reference to Configuration."
|
|
||||||
],
|
|
||||||
"fields": [
|
|
||||||
{
|
|
||||||
"name": "name",
|
|
||||||
"type": "String",
|
|
||||||
"doc": [ "The name of the configuration that eventually get used by Maven." ]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"parentsCompanion": "sbt.librarymanagement.ConfigRefFunctions",
|
|
||||||
"toString": "name"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "ConfigurationReport",
|
"name": "ConfigurationReport",
|
||||||
"namespace": "sbt.librarymanagement",
|
"namespace": "sbt.librarymanagement",
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,75 @@
|
||||||
|
/**
|
||||||
|
* This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
|
||||||
|
*/
|
||||||
|
package sbt.librarymanagement
|
||||||
|
|
||||||
|
import scala.collection.concurrent.TrieMap
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A reference to Configuration.
|
||||||
|
* @param name The name of the configuration that eventually get used by Maven.
|
||||||
|
*/
|
||||||
|
final class ConfigRef private (val name: String) extends Serializable {
|
||||||
|
|
||||||
|
override def equals(o: Any): Boolean =
|
||||||
|
this.eq(o.asInstanceOf[AnyRef])
|
||||||
|
|
||||||
|
override val hashCode: Int = {
|
||||||
|
37 * (37 * (17 + "sbt.librarymanagement.ConfigRef".##) + name.##)
|
||||||
|
}
|
||||||
|
|
||||||
|
override def toString: String = {
|
||||||
|
name
|
||||||
|
}
|
||||||
|
|
||||||
|
private[this] def copy(name: String = name): ConfigRef = {
|
||||||
|
ConfigRef(name)
|
||||||
|
}
|
||||||
|
|
||||||
|
def withName(name: String): ConfigRef = {
|
||||||
|
copy(name = name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
object ConfigRef extends sbt.librarymanagement.ConfigRefFunctions {
|
||||||
|
// cache the reference to ConfigRefs
|
||||||
|
private val cache = new TrieMap[String, ConfigRef]
|
||||||
|
private lazy val Default = new ConfigRef("default")
|
||||||
|
private lazy val Compile = new ConfigRef("compile")
|
||||||
|
private lazy val IntegrationTest = new ConfigRef("it")
|
||||||
|
private lazy val Provided = new ConfigRef("provided")
|
||||||
|
private lazy val Runtime = new ConfigRef("runtime")
|
||||||
|
private lazy val Test = new ConfigRef("test")
|
||||||
|
private lazy val System = new ConfigRef("system")
|
||||||
|
private lazy val Optional = new ConfigRef("optional")
|
||||||
|
private lazy val Pom = new ConfigRef("pom")
|
||||||
|
private lazy val ScalaTool = new ConfigRef("scala-tool")
|
||||||
|
private lazy val ScalaDocTool = new ConfigRef("scala-doc-tool")
|
||||||
|
private lazy val CompilerPlugin = new ConfigRef("plugin")
|
||||||
|
private lazy val Component = new ConfigRef("component")
|
||||||
|
private lazy val RuntimeInternal = new ConfigRef("runtime-internal")
|
||||||
|
private lazy val TestInternal = new ConfigRef("test-internal")
|
||||||
|
private lazy val IntegrationTestInternal = new ConfigRef("it-internal")
|
||||||
|
private lazy val CompileInternal = new ConfigRef("compile-internal")
|
||||||
|
|
||||||
|
def apply(name: String): ConfigRef = name match {
|
||||||
|
case "default" => Default
|
||||||
|
case "compile" => Compile
|
||||||
|
case "it" => IntegrationTest
|
||||||
|
case "provided" => Provided
|
||||||
|
case "runtime" => Runtime
|
||||||
|
case "test" => Test
|
||||||
|
case "system" => System
|
||||||
|
case "optional" => Optional
|
||||||
|
case "pom" => Pom
|
||||||
|
case "scala-tool" => ScalaTool
|
||||||
|
case "scala-doc-tool" => ScalaDocTool
|
||||||
|
case "plugin" => CompilerPlugin
|
||||||
|
case "component" => Component
|
||||||
|
case "runtime-internal" => RuntimeInternal
|
||||||
|
case "test-internal" => TestInternal
|
||||||
|
case "it-internal" => IntegrationTestInternal
|
||||||
|
case "compile-internal" => CompileInternal
|
||||||
|
case _ => cache.getOrElseUpdate(name, new ConfigRef(name))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
/**
|
||||||
|
* This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]].
|
||||||
|
*/
|
||||||
|
package sbt.librarymanagement
|
||||||
|
|
||||||
|
import _root_.sjsonnew.{ Unbuilder, Builder, JsonFormat, deserializationError }
|
||||||
|
|
||||||
|
trait ConfigRefFormats { self: sjsonnew.BasicJsonProtocol =>
|
||||||
|
implicit lazy val ConfigRefFormat: JsonFormat[sbt.librarymanagement.ConfigRef] =
|
||||||
|
new JsonFormat[sbt.librarymanagement.ConfigRef] {
|
||||||
|
override def read[J](
|
||||||
|
__jsOpt: Option[J],
|
||||||
|
unbuilder: Unbuilder[J]
|
||||||
|
): sbt.librarymanagement.ConfigRef = {
|
||||||
|
__jsOpt match {
|
||||||
|
case Some(__js) =>
|
||||||
|
unbuilder.beginObject(__js)
|
||||||
|
val name = unbuilder.readField[String]("name")
|
||||||
|
unbuilder.endObject()
|
||||||
|
sbt.librarymanagement.ConfigRef(name)
|
||||||
|
case None =>
|
||||||
|
deserializationError("Expected JsObject but found None")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
override def write[J](obj: sbt.librarymanagement.ConfigRef, builder: Builder[J]): Unit = {
|
||||||
|
builder.beginObject()
|
||||||
|
builder.addField("name", obj.name)
|
||||||
|
builder.endObject()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -54,6 +54,10 @@ object DatatypeConfig {
|
||||||
Nil
|
Nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case "sbt.librarymanagement.ConfigRef" => { _ =>
|
||||||
|
"sbt.librarymanagement.ConfigRefFormats" :: Nil
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: These are handled by BasicJsonProtocol, and sbt-datatype should handle them by default, imo
|
// TODO: These are handled by BasicJsonProtocol, and sbt-datatype should handle them by default, imo
|
||||||
case "Option" | "Set" | "scala.Vector" => { tpe =>
|
case "Option" | "Set" | "scala.Vector" => { tpe =>
|
||||||
getFormats(oneArg(tpe))
|
getFormats(oneArg(tpe))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue