LiveReload does not work with Gradle Project fix
@@ -328,12 +328,6 @@ public class LiveReload implements Module {
private List<Object[]> paths = new ArrayList<>();
- /**
- * Creates a new {@link LiveReload} module.
- */
- public LiveReload() {
- }
-
/**
* Add the given path to the watcher.
*
@@ -415,7 +409,8 @@ public class LiveReload implements Module {
}).consumes(MediaType.json).produces(MediaType.json);
if (paths.isEmpty()) {
- register(Paths.get("public"),
+ Path basedir = Paths.get(System.getProperty("user.dir"));
+ register(basedir.resolve("public"),
"**/*.css",
"**/*.scss",
"**/*.sass",
@@ -424,16 +419,17 @@ public class LiveReload implements Module {
"**/*.js",
"**/*.coffee",
"**/*.ts");
- register(Paths.get("target"),
+ register(basedir.resolve("target"),
"**/*.class",
"**/*.conf",
"**/*.properties");
- register(Paths.get("build"),
+ register(basedir.resolve("build"),
"**/*.class",
"**/*.conf",
"**/*.properties");
}
+ if (paths.size() > 0) {
FileWatcher watcher = new FileWatcher();
paths.forEach(it -> watcher.register((Path) it[0], (kind, path) -> {
Path relative = relative(paths, path.toAbsolutePath());
@@ -443,7 +439,7 @@ public class LiveReload implements Module {
css.test(relative));
for (WebSocket ws : broadcast) {
try {
- log.info("sending: {}", reload);
+ log.debug("sending: {}", reload);
ws.send(reload);
} catch (Exception x) {
log.debug("execution of {} resulted in exception", reload, x);
@@ -451,6 +447,9 @@ public class LiveReload implements Module {
}
}, options -> ((List<String>) it[1]).forEach(options::includes)));
watcher.configure(env, conf, binder);
+ } else {
+ log.warn("File watcher is off");
+ }
}
}
