Build a jar file with Scala-Metals on VSCode

Viewed 1056

I'm attempting to develop for Scala and Spark using VSCode and the metals extension. My setup is using a dev container following the instructions (here). I now have my code running and I need to build a jar file to deploy to Spark. Is there a way to do this within the metals extension?

I have read about using sbt-assembly to build a fat jar but I'm unsure of how to integrate this with my setup. Any help would be greatly appreciated.

Edit

To be more clear, the metals VSCode extension uses bloop or sbt-bsp as the build server and I have configured it to use the sbt server. My question is if and how I can get the sbt-assembly extension integrated with it.

2 Answers

sbt package after sbt compile should generate the result you want.

You can find more about generating the JAR here and then running the JAR here.

I found the answers to my question, thank you to everyone for your help.

  • Metals extension for VSCode does not provide any way to run sbt tasks that are not already exposed in the build commands window.
  • I was able to run sbt in the terminal window of VSCode whith Metals running, as long as Metals is configured to use bloop instead of sbt. If Metals is configured to use sbt then the sbt server is already running and I was unable to create a new instance or get a reference to the existing instance.
Related