Skip to content
This repository has been archived by the owner on Jun 24, 2024. It is now read-only.

Add fallback to using SBT credentials file #21

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ import sbt.Keys._
import sbt.internal.util.ManagedLogger

object CodeArtifactPlugin extends AutoPlugin {

import CodeArtifactKeys._
import InternalCodeArtifactKeys._

override def requires = sbt.plugins.JvmPlugin

override def trigger = allRequirements

override def buildSettings: Seq[Setting[_]] = buildPublishSettings

override def projectSettings: Seq[Setting[_]] = codeArtifactSettings

object autoImport extends CodeArtifactKeys
Expand All @@ -25,8 +28,10 @@ object CodeArtifactPlugin extends AutoPlugin {
codeArtifactPublish := dynamicallyPublish.value,
codeArtifactRepo := CodeArtifactRepo.fromUrl(codeArtifactUrl.value),
codeArtifactToken := sys.env
.get(
"CODEARTIFACT_AUTH_TOKEN")
.orElse(Credentials.loadCredentials(Path.userHome / ".sbt" / "credentials").toOption.map(_.passwd))
.getOrElse(
"CODEARTIFACT_AUTH_TOKEN",
CodeArtifact.getAuthToken(codeArtifactRepo.value)
),
codeArtifactConnectTimeout := CodeArtifact.Defaults.CONNECT_TIMEOUT,
Expand Down Expand Up @@ -106,9 +111,9 @@ object CodeArtifactPlugin extends AutoPlugin {
}

private def reportPublishResults(
publishResults: Seq[requests.Response],
logger: ManagedLogger
) = {
publishResults: Seq[requests.Response],
logger: ManagedLogger
) = {
if (publishResults.forall(_.is2xx)) {
logger.info(s"Successfully published to AWS Codeartifact")
} else {
Expand Down