Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sbt equivalent of gradle's JavaExec

Tags:

gradle

scala

sbt

Is there an equivalent of gradle's JavaExec task in sbt? Here's an example from the docs to understand what I'm looking for:

apply plugin: 'java'

task runApp(type: JavaExec) {
  classpath = sourceSets.main.runtimeClasspath

  main = 'package.Main'

  // arguments to pass to the application
  args 'appArg1'
}

I need to configure classpath, main and pass some args - as in this example.

like image 742
Opal Avatar asked Mar 26 '26 02:03

Opal


1 Answers

runner seems to be similar to gradle's JavaExec, for example

val runApp = taskKey[Unit]("sbt equivalent of gradle's JavaExec")
runApp := {
  (runner in Compile).value.run(
    mainClass = "example.Main",
    classpath = (fullClasspath in Runtime).value.files,
    options = Array("appArg1"),
    log = streams.value.log
  )
}
like image 124
Mario Galic Avatar answered Mar 27 '26 16:03

Mario Galic



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!