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>
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 :)
This is my own temporary answer to this problem.
It would be nice if it could be done with maven, but I haven't been able to find a solution. Therefore I have bound an ant target to the compile phase of the web module.
This is probably not a solution that can be used anywhere, but it works in my case.
web/pom.xml:
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>copy-modules</id>
<phase>compile</phase>
<configuration>
<target>
<delete dir="${project.basedir}\src\main\webapp\WEB-INF\classes"/>
<copy todir="${project.basedir}\src\main\webapp\WEB-INF\classes">
<fileset dir="${main.basedir}\modules\child-1\target\classes">
<include name="**/*.class"/>
<include name="**/*.xml"/>
</fileset>
<fileset dir="${main.basedir}\modules\child-2\target\classes">
<include name="**/*.class"/>
<include name="**/*.xml"/>
</fileset>
</copy>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
Now the jetty sees everytime I do a compile, which is much faster than install, war and the stuff that was needed before.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With