TomEE maven plugin is pretty powerful since it can deploy the application of the current pom, deploy other applications, add librairies to the container, create a zip of the server and attach it to the build etc…but in development reloading of application is pretty nice.
This feature was added this week on trunk.
Here how to use it.
First the tomee-maven-plugin allows to observe file system to synchronize it with the deployed application.
To do it simply add a synchronization block. This block accepts the following configuration:
- resourcesDir (default src/main/webapp): where to take resources
- binariesDir (default target/classes): where to take binaries
- targetBinariesDir (default your-webapp/WEB-INF/classes): where to put binaries
- targetResourcesDir (default your-webapp/): where to put resources
- updateInterval (default 5s)
- extensions (default: .html, .css, .js, .xhtml)
- regex (default null, if not null used to match files to synchronize)
Then a new parameter was added: reloadOnUpdate (a boolean for now).
The idea is to set this boolean to true and to add to extensions .class. Doing it, the tomee maven plugin will synchronize all compiled sources of the project and then reload (undeploy/deploy) the application.
With such a configuration you can pretty quickly use F5 after a source update to see the updates without stopping/starting TomEE.
Note: think to force the compiler to push new compiled sources in target/classes (or use mvn compile ;)).
Here a sample configuration:
<plugin> <groupId>org.apache.openejb.maven</groupId> <artifactId>tomee-maven-plugin</artifactId> <version>1.0.1-SNAPSHOT</version> <configuration> <synchronization> <extensions> <extension>.class</extension> </extensions> </synchronization> <reloadOnUpdate>true</reloadOnUpdate> </configuration> </plugin>
Note: this feature needs a reloadable context (webapp). It is automatically taken into account since TomEE 1.5.2 but for previous versions (1.5.1 at least) you can need to activate it in server.xml.