mirror of
https://github.com/sbt/sbt.git
synced 2026-09-01 18:47:14 +02:00
Environment variables support in BSP debug session
This commit is contained in:
@@ -8,26 +8,28 @@ package sbt.internal.bsp
|
||||
* @param class The main class to run.
|
||||
* @param arguments The user arguments to the main entrypoint.
|
||||
* @param jvmOptions The jvm options for the application.
|
||||
* @param environmentVariables Additional environment variables for the application.
|
||||
*/
|
||||
final class ScalaMainClass private (
|
||||
val `class`: String,
|
||||
val arguments: Vector[String],
|
||||
val jvmOptions: Vector[String]) extends Serializable {
|
||||
val jvmOptions: Vector[String],
|
||||
val environmentVariables: Vector[String]) extends Serializable {
|
||||
|
||||
|
||||
|
||||
override def equals(o: Any): Boolean = this.eq(o.asInstanceOf[AnyRef]) || (o match {
|
||||
case x: ScalaMainClass => (this.`class` == x.`class`) && (this.arguments == x.arguments) && (this.jvmOptions == x.jvmOptions)
|
||||
case x: ScalaMainClass => (this.`class` == x.`class`) && (this.arguments == x.arguments) && (this.jvmOptions == x.jvmOptions) && (this.environmentVariables == x.environmentVariables)
|
||||
case _ => false
|
||||
})
|
||||
override def hashCode: Int = {
|
||||
37 * (37 * (37 * (37 * (17 + "sbt.internal.bsp.ScalaMainClass".##) + `class`.##) + arguments.##) + jvmOptions.##)
|
||||
37 * (37 * (37 * (37 * (37 * (17 + "sbt.internal.bsp.ScalaMainClass".##) + `class`.##) + arguments.##) + jvmOptions.##) + environmentVariables.##)
|
||||
}
|
||||
override def toString: String = {
|
||||
"ScalaMainClass(" + `class` + ", " + arguments + ", " + jvmOptions + ")"
|
||||
"ScalaMainClass(" + `class` + ", " + arguments + ", " + jvmOptions + ", " + environmentVariables + ")"
|
||||
}
|
||||
private[this] def copy(`class`: String = `class`, arguments: Vector[String] = arguments, jvmOptions: Vector[String] = jvmOptions): ScalaMainClass = {
|
||||
new ScalaMainClass(`class`, arguments, jvmOptions)
|
||||
private[this] def copy(`class`: String = `class`, arguments: Vector[String] = arguments, jvmOptions: Vector[String] = jvmOptions, environmentVariables: Vector[String] = environmentVariables): ScalaMainClass = {
|
||||
new ScalaMainClass(`class`, arguments, jvmOptions, environmentVariables)
|
||||
}
|
||||
def withClass(`class`: String): ScalaMainClass = {
|
||||
copy(`class` = `class`)
|
||||
@@ -38,8 +40,11 @@ final class ScalaMainClass private (
|
||||
def withJvmOptions(jvmOptions: Vector[String]): ScalaMainClass = {
|
||||
copy(jvmOptions = jvmOptions)
|
||||
}
|
||||
def withEnvironmentVariables(environmentVariables: Vector[String]): ScalaMainClass = {
|
||||
copy(environmentVariables = environmentVariables)
|
||||
}
|
||||
}
|
||||
object ScalaMainClass {
|
||||
|
||||
def apply(`class`: String, arguments: Vector[String], jvmOptions: Vector[String]): ScalaMainClass = new ScalaMainClass(`class`, arguments, jvmOptions)
|
||||
def apply(`class`: String, arguments: Vector[String], jvmOptions: Vector[String], environmentVariables: Vector[String]): ScalaMainClass = new ScalaMainClass(`class`, arguments, jvmOptions, environmentVariables)
|
||||
}
|
||||
|
||||
+3
-1
@@ -14,8 +14,9 @@ implicit lazy val ScalaMainClassFormat: JsonFormat[sbt.internal.bsp.ScalaMainCla
|
||||
val `class` = unbuilder.readField[String]("class")
|
||||
val arguments = unbuilder.readField[Vector[String]]("arguments")
|
||||
val jvmOptions = unbuilder.readField[Vector[String]]("jvmOptions")
|
||||
val environmentVariables = unbuilder.readField[Vector[String]]("environmentVariables")
|
||||
unbuilder.endObject()
|
||||
sbt.internal.bsp.ScalaMainClass(`class`, arguments, jvmOptions)
|
||||
sbt.internal.bsp.ScalaMainClass(`class`, arguments, jvmOptions, environmentVariables)
|
||||
case None =>
|
||||
deserializationError("Expected JsObject but found None")
|
||||
}
|
||||
@@ -25,6 +26,7 @@ implicit lazy val ScalaMainClassFormat: JsonFormat[sbt.internal.bsp.ScalaMainCla
|
||||
builder.addField("class", obj.`class`)
|
||||
builder.addField("arguments", obj.arguments)
|
||||
builder.addField("jvmOptions", obj.jvmOptions)
|
||||
builder.addField("environmentVariables", obj.environmentVariables)
|
||||
builder.endObject()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -631,4 +631,7 @@ type ScalaMainClass {
|
||||
|
||||
## The jvm options for the application.
|
||||
jvmOptions: [String]
|
||||
|
||||
## Additional environment variables for the application.
|
||||
environmentVariables: [String]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user