-
Notifications
You must be signed in to change notification settings - Fork 143
Support links in using file directive (implements #1328) #3681
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: Michał Pawlik <[email protected]> Co-authored-by: tgodzik <[email protected]>
|
@majk-p @tgodzik It works! Indeed, dependencies are resolved recursively already.
|
Note: need to fix formatting & regenerate reference docs for the CI to pass. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's fine to skip git+ssh
IMO, we don't support that anywhere else, either.
The solution looks good so far, just need to address the TODOs and add tests
As for tests, maybe can reuse stuff from scala.cli.integration.RunGistTestDefinitions
.
// TODO: reuse existing one? e.g. scala.cli.commands.shared.SharedOptions.coursierCache | ||
lazy val fileCache: FileCache[coursier.util.Task] = FileCache() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, I think it's accurate that SharedOptions.coursierCache
should be used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Gedochao but scala.cli.commands.shared.SharedOptions.coursierCache
is in cli
module, while we're in build
here - so that definition is inaccessible (build doesn't depend on cli)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's why we haven't picked it up and left a todo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...well, yes, but cli
depends on build
.
so what I mean here is that the way to go would be to pass it all the way from cli
to CrossSources
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you just leave a TODO, it's very likely to get forgotten.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you don't have time to fix it, please at least create a ticket for the follow-up and link it back in the code.
private def downloadFile(pUri: Positioned[java.net.URI]) = | ||
import scala.build.options.ScalaVersionUtil.fileWithTtl0 | ||
val artifact = Artifact(pUri.value.toString).withChanging(true) | ||
fileCache.fileWithTtl0(artifact) | ||
.left | ||
.map(err => | ||
new MalformedDirectiveError(err.describe, pUri.positions) | ||
) // TODO: better error type | ||
.map(f => os.read.bytes(os.Path(f, Os.pwd))).map(content => | ||
Seq(Virtual(pUri.value.toString, content)) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is very similar to SharedOptions.downloadInputs
... I wonder if the function itself could be passed all the way here, rather than the cache
@@ -126,6 +126,8 @@ Manually add sources to the project. Does not support chaining, sources are adde | |||
#### Examples | |||
`//> using file utils.scala` | |||
|
|||
`//> using file https://raw.githubusercontent.com/softwaremill/sttp/refs/heads/master/examples/src/main/scala/sttp/client4/examples/json/GetAndParseJsonCatsEffectCirce.scala` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Gedochao I think it would be nice to reference a file within scala-cli
repo itself
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean... dunno if it matters, as long as the example is useful, to be honest. 🤷
Scala Tooling Spree 15.05
see #1328