@@ -15,6 +15,7 @@ import scala.util.Failure
15
15
import scala .util .Success
16
16
import scala .util .Try
17
17
18
+ import org .scalafmt .interfaces .RepositoryCredential
18
19
import org .scalafmt .interfaces .Scalafmt
19
20
import org .scalafmt .sysops .AbsoluteFile
20
21
import org .scalafmt .sysops .FileOps
@@ -141,6 +142,7 @@ object ScalafmtPlugin extends AutoPlugin {
141
142
taskStreams : TaskStreams ,
142
143
cacheStoreFactory : CacheStoreFactory ,
143
144
resolvers : Seq [Resolver ],
145
+ credentials : Seq [Credentials ],
144
146
currentProject : ResolvedProject ,
145
147
filterMode : String ,
146
148
errorHandling : ErrorHandling
@@ -156,13 +158,24 @@ object ScalafmtPlugin extends AutoPlugin {
156
158
val repositories = resolvers.collect { case r : MavenRepository =>
157
159
r.root
158
160
}
161
+ val repoCredentials = credentials.map { x =>
162
+ val cred = Credentials .toDirect(x)
163
+ new RepositoryCredential (cred.host, cred.userName, cred.passwd)
164
+ }
165
+
159
166
log.debug(
160
- s " Adding repositories ${repositories .mkString(" [" , " ," , " ]" )} "
167
+ repositories.mkString(" Adding repositories [" , " ," , " ]" )
161
168
)
169
+ log.debug {
170
+ val info = repoCredentials.map(x => s " ${x.username}@ ${x.host}" )
171
+ info.mkString(" Adding credentials [" , " ," , " ]" )
172
+ }
173
+
162
174
val scalafmtSession =
163
175
globalInstance
164
176
.withReporter(reporter)
165
177
.withMavenRepositories(repositories : _* )
178
+ .withRepositoryCredentials(repoCredentials : _* )
166
179
.createSession(config.toAbsolutePath)
167
180
if (scalafmtSession == null )
168
181
throw messageException(
@@ -465,6 +478,7 @@ object ScalafmtPlugin extends AutoPlugin {
465
478
streams.value,
466
479
(scalafmt / streams).value.cacheStoreFactory,
467
480
fullResolvers.value,
481
+ credentials.value,
468
482
thisProject.value,
469
483
scalafmtFilter.value,
470
484
new ErrorHandling (
@@ -511,6 +525,7 @@ object ScalafmtPlugin extends AutoPlugin {
511
525
streams.value,
512
526
(scalafmt / streams).value.cacheStoreFactory,
513
527
fullResolvers.value,
528
+ credentials.value,
514
529
thisProject.value,
515
530
" " ,
516
531
new ErrorHandling (
0 commit comments