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
Allow the sbt launcher to be called programmatcially without running into an exit
call
#7540
Comments
Probably coming from https://github.com/sbt/launcher/blob/1.x/launcher-implementation/src/main/scala/xsbt/boot/Boot.scala. Would a system property like |
For my use-case, yes. Though I believe that introducing conditional code for this could be more complex and introduce pitfalls (like users setting that system property despite using SBT via the CLI) compared to just doing a refactoring that introduces a
The Jar's main entry point would still be |
I don't know if the original scope of sbt launcher was to be a generic launcher, but given that almost no one else but sbt uses it I'd suggest looking into Couriser app as a launcher, or drive Coursier programmatically instead. Here's launcher code for Giter8 for example https://github.com/foundweekends/giter8/blob/develop/launcher/src/main/scala/LauncherMain.scala that resolves artifacts from Maven repo and calls |
Hmm, I'm starting to get confused about launcher-related artifacts now... what's the difference between |
https://github.com/sbt/launcher hosts launcher-interface and launcher. launcher-interface is the Java interface that exposes an API to the application to be launched, whereas |
Thanks. And where does Coursier now come into play? IIUC Coursier is "just" a dependency resolver, but not a launcher. So maybe Anyway, what I'm looking for is a way to programmatically bootstrap the SBT version configured in a project, just like the launcher does, and to run commands like |
To some extent that's what CI process like GitHub Actions and Jenkins do basically by creating files and shelling out to an external process. So think that would be probably the easiest regardless of the programming language you're currently on. You can use |
Right, but the whole point was to take advantage of SBT being implemented for the JVM, just as my application, and to call it directly via some API to avoid the dependency on an external CLI tool that I would need to bundle with my application... |
In addition to |
Agreed, that's why all I was asking for was to be able to basically call the CLI programmatically via Maven artifacts without running into the |
I'd like to call the sbt launcher programmatically from a Kotlin/JVM application in order to analyze sbt projects. For that, I'm using the
org.scala-sbt:sbt-launch:1.9.9
artifact from Maven Central, and callxsbt.boot.main()
programmatically with arguments I'd usually pass via command line.This basically does what I want, but afterwards brings down my JVM-based host application, as somewhere as part of
xsbt.boot.main()
theexit()
function seems to be called.I'm no Scala guy, but it seems to me as if some rather simple refactoring could provide a programmatic entry point that avoid the
exit()
call (and maybe also takes an array of arguments rather than a CLI-like argument string).The text was updated successfully, but these errors were encountered: