问题
I'm using sbt 0.11.2 with xsbt-web-plugin 0.2.10 to build a Wicket (1.5.3) app. I'm using this version of Jetty:
"org.eclipse.jetty" % "jetty-webapp" % "8.0.1.v20110908" % "container",
So when I do
> container:start
my app starts up just fine.
But if I change some some of the html, the change does not kick in until I do
> copy-resources
and scala source code changes are not reflected until I do
> aux-compile(this one was hard to find out!!)
The problem is that I want this to be reflected immediately. I can do
> ~ copy-resources
or
> ~ aux-compile
separately so that one or the other will happen on save automatically.
The problem is that I don't see any obvious way to do both because I can't enter a 2nd tilde-prefixed command without pressing the enter key first to get the command prompt, and that cancels the running tilde command.
Thanks.
UPDATE:
I posted a minimal example of what I'm trying to do here:
https://github.com/jpswain/DummySbtScalaWicket.git
I fire this up by running sbt (0.11.2), and then doing
> container:start
So you will notice that if you do "~aux-compile" and change a log statement, or change the name that is read by the label, that will be updated on the fly. If you do "~copy-resources" and change "Hello" -> "Hola" you will see that changed on the fly. I'm trying to make it so that both will be done on save. "~container:reload /" seems to do nothing!
The answer from @Vasil Remeniuk seems like the right approach, except I haven't figure out exactly where to put the code to make it work. (I get a syntax error.) It would be great if someone would please verify if that code will work, or if I'm doing something wrong with my project that would prevent it from working?
Thanks!!
Jamie
FINAL UPDATE:
Thanks to the advice from @Vasil Remeniuk I got all this working. If anyone needs it for a quickstart to work with reloadable Jetty container, just download it at https://github.com/jpswain/DummySbtScalaWicket.git
and then from the directory run:
$ sbt
once sbt comes up, do this:
> container:start
> ~auxx
回答1:
You can create your own task that calls/depends on aux-compile
and copy-resources
import sbt._
import Keys._
import com.github.siasia._
import PluginKeys._
object SampleProject extends Build {
val sampleTask = TaskKey[Unit]("combined")
val setngs = Seq(
sampleTask <<= (copyResources in Compile, auxCompile in Compile) map {
(c, p) =>
}
)
val root = Project("root", file(".")) settings(setngs:_*)
override val projects = Seq(root)
}
,and call the new task continuously
~combined
回答2:
~
accepts any command as an argument, including a command list:
~ ;copy-resources;aux-compile
This will run copy-resources
and then aux-compile
on each trigger.
I prefer Vasil's solution in this case, however, because it only requires one evaluation of the task graph.
来源:https://stackoverflow.com/questions/8469503/sbt-0-11-2-how-to-combine-copy-resources-with-aux-compile