Only warn on missing credential file

This commit is contained in:
Alexandre Archambault 2017-04-21 15:11:39 +02:00
parent dba6225ac1
commit f7020fd0ad
5 changed files with 33 additions and 6 deletions

View File

@ -457,12 +457,24 @@ object Tasks {
val useSbtCredentials = coursierUseSbtCredentials.value
val authenticationByHost =
if (useSbtCredentials) {
val cred = sbt.Keys.credentials.value.map(sbt.Credentials.toDirect)
cred.map { c =>
c.host -> Authentication(c.userName, c.passwd)
}.toMap
} else
if (useSbtCredentials)
sbt.Keys.credentials
.value
.flatMap {
case dc: sbt.DirectCredentials => List(dc)
case fc: sbt.FileCredentials =>
sbt.Credentials.loadCredentials(fc.path) match {
case Left(err) =>
log.warn(s"$err, ignoring it")
Nil
case Right(dc) => List(dc)
}
}
.map { c =>
c.host -> Authentication(c.userName, c.passwd)
}
.toMap
else
Map.empty[String, Authentication]
val authenticationByRepositoryId = coursierCredentials.value.mapValues(_.authentication)

View File

@ -0,0 +1,2 @@
scalaVersion := "2.11.8"
credentials += Credentials(file("nope/nope/nope/nope/nope"))

View File

@ -0,0 +1,11 @@
{
val pluginVersion = sys.props.getOrElse(
"plugin.version",
throw new RuntimeException(
"""|The system property 'plugin.version' is not defined.
|Specify this property using the scriptedLaunchOpts -D.""".stripMargin
)
)
addSbtPlugin("io.get-coursier" % "sbt-coursier" % pluginVersion)
}

View File

@ -0,0 +1 @@
object Main extends App

View File

@ -0,0 +1 @@
> update