aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-09-26 23:03:59 +0300
committerGravatar Vitaly Takmazov2018-09-26 23:03:59 +0300
commita6537a1349de14f9fb457d7abb14147c7a0795b2 (patch)
treed1d0c8e765ec4c91d8aea6a48fc45c484f0ec802
parent213972ed2bbe724941b39a134ed6fb79b778a700 (diff)
live reload for templates
-rw-r--r--juick-server/build.gradle7
-rw-r--r--juick-server/src/main/java/com/juick/server/configuration/WwwAppConfiguration.java8
2 files changed, 14 insertions, 1 deletions
diff --git a/juick-server/build.gradle b/juick-server/build.gradle
index 9b0a6496..54b39955 100644
--- a/juick-server/build.gradle
+++ b/juick-server/build.gradle
@@ -67,7 +67,8 @@ dependencies {
compile("org.springframework.boot:spring-boot-starter-security")
compile("org.springframework.boot:spring-boot-starter-web")
compile("org.springframework.boot:spring-boot-starter-websocket")
-
+ compile 'org.springframework.boot:spring-boot-devtools'
+
compileOnly 'io.springfox:springfox-core:2.9.2'
compile 'org.apache.commons:commons-email:1.5'
@@ -114,6 +115,10 @@ bootJar {
launchScript()
}
+bootRun {
+ sourceResources sourceSets.main
+}
+
bootRun.dependsOn ':generateDebugKey'
compileFrontend.dependsOn 'yarn'
processResources.dependsOn 'compileFrontend'
diff --git a/juick-server/src/main/java/com/juick/server/configuration/WwwAppConfiguration.java b/juick-server/src/main/java/com/juick/server/configuration/WwwAppConfiguration.java
index f829a999..9f68032d 100644
--- a/juick-server/src/main/java/com/juick/server/configuration/WwwAppConfiguration.java
+++ b/juick-server/src/main/java/com/juick/server/configuration/WwwAppConfiguration.java
@@ -93,8 +93,16 @@ public class WwwAppConfiguration implements WebMvcConfigurer {
@Bean
public PebbleEngine pebbleEngine() {
+ boolean devToolsArePresent = false;
+ try {
+ Class.forName("org.springframework.boot.devtools.livereload.Connection");
+ devToolsArePresent = true;
+ } catch (ClassNotFoundException e) {
+ // release mode
+ }
return new PebbleEngine.Builder()
.loader(this.templateLoader())
+ .cacheActive(!devToolsArePresent)
.extension(springExtension())
.extension(new FormatterExtension())
.strictVariables(true)