Removing auto-credentials, because they fundamentally cannot work behind a password-gated artifact server.

This commit is contained in:
Pat Garrity 2024-03-17 21:33:41 -05:00
parent 862405422d
commit 56622729e2
Signed by: pfm
GPG key ID: 5CA5D21BAB7F3A76
2 changed files with 34 additions and 33 deletions

View file

@ -1,5 +1,7 @@
package gs;
import sbt._
object Gs {
/**
* Standard compiler options used by GS projects.
@ -81,4 +83,36 @@ object Gs {
val MavenUser: String = "GS_MAVEN_USER"
val MavenToken: String = "GS_MAVEN_TOKEN"
}
/**
* Prefers to load credentials from file, if a file is available. Otherwise
* mandates that the following environment variables exist:
*
* - `GS_MAVEN_USER`
* - `GS_MAVEN_TOKEN`
*
* @return The selected credentials for GS Maven.
*/
def selectCredentials(): Credentials =
if ((Path.userHome / ".sbt" / ".credentials").exists())
Credentials(Path.userHome / ".sbt" / ".credentials")
else
Credentials.apply(
realm =Gs.MavenRealm,
host = Gs.MavenHost,
userName = sys.env
.get(Gs.Environment.MavenUser)
.getOrElse(
throw new RuntimeException(
s"You must either provide ~/.sbt/.credentials or specify the ${Gs.Environment.MavenUser} environment variable."
)
),
passwd = sys.env
.get(Gs.Environment.MavenToken)
.getOrElse(
throw new RuntimeException(
s"You must either provide ~/.sbt/.credentials or specify the ${Gs.Environment.MavenToken} environment variable."
)
)
)
}

View file

@ -10,40 +10,7 @@ object GsPlugin extends AutoPlugin {
import autoImport._
/**
* Prefers to load credentials from file, if a file is available. Otherwise
* mandates that the following environment variables exist:
*
* - `GS_MAVEN_USER`
* - `GS_MAVEN_TOKEN`
*
* @return The selected credentials for GS Maven.
*/
def selectCredentials(): Credentials =
if ((Path.userHome / ".sbt" / ".credentials").exists())
Credentials(Path.userHome / ".sbt" / ".credentials")
else
Credentials.apply(
realm =Gs.MavenRealm,
host = Gs.MavenHost,
userName = sys.env
.get(Gs.Environment.MavenUser)
.getOrElse(
throw new RuntimeException(
s"You must either provide ~/.sbt/.credentials or specify the ${Gs.Environment.MavenUser} environment variable."
)
),
passwd = sys.env
.get(Gs.Environment.MavenToken)
.getOrElse(
throw new RuntimeException(
s"You must either provide ~/.sbt/.credentials or specify the ${Gs.Environment.MavenToken} environment variable."
)
)
)
override def projectSettings: Seq[Setting[_]] = Seq(
credentials += selectCredentials(),
publishMavenStyle := true,
Test / Keys.publishArtifact := false,
pomIncludeRepository := Function.const(false),