Skip to content
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

Make it even easier to add library dependencies? #3

Closed
lrytz opened this issue Jul 3, 2019 · 4 comments
Closed

Make it even easier to add library dependencies? #3

lrytz opened this issue Jul 3, 2019 · 4 comments

Comments

@lrytz
Copy link
Collaborator

lrytz commented Jul 3, 2019

This works:

~/scala/scala-runners/scala -cp $(coursier fetch -p com.chuusai:shapeless_2.13:2.3.3)

But it would be nicer with less boilerplate, something like scala -dep com.chuusai:shapeless. We know the binary version, coursier finds (right?) the latest dependency version.

Also, doing everything in one invocation of coursier would make it faster.

@dwijnand
Copy link
Owner

dwijnand commented Jul 3, 2019

In the shell script wrapper (that is this project) we don't exactly have the binary version. With the -212, etc flags we do. We'd have to switch from latest.stable to 2.13+ as the default in order to have a default binary version that matches. But what do we do with --scala-version 2.13.0-RC? Use 2.13 or the whole string? What about 2.13.0-bin- or 2.14.0-pre-?

And still that wouldn't solve the number of invocations of coursier. Because coursier launch wants to resolve scala-compiler and its transitive dependencies to run the repl main. Separately the repl main can take a classpath of dependencies..

So it doesn't really fit into coursier's CLI APIs. Perhaps the solution is a Graal native built coursier, called twice. Or perhaps this project should become a Scala project and switch from Coursier's CLI API to its library API.

@dwijnand
Copy link
Owner

dwijnand commented Jul 6, 2019

This is the alternative that we should the Graal native built solution to:

  • Coursier's CLI API: https://get-coursier.io/docs/api.html
  • overlay the command-line flags (like sbt-extras) to pull out scala-runner specific options, like --dep that runs Coursier to get dependencies that then feed into the classpath of the scala app (e.g. scalac, the scala repl. etc)
  • then sbt publishLocal and coursier bootstrap from ~/.ivy2/local in the homebrew formula

@lrytz
Copy link
Collaborator Author

lrytz commented May 4, 2020

Given https://twitter.com/alxarchambault/status/1256195610031591424, this works:

➜ ~/Applications/bin/scala-runners/scala -Ccom.lihaoyi::fastparse:2.2.2
Welcome to Scala 2.13.2 (Java HotSpot(TM) 64-Bit GraalVM EE 19.2.1, Java 1.8.0_231).
Type in expressions for evaluation. Or try :help.

scala> import fastparse._, NoWhitespace._
import fastparse._
import NoWhitespace._

So we can close this, it's a matter of documentation.

@lrytz lrytz closed this as completed May 4, 2020
dwijnand added a commit that referenced this issue May 4, 2020
@dwijnand
Copy link
Owner

dwijnand commented May 4, 2020

f339bba

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants