From 56622729e2d5813471c707c8baea439e6e2c5100 Mon Sep 17 00:00:00 2001 From: Pat Garrity Date: Sun, 17 Mar 2024 21:33:41 -0500 Subject: [PATCH] Removing auto-credentials, because they fundamentally cannot work behind a password-gated artifact server. --- src/main/scala/gs/Gs.scala | 34 ++++++++++++++++++++++++++++++++ src/main/scala/gs/GsPlugin.scala | 33 ------------------------------- 2 files changed, 34 insertions(+), 33 deletions(-) diff --git a/src/main/scala/gs/Gs.scala b/src/main/scala/gs/Gs.scala index d292f0f..8e76282 100644 --- a/src/main/scala/gs/Gs.scala +++ b/src/main/scala/gs/Gs.scala @@ -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." + ) + ) + ) } diff --git a/src/main/scala/gs/GsPlugin.scala b/src/main/scala/gs/GsPlugin.scala index 73a0014..c13cd0b 100644 --- a/src/main/scala/gs/GsPlugin.scala +++ b/src/main/scala/gs/GsPlugin.scala @@ -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),