Ever wish Maven could run a specific command if any files in your project change? Some IDEs have their own features to do X if a file changes, but they usually don't take your full Maven project file into account. Problem finally solved with the Watcher Plugin for Maven. Add to your Maven project file and fire it up in a new shell. Maven will continuously and recursively watch any number of configured directories and then execute a series of goals if a file change is detected. Just like if you typed it on the command-line! We use it at Fizzed across a bunch of projects, but mainly our web projects -- where we want a full
compile run any time our Java code, resources, or templates change. Works especially well from a project parent to watch any of your sub modules too.
To use add the following to your POM:
<build> <plugins> ... <plugin> <groupId>com.fizzed</groupId> <artifactId>fizzed-watcher-maven-plugin</artifactId> <version>1.0.4</version> <configuration> <files> <param>src/main/java</param> <param>src/main/resources</param> </files> <goals> <param>clean</param> <param>compile</param> </goals> <profiles> <param>optional-profile-to-activate-while-running-goals</param> </profiles> </configuration> </plugin> ... </plugins> </build>
By default this maven plugin does NOT attach to a lifecycle -- since it is essentially a daemon that runs forever. Usually, you'll run this in a separate shell and run via: