This is a fork of https://github.com/Gekkio/sbt-jrebel-plugin to add SBT 1.x support since there is no plans for original plugin to get it (see more Gekkio#7)
sbt-jrebel-plugin is a plugin for Simple Build Tool v1 that generates configuration files (rebel.xml) for JRebel. A rebel.xml is not always required but is recommended because if you don't have one, JRebel cannot understand the layout of your project and might fail to reload changes. You also cannot reload changes from separate projects.
Supported SBT versions: 1.X For older sbt versions please use the original plugin: https://github.com/Gekkio/sbt-jrebel-plugin
- Generates rebel.xml, so it's similar to javarebel-maven-plugin in the Maven world
- Cross-project change reloading
Default behaviour
- Disables itself if SBT isn't run with JRebel agent enabled
- Writes rebel.xml as a managed resource which is automatically added to classpath and artifacts
You should always disable sbt-jrebel-plugin when publishing artifacts somewhere else than locally. Otherwise your artifacts will include rebel.xml files
Make sure you run sbt with JRebel agent enabled
Compile yourself or download pre-built sbt-jrebel-plugin_2.12-1.0.0.jar jar. Then save it locally under you project lib directory [project]/lib
which is the standard default location for unmanaged dependencies.
Add the plugin declaration to project/plugins.sbt:
addSbtPlugin("fi.jamonkko.sbtplugins" % "sbt-jrebel-plugin_2.12" % "1.0.0" from s"file:///${file("lib").getCanonicalPath}/sbt-jrebel-plugin_2.12-1.0.0.jar")
Then include the plugin settings in your project definition:
seq(JRebelPlugin.jrebelSettings: _*)
If you are using xsbt-web-plugin and want to reload web resources, also add this:
xsbt-web-plugin >= 2.0:
jrebelWebLinks += (sourceDirectory in Compile).value / "webapp"
Available settings are:
jrebelClasspath, jrebelEnabled, jrebelRebelXml, jrebelWebLinks
Project definition:
jrebelEnabled := false
or in SBT console:
set jrebelEnabled := false
Project definition:
jrebelEnabled := true
or in SBT console:
set jrebelEnabled := true
Let's say you have two projects, MyLib which is a library project and MyWebApp which is a webapp. These two are completely separate and differently versioned projects. If you have sbt-jrebel-plugin enabled for both projects, you can make changes in MyLib while developing MyWebApp and have them reloaded instantly.
- Deploy MyLib with
sbt publish-local
. The package includes a rebel.xml file that contains the absolute paths to your MyLib project directories. - Update MyWebApp dependencies with
sbt update
. MyWebApp now uses the MyLib package that has a rebel.xml. - Run MyWebApp and enable continuous webapp compilation (for example I use
sbt jetty-run "~ prepare-webapp"
) - In a separate terminal, start continuous compilation for MyLib (for example,
sbt ~ compile
). - Change a class in MyLib
- Notice that the change is visible in MyWebApp (if the change is reloadable using JRebel). Voilá!
Do not share rebel.xml files because by default they contain absolute paths which are computer-specific!