Alternative fix for https://github.com/polynote/polynote/issues/1009#1019
Alternative fix for https://github.com/polynote/polynote/issues/1009#1019jelmerk wants to merge 1 commit intopolynote:masterfrom
Conversation
|
I like this solution! It uses the local JAR for dependencies that come from a credentialed host; otherwise uses the direct URL. |
jeremyrsmith
left a comment
There was a problem hiding this comment.
A couple of nitpicks; let me know if you need help with them! Thanks for coming up with this alternate solution; I like how minimal it is!
| val passwordProtectedHosts = directCredentials.map(_.host).toSet | ||
|
|
||
| val jars = deps.map { case (url, file) => | ||
| if (passwordProtectedHosts.contains(URI.create(url).getHost)) file.getAbsolutePath |
There was a problem hiding this comment.
URI.create could throw if the URI string isn't correctly formatted, so that should be inside an IO. Also, file.getAbsolutePath will do blocking IO, so it should be inside effectBlocking.
|
|
||
| private def loadCredentials(credentials: Credentials): URIO[Logging, List[DirectCredentials]] = credentials.coursier match { | ||
| case Some(Credentials.Coursier(path)) => | ||
| Task(CoursierCredentials(new File(path), optional = false).get().toList) |
There was a problem hiding this comment.
Credentials#get() from coursier does blocking IO, so it should be in effectBlocking() rather than Task() (so this would have to return URIO[Blocking with Logging, List[DirectCredentials] – I'd just make it URIO[BaseEnv, List[DirectCredentials] which includes both of those)
See discussion in : #1011