Maven multi-module web application (Hot swap)

jetty, maven, web-applications

Solution

A possible solution to your problem could be to build a skinny war with the maven-war-plugin (or at least exclude child1 and child2 if you have other dependencies as well) and add the target/classes folders of the child-projects to your classpath. This could be done with the Build Helper Maven Plugin's `add-resource` goal.

Disclaimer: I didn't try this myself but in theory it could work :)

Problem

I have a multi module web application. The structure is: ``` Parent | | - - Child 1 | - - Child 2 | - - Web ``` And the web project depends on the two child modules When using my IDE to build my project I was used to the IDE building the classes in the WEB-INF/classes folder. This was nice as the web server noticed the new classes and either restarted or hot deployed these files. With maven it seems that I have to package the whole thing from scratch every time. I would like to find a way in maven such that i can avoid running mvn:clean mvn:install mvn:war:inplace. Instead I would like a mvn:comile, and then the stuff just there. I hope you understand what I mean. Testing the web app is extremely slow when you always have to build all the project jars and run som war command before things are updated. The web apps pom: ``` <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> ... </parent> <artifactId>web</artifactId> <packaging>war</packaging> <dependencies> <dependency> <groupId>bla.bla.bla</groupId> <artifactId>bla_child1</artifactId> <version>1.0-SNAPSHOT</version> </dependency> <dependency> <groupId>bla.bla.bla</groupId> <artifactId>bla_child2</artifactId> <version>1.0-SNAPSHOT</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.4</version> </plugin> <plugin> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> <version>9.0.4.v20130625</version> <configuration> <scanIntervalSeconds>30</scanIntervalSeconds> <webApp> <contextPath>/blabla</contextPath> </webApp> </configuration> </plugin> </plugins> </build> </project> ```

Original source