/sbt-spring-loaded

An sbt plugin that allows your code to auto-update on re-compile using spring-loaded

Primary LanguageScalaGNU General Public License v3.0GPL-3.0

This plugin allows your to start processes using the spring-loaded Java class reloading agent, a FOSS alternative to JRebel (albiet a somewhat limited alternative).

This has been minimally tested against spray and akka classes YMMV.

This is the authors first "from-scratch" sbt plugin, so please be gentle.

Installation

sbt-spring-loaded requires SBT >= 0.13.5 (for AutoPlugin). Add the following to your project/plugins.sbt:

addSbtPlugin("me.browder" % "sbt-spring-loaded" % "0.2.0")

Usage

Since this requires forking the jvm and we don't want to wait for the application to recompile there are special commands to run your code:

reStart
start the mainClass of your project using spring-loaded, all arguments are passed though to it.
reStop
stop a previous invocation of reStart
reList
list what projects that have reStart JVMs running

Typical use case:

reStart
~compile

When you change your source you'll get new compiles which spring-loaded will pick up.

By default version 0.2.0 and greater now uses the Concurrent Mark Sweep GC so that class unloading can be used. Otherwise classes are kept forever which can lead to OOM: PermGen when doing class reloading, esp. on JDK < 8 which pulls from a fixed PermGen pool. JDK 8 introduces a new Mataspace which can use all of your memory (reducing the occurence of the issue) You can override this behavior by doing the following in sbt:

set noClassUnloading := true

Or you can add the following after the plugin load in plugins.sbt:

noClassUnloading := true

Special Thanks

  • SBT
  • spray/sbt-revolver for inspiration (the command lines are similar, hope you don't mind)
  • spring-loaded - really really under apprecieted (at least by those outside of the Grails community)

TODO

  • Determine if it's possible to parameterize the spring-loaded dependency.
  • Better logging
  • Testing

Copyright and License

Released under GPLv3.

Copyright (C) 2014 Kevin Browder.