@@ -18,13 +18,18 @@ object CodeArtifactPlugin extends AutoPlugin {
18
18
19
19
def buildPublishSettings : Seq [Setting [_]] = Seq (
20
20
ThisBuild / codeArtifactUrl := " " ,
21
- ThisBuild / codeArtifactResolvers := Nil ,
22
- codeArtifactRepo := CodeArtifactRepo .fromUrl(codeArtifactUrl.value),
23
- codeArtifactToken := getCodeArtifactAuthToken.value
21
+ ThisBuild / codeArtifactResolvers := Nil
24
22
)
25
23
26
24
def codeArtifactSettings : Seq [Setting [_]] = Seq (
27
25
codeArtifactPublish := dynamicallyPublish.value,
26
+ codeArtifactRepo := CodeArtifactRepo .fromUrl(codeArtifactUrl.value),
27
+ codeArtifactToken := sys.env
28
+ .get(" CODEARTIFACT_AUTH_TOKEN" )
29
+ .orElse(
30
+ Credentials .loadCredentials(Path .userHome / " .sbt" / " credentials" ).toOption.map(_.passwd)
31
+ )
32
+ .orElse(CodeArtifact .getAuthToken(codeArtifactRepo.value)),
28
33
codeArtifactConnectTimeout := CodeArtifact .Defaults .CONNECT_TIMEOUT ,
29
34
codeArtifactReadTimeout := CodeArtifact .Defaults .READ_TIMEOUT ,
30
35
codeArtifactPackage := CodeArtifactPackage (
@@ -37,7 +42,10 @@ object CodeArtifactPlugin extends AutoPlugin {
37
42
isScalaProject = crossPaths.value
38
43
),
39
44
credentials ++= {
40
- val token = codeArtifactToken.value.getOrElse(" " )
45
+ val token = codeArtifactToken.value.getOrElse {
46
+ streams.value.log.warn(" Unable to get AWS CodeArtifact auth token." )
47
+ " "
48
+ }
41
49
val repos = codeArtifactRepo.value +: codeArtifactResolvers.value
42
50
.map(CodeArtifactRepo .fromUrl)
43
51
@@ -51,22 +59,6 @@ object CodeArtifactPlugin extends AutoPlugin {
51
59
.map(_.resolver)
52
60
)
53
61
54
- def getCodeArtifactAuthToken : Def .Initialize [Task [Option [String ]]] = Def .task {
55
- sys.env
56
- .get(" CODEARTIFACT_AUTH_TOKEN" )
57
- .orElse(
58
- Credentials
59
- .loadCredentials(Path .userHome / " .sbt" / " credentials" )
60
- .toOption
61
- .map(_.passwd)
62
- )
63
- .orElse {
64
- CodeArtifact .getAuthToken(codeArtifactRepo.value)
65
- streams.value.log.warn(" Unable to get AWS CodeArtifact auth token." )
66
- None
67
- }
68
- }
69
-
70
62
// Uses taskDyn because it can return one of two potential tasks
71
63
// as its result, each with their own dependencies.
72
64
// See: https://www.scala-sbt.org/1.x/docs/Howto-Dynamic-Task.html
0 commit comments