Listen to Maven Build Events
I need to execute taks after a module / project is built with the Maven plugin. I could not find a listener that would inform me about this.
Are there listeners in Maven Plugin that can be used?
Are there IntelliJ listeners that can be used?
Thanks - Andy Schaefer
Please sign in to leave a comment.
Use org.jetbrains.idea.maven.importing.MavenImporter extensionPoint.
You can do the following:
1. add your MavenImporter extention, e.g.
2. implement org.jetbrains.idea.maven.importing.MavenImporter#process method
3. and add your task as an entry to List<MavenProjectsProcessorTask> postTasks parameter of the process method
Thanks for the reply. I did the follwoing:
1. Create the Maven Importer and define it in the plugin.xml:
Oops, I'm sorry, I thaught you need to hook after creation/reimporting of the IDEA project/modules by maven plugin.
Do I understand you correctly, that you want to run your task after each invocation of maven run configuration with "install" goal defined?
If yes, there is no such an API in the maven plugin.
Yes, that was the idea.
But what I need is to know when an Artifact (JAR file) has changed to display the change in my plugin. I guess I could accmplish the same thing with a VirtualFileListener to see if the artifact has changed.
Thanks for your help - Andy
By default, all files under excluded directory are not included in VFS, and maven output 'target' directory will be excluded for most of maven projects.
You can try to add maven project artifact directory to VFS and use VirtualFileListener but it can be not so easy, since the directory might not exist yet and can be created by external tool like maven CLI invocation.
Also if you add the whole 'target' directory to VFS it may slow down the performance.
I just did that and it works with excluded target (build directory) folder under IntelliJ 14 CE.
Thanks for your help - Andy