Ratpack works very smoothly with spring-loaded library. It is defined as dependency in build.gradle file. Spring-loaded enables runtime hot class reloading.
dependencies {
springloaded "org.springframework:springloaded:1.2.0.RELEASE"
}
But default configuration reloads only changes in Ratpack.groovy file.
There are two solutions for hot reloading classes from src/main folder.
In one terminal window run:
$ ./gradlew run
Once you save changes in source files in another terminal window run:
$ ./gradlew classes
This command compiles changes and then spring-loaded reloads them in memory.
Put the following dependencies to the build.gradle file:
buildscript {
repositories {
maven { url "http://oss.jfrog.org/artifactory/repo" }
jcenter()
}
dependencies {
classpath "io.ratpack:ratpack-gradle:0.9.8"
classpath 'com.bluepapa32:gradle-watch-plugin:0.1.3'
}
}
Apply plugin:
apply plugin: "watch"
Add new task definition (watch for changes in src/main/groovy):
watch {
groovy {
files fileTree(dir: "src/main/groovy", include: "**/*.groovy")
tasks "classes"
}
}
In one terminal window run command:
$ ./gradlew run
In another terminal window run one more command:
$ ./gradlew watchRun
One you save changes in source files watch command catches them, compiles classes and then spring-loaded library reloads them in memory.