
com.dev9.mvnwatcher.event.FileChangeSubscriber Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of watcher-maven-plugin Show documentation
Show all versions of watcher-maven-plugin Show documentation
Maven Plugin to watch file system changes and automatically restart builds
The newest version!
package com.dev9.mvnwatcher.event;
import com.dev9.mvnwatcher.MvnRunner;
import com.google.common.eventbus.Subscribe;
import java.util.Objects;
public class FileChangeSubscriber implements PathEventSubscriber {
DirectoryEventWatcher dirWatcher;
MvnRunner runner;
public FileChangeSubscriber(DirectoryEventWatcher dirWatcher, MvnRunner runner) {
this.dirWatcher = Objects.requireNonNull(dirWatcher);
this.runner = Objects.requireNonNull(runner);
}
@Subscribe
@Override
public void handlePathEvents(PathEventContext pathEventContext) {
for (PathEvent evt : pathEventContext.getEvents()) {
if (evt.getEventTarget().getFileName().toString().indexOf(".") == 0) {
System.out.println("Ignoring change to path entry with a .");
} else {
System.out.println("Noticed " + evt.getType().name() + " to " + evt.getEventTarget().getFileName());
runner.changeEvent();
}
//TODO add newly created directories to monitoring
//TODO remove deleted directories from monitoring
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy