I cannot fork my sbt process using sbt run &. When I do so, I return to bash console, and I get a PID, but soon, the process stops.
In my build.sbt I have added the line Keys.fork in run := true but that doesn't do anything.
What is that?
I don't believe you need to restrict to run. Try just
fork := true
Related
I am using xsbt-web-plugin v4.0.1. After starting the sbt console, the tomcat:start command works fine. However I don't know how to run tomcat:stop. When I press Ctrl-C, I exit out of console, but I think tomcat continues to run in background. When I press Ctrl-D, I see the message waiting for server to shutdown and then sbt exists. Either case, I am forced to start sbt console again.
I have added following 2 lines in build.sbt
fork in run := true
connectInput in run := true
and this line in my global.sbt
cancelable in Global := true
How can I start and stop container without exiting sbt?
After running tomcat:start, you can run tomcat:stop (or any other sbt command) at any time.
The tomcat:start command does not block further interaction with the sbt prompt. It can be misleading to see the output of the container mixed in with that of the sbt prompt.
The fork in run, connectInput in run, and cancelable in Global settings are not needed to be able to use tomcat:start and tomcat:stop.
I'm puzzled by sbt tool. I would like to define two Java options, one for sbt run target and another for sbt test target. These options require forking the VM, which I would not like to happen for other commands (such as compile, update).
How to define this in the build.sbt elegantly?
what's the role of the Compile thing? What about Test?
how to declare fork only once, so that it would apply to both sbt run and sbt test?
I've been using sbt for a few years, now. Read the documents. Something like this still escapes me. sigh
fork in run := true
javaOptions in (Compile,run) ++= Seq(
"-Dconfig.file=conf/debug.conf"
)
fork in test := true
javaOptions in (Test,test) ++= Seq(
"-Dconfig.file=conf/debug-test.conf"
)
Using sbt 0.13.8
Say you want to specify that you only want to fork() on sbt run and not on other executions of run (e.g., on sbt test:run) then you need to use the Configuration scope together with the task. That is:
fork in (Compile,run) := true
If you had the following:
fork in run := true
It will fork all run tasks, including test:run etc.
Now, if you had this:
fork := true
It will fork() all the fork-able task in all scopes.
Coming back to your questions, you can think of the (Compile, run) and (Test, run) etc. as instances of (Configuration,task) scope. You should use this construct when you want to narrow down the scope of a particular setting down to the task of a specific configuration: Compile, Run, Test, or any custom one you may have.
In your .sbt file I think the right thing to do is:
fork in (Compile,run) := true
javaOptions in (Compile,run) ++= Seq(
"-Dconfig.file=conf/debug.conf"
)
fork in (Test,test) := true
javaOptions in (Test,test) ++= Seq(
"-Dconfig.file=conf/debug-test.conf"
)
I have a custom sbt task myTask, which accepts list of arguments.
The task is running fine on the sbt console.
sbt_proj> mytask arg1
I want to run this task on the command line :
$ sbt myTask arg1
Unfortunately i can't get this working.
Any ideas ?
You need to quote it, ie:
$ sbt 'myTask arg1'
Otherwise it will interpret it as two commands, such as if you were trying to run sbt clean compile
Using Flyway 2.3 on Windows, same result from command prompt and within cygwin. Production env is Linux, but haven't been able to test there yet.
My SQL file has the line:
alter table person add ${new_col} text;
I added the following to my build.sbt, based on what I saw on the the flyway sbt doc page:
flywayPlaceholders := Map(
"new_col" -> "temp_name"
)
When I run
> sbt flywayMigrate
I get this:
com.googlecode.flyway.core.api.FlywayException: No value provided for placeholder expressions: ${new_col}. Check your configuration!
Under cygwin it does work if I specify the substitution on the command line:
> sbt flywayMigrate -Dflyway.placeholders.new_col=temp_name
Command line plaveholder substitution doesn't work in Windows command prompt, but I suspect that's a different issue as none of my -D options are respected there.
I'm new to both sbt and Flyway, so I'm hoping this is something simple, but I couldn't find anything helpful by googling. thanks in advance for any help
The flywayPlaceholders in build.sbt are currently by the commandline configuration.
This is a bug in Flyway.
I created a pull request.
Inspired by the examples on the SBT github page, I'm trying to redirect the stdout produced from a run in SBT's interactive mode to a file.
Here's my failed attempt:
> run #> file('/Users/dsg/temp/temp.txt') !
I've tried both with and without the ! at the end. I've tried both single and double quotes. Nothing works -- it just behaves as if the #> file(... is omitted, things only get printed to stdout, no file is created.
I'm not an SBT expert, but this doesn't seem to be the correct feature.
> run is interpreting everything after it as file arguments. #> seems to be part of the sbt library, for use inside of your project sbt files, not at their prompt.
Getting around this, I exit sbt, and use my external shell to do this:
$ sbt "run" > run_output.txt
Don't know how to do it from the sbt console, but from shell command line you can capture the sbt output via:
sbt "test" 2>&1 > test.log
This worked for me:
sbt | tee log.txt
You could try this.
sbt test >> "log.txt"