mirror of https://github.com/sbt/sbt.git
Load credentials from SBT_CREDENTIALS (#6724)
Load credentials from SBT_CREDENTIALS Prefer sys.env to System.getenv
This commit is contained in:
parent
64e05bdf68
commit
a448b1caab
|
|
@ -54,7 +54,7 @@ object Util {
|
|||
System.getProperty("os.name").toLowerCase(Locale.ENGLISH).contains("windows")
|
||||
|
||||
lazy val isCygwin: Boolean = {
|
||||
val os = Option(System.getenv("OSTYPE"))
|
||||
val os = sys.env.get("OSTYPE")
|
||||
os match {
|
||||
case Some(x) => x.toLowerCase(Locale.ENGLISH).contains("cygwin")
|
||||
case _ => false
|
||||
|
|
@ -64,7 +64,7 @@ object Util {
|
|||
lazy val isNonCygwinWindows: Boolean = isWindows && !isCygwin
|
||||
lazy val isCygwinWindows: Boolean = isWindows && isCygwin
|
||||
|
||||
lazy val isEmacs: Boolean = Option(System.getenv("INSIDE_EMACS")).isDefined
|
||||
lazy val isEmacs: Boolean = sys.env.contains("INSIDE_EMACS")
|
||||
|
||||
def nil[A]: List[A] = List.empty[A]
|
||||
def nilSeq[A]: Seq[A] = Seq.empty[A]
|
||||
|
|
|
|||
|
|
@ -308,7 +308,7 @@ object Terminal {
|
|||
}
|
||||
private[sbt] lazy val isAnsiSupported: Boolean = logFormatEnabled.getOrElse(useColorDefault)
|
||||
|
||||
private[this] val isDumb = "dumb" == System.getenv("TERM")
|
||||
private[this] val isDumb = Some("dumb") == sys.env.get("TERM")
|
||||
private[this] def isDumbTerminal = isDumb || System.getProperty("jline.terminal", "") == "none"
|
||||
private[this] val hasConsole = Option(java.lang.System.console).isDefined
|
||||
private[this] def useColorDefault: Boolean = {
|
||||
|
|
@ -736,22 +736,20 @@ object Terminal {
|
|||
val supershell: Boolean
|
||||
)
|
||||
private[sbt] val TERMINAL_PROPS = "SBT_TERMINAL_PROPS"
|
||||
private val props = System.getenv(TERMINAL_PROPS) match {
|
||||
case null => None
|
||||
case p =>
|
||||
p.split(",") match {
|
||||
case Array(width, height, ansi, color, supershell) =>
|
||||
Try(
|
||||
new Props(
|
||||
width.toInt,
|
||||
height.toInt,
|
||||
ansi.toBoolean,
|
||||
color.toBoolean,
|
||||
supershell.toBoolean
|
||||
)
|
||||
).toOption
|
||||
case _ => None
|
||||
}
|
||||
private val props = sys.env.get(TERMINAL_PROPS) flatMap { p =>
|
||||
p.split(",") match {
|
||||
case Array(width, height, ansi, color, supershell) =>
|
||||
Try(
|
||||
new Props(
|
||||
width.toInt,
|
||||
height.toInt,
|
||||
ansi.toBoolean,
|
||||
color.toBoolean,
|
||||
supershell.toBoolean
|
||||
)
|
||||
).toOption
|
||||
case _ => None
|
||||
}
|
||||
}
|
||||
private[sbt] def startedByRemoteClient = props.isDefined
|
||||
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ class NetworkClient(
|
|||
private val rebooting = new AtomicBoolean(false)
|
||||
private lazy val noTab = arguments.completionArguments.contains("--no-tab")
|
||||
private lazy val noStdErr = arguments.completionArguments.contains("--no-stderr") &&
|
||||
System.getenv("SBTC_AUTO_COMPLETE") == null
|
||||
!sys.env.contains("SBTC_AUTO_COMPLETE")
|
||||
|
||||
private def mkSocket(file: File): (Socket, Option[String]) = ClientSocket.socket(file, useJNI)
|
||||
|
||||
|
|
|
|||
|
|
@ -148,6 +148,7 @@ object Defaults extends BuildCommon {
|
|||
val m = (for (a <- cp; an <- a.metadata get Keys.analysis) yield (a.data, an)).toMap
|
||||
m.get _
|
||||
}
|
||||
|
||||
private[sbt] def globalDefaults(ss: Seq[Setting[_]]): Seq[Setting[_]] =
|
||||
Def.defaultSettings(inScope(GlobalScope)(ss))
|
||||
|
||||
|
|
@ -229,7 +230,7 @@ object Defaults extends BuildCommon {
|
|||
private[sbt] lazy val globalIvyCore: Seq[Setting[_]] =
|
||||
Seq(
|
||||
internalConfigurationMap :== Configurations.internalMap _,
|
||||
credentials :== Nil,
|
||||
credentials :== SysProp.sbtCredentialsEnv.toList,
|
||||
exportJars :== false,
|
||||
trackInternalDependencies :== TrackLevel.TrackAlways,
|
||||
exportToInternal :== TrackLevel.TrackAlways,
|
||||
|
|
|
|||
|
|
@ -15,8 +15,9 @@ import scala.util.control.NonFatal
|
|||
import scala.concurrent.duration._
|
||||
import sbt.internal.util.{ Terminal => ITerminal, Util }
|
||||
import sbt.internal.util.complete.SizeParser
|
||||
import sbt.nio.Keys._
|
||||
import sbt.io.syntax._
|
||||
import sbt.librarymanagement.ivy.{ Credentials, FileCredentials }
|
||||
import sbt.nio.Keys._
|
||||
|
||||
// See also BuildPaths.scala
|
||||
// See also LineReader.scala
|
||||
|
|
@ -216,4 +217,7 @@ object SysProp {
|
|||
.getOrElse(linuxCache)
|
||||
baseCache.getAbsoluteFile / "v1"
|
||||
}
|
||||
|
||||
val sbtCredentialsEnv: Option[Credentials] =
|
||||
sys.env.get("SBT_CREDENTIALS").map(raw => new FileCredentials(new File(raw)))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ object BuildServerConnection {
|
|||
// For those who use an old sbt script, the -Dsbt.script is not set
|
||||
// As a fallback we try to find the sbt script in $PATH
|
||||
val fileName = if (Properties.isWin) "sbt.bat" else "sbt"
|
||||
val envPath = Option(System.getenv("PATH")).getOrElse("")
|
||||
val envPath = sys.env.getOrElse("PATH", "")
|
||||
val allPaths = envPath.split(File.pathSeparator).map(Paths.get(_))
|
||||
allPaths
|
||||
.map(_.resolve(fileName))
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
object ForkTest {
|
||||
def main(args:Array[String]): Unit = {
|
||||
val name = Option(System.getenv("flag.name")) getOrElse("flag")
|
||||
val name = sys.env.getOrElse("flag.name", "flag")
|
||||
println("Name: " + name)
|
||||
val cwd = (new java.io.File(name)).getAbsoluteFile
|
||||
cwd.getParentFile.mkdirs()
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import org.scalatest.FlatSpec
|
||||
|
||||
class Test extends FlatSpec {
|
||||
val v = Option(System.getenv("tests.max.value")) getOrElse Int.MaxValue
|
||||
val v = sys.env.getOrElse("tests.max.value", Int.MaxValue)
|
||||
"A simple equation" should "hold" in {
|
||||
assert(Int.MaxValue == v)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue