I am using the sbt revolver plugin to drive a vert.x scala project.
Currently I manually enter the following commands in sbt:
set mainClass in Revolver.reStart := Some("org.vertx.java.platform.impl.cli.Starter")
~re-start run scala:com.something.myClass
How could this be delegated to the build.sbt file, such that I can just run ~re-start in sbt, rather than those two commands every time?
It seems revolver has all the relevant configuration flexibility for that, but the sbt configuration language/conventions elude me and I failed to fiddle build.sbt to that effect.
You can add your settings to the build.sbt. It is rather simple, if you do set <whatever-here>, you can drop set and add it to the build.sbt directly.
For example, the build.sbt for your example would look like this.
build.sbt
Revolver.settings
mainClass in Revolver.reStart := Some("org.vertx.java.platform.impl.cli.Starter")
Revolver.reStartArgs := Seq("run", "scala:com.something.myClass")
The list of settings you can use is in the original link of yours, there are even some examples if you look down below.
Related
I'm working on an SBT project that has to be built with the options like:
-Xmx2G -Xss256M -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled
This means that every new developer has to read the readme and assign the options to SBT_OPTS in bash profile or put them in the sbtopts file. Similarly, this has to be configured on Jenkins and this applies to all the projects (so if someone wants to use -XX:+UseG1GC with other projects it becomes an issue). Is it possible to specify the required options in the build file itself? This seems logical to me, as the options are project-specific and without them, you cannot build the project.
Create a .sbtopts file at the root of the build with contents:
-J-Xmx2G
-J-Xss256M
-J-XX:+UseConcMarkSweepGC
-J-XX:+CMSClassUnloadingEnabled
I use SBT / Console as a prototyping tool and therefore don't want to start with a pre-defined build.sbt file.
What I want to do is to run the sbt tool and then modify the libraryDependencies setting. then run console and go and use my newly imported library. If I need something more. I can exit the console and import more stuff and then come back in the console.
is this possible? or should I always start with a predefined build.sbt file?
set libraryDependencies += group % art % version
I understand ammonite is good at this as well
Imagine I would like to define a sbt task which is the equivalent of
sbt runDev "-Dconfig.resource=dev.conf"
and then call it via
sbt runDev
runDev is custom run-task in that case. How would the part of my build.sbt look like? Ideally I would like to do something like
javaOptions in runDev += "config.resource=application-dev.conf"
I found a solution myself
fork in runDev := true
javaOptions in runDev ++= Seq("-Dconfig.resource=dev.conf")
The fork is important otherwise it wont start a new JVM with the corresponding java options!
I want to change the sbt.ivy.home java option in my build.sbt file. I tried:
javaOptions := Seq("-Dsbt.ivy.home=c:/ivy2/")
But it doesn't work.
It work well on the command line:
sbt update -Dsbt.ivy.home=c:/ivy/
For Ivy home, you can set it via ivyPaths setting.
I'm using sbt 0.10 to build a Scala project using just a build.sbt file instead of a full configuration.
Every time I start sbt it gives me the messages as follows:
[info] Set current project to default-ee699e (in build file:/Users/.../project/plugins/)
[info] Set current project to default-8febe7 (in build file:/Users/.../)
I did set the name and mainClass settings in the build.sbt file, so I don't know what I need to set to get the project names default-XXXX go away.
EDIT: the answer given below is correct in that this is cosmetic. If you switch to a full configuration of sbt, then it uses that project's name as opposed to default-XXXX however.
The message can be a bit misleading, it's not saying that you must "set the curent project", it's telling you what it's doing.
It sets the current project to the plugins folder, does it's stuff (compile, etc.), then sets the current project to your actual build folder and does it's thing once again.
You don't need to set anything else.