/** * Creates a new {@link Watcher}. * * @param root the root directory * @param includes the list of include patterns, should not be {@code null} or empty * @param deploy the function called when deployment is required * @param undeploy the function called when un-deployment is required * @param onRedeployCommand an optional command executed after the un-deployment and before the deployment * @param gracePeriod the amount of time in milliseconds to wait between two redeploy even * if there are changes * @param scanPeriod the time in millisecond between 2 file system scans */ public Watcher(File root, List<String> includes, Handler<Handler<Void>> deploy, Handler<Handler<Void>> undeploy, String onRedeployCommand, long gracePeriod, long scanPeriod) { this.gracePeriod = gracePeriod; this.includes = sanitizeIncludePatterns(includes); this.roots = extractRoots(root, this.includes); this.cwd = root; LOGGER.info("Watched paths: " + this.roots); this.deploy = deploy; this.undeploy = undeploy; this.cmd = onRedeployCommand; this.scanPeriod = scanPeriod; addFilesToWatchedList(roots); }
List<String> patterns = new ArrayList<>(); patterns.add("src/main/java/**/*.java"); List<File> results = Watcher.extractRoots(root, patterns); assertThat(results).hasSize(1); assertThat(results.get(0).getAbsolutePath()).contains(root.getAbsolutePath()); results = Watcher.extractRoots(root, patterns); assertThat(results).hasSize(1); assertThat(results.get(0).getAbsolutePath()).contains(root.getParentFile().getAbsolutePath()); results = Watcher.extractRoots(root, patterns); assertThat(results).hasSize(1); assertThat(results.get(0).getAbsolutePath()).contains(root.getAbsolutePath()); results = Watcher.extractRoots(root, patterns); assertThat(results).hasSize(1); assertThat(results.get(0).getAbsolutePath()).contains(root.getParentFile().getAbsolutePath()); results = Watcher.extractRoots(root, patterns); assertThat(results).hasSize(1); assertThat(results.get(0).getAbsolutePath()).contains(root.getParentFile().getAbsolutePath()); results = Watcher.extractRoots(root, patterns); assertThat(results).hasSize(1); assertThat(results.get(0).getAbsolutePath()).contains(root.getParentFile().getAbsolutePath());
/** * Creates a new {@link Watcher}. * * @param root the root directory * @param includes the list of include patterns, should not be {@code null} or empty * @param deploy the function called when deployment is required * @param undeploy the function called when un-deployment is required * @param onRedeployCommand an optional command executed after the un-deployment and before the deployment * @param gracePeriod the amount of time in milliseconds to wait between two redeploy even * if there are changes * @param scanPeriod the time in millisecond between 2 file system scans */ public Watcher(File root, List<String> includes, Handler<Handler<Void>> deploy, Handler<Handler<Void>> undeploy, String onRedeployCommand, long gracePeriod, long scanPeriod) { this.gracePeriod = gracePeriod; this.includes = sanitizeIncludePatterns(includes); this.roots = extractRoots(root, this.includes); this.cwd = root; LOGGER.info("Watched paths: " + this.roots); this.deploy = deploy; this.undeploy = undeploy; this.cmd = onRedeployCommand; this.scanPeriod = scanPeriod; addFilesToWatchedList(roots); }
List<String> patterns = new ArrayList<>(); patterns.add("src/main/java/**/*.java"); List<File> results = Watcher.extractRoots(root, patterns); assertThat(results).hasSize(1); assertThat(results.get(0).getAbsolutePath()).contains(root.getAbsolutePath()); results = Watcher.extractRoots(root, patterns); assertThat(results).hasSize(1); assertThat(results.get(0).getAbsolutePath()).contains(root.getParentFile().getAbsolutePath()); results = Watcher.extractRoots(root, patterns); assertThat(results).hasSize(1); assertThat(results.get(0).getAbsolutePath()).contains(root.getAbsolutePath()); results = Watcher.extractRoots(root, patterns); assertThat(results).hasSize(1); assertThat(results.get(0).getAbsolutePath()).contains(root.getParentFile().getAbsolutePath()); results = Watcher.extractRoots(root, patterns); assertThat(results).hasSize(1); assertThat(results.get(0).getAbsolutePath()).contains(root.getParentFile().getAbsolutePath()); results = Watcher.extractRoots(root, patterns); assertThat(results).hasSize(1); assertThat(results.get(0).getAbsolutePath()).contains(root.getParentFile().getAbsolutePath());