The goal of the Jawr maven plugin is to simplify the use of the bundle preprocessing in the maven build lifecycle. If you have not read the documentation of the bundle preprocessing, please take a look at it before continuing.
The Jawr maven plugin use the following properties:
<plugin> <groupId>net.jawr.tools</groupId> <artifactId>jawr-maven-plugin</artifactId> <version>3.8</version> <executions> <execution> <!-- Use this phase so that we could deal with the war folder just before the war package --> <phase>prepare-package</phase> <goals> <goal>bundle</goal> </goals> </execution> </executions> <configuration> <generateCDNFiles>true</generateCDNFiles> </configuration> </plugin>
For the spring MVC projects, you can use:
<plugin> <groupId>net.jawr</groupId> <artifactId>maven-jawr-plugin</artifactId> <version>1.0</version> <executions> <execution> <!-- Use this phase so that we could deal with the war folder just before the war package --> <phase>prepare-package</phase> <goals> <goal>bundle</goal> </goals> </execution> </executions> <configuration> <generateCDNFiles>true</generateCDNFiles> <springConfigFiles>classpath:/spring-jawrConfig.xml,/WEB-INF/jawr-controllers.xml</springConfigFiles> </configuration> </plugin>
You could launch the bundling process directly using the maven command:
mvn jawr:bundle
As you know, the bundle processor fakes the server startup. In the current implementation, the bundle processor will add the WEB-INF/lib directory in the classpath. But you could face some issue, if you are using some jar files which are defined in the application server itself.
To resolve this issue, you can use the classpath property in the plugin definition like below:
<plugin> <groupId>net.jawr.tools</groupId> <artifactId>jawr-maven-plugin</artifactId> <version>3.8</version> <executions> <execution> <!-- Use this phase so that we could deal with the war folder just before the war package --> <phase>prepare-package</phase> <goals> <goal>bundle</goal> </goals> </execution> </executions> <!-- Add jars as the dependencies of the plugin, so it will be accessible in the classpath during the Jawr maven plugin execution --> <dependencies> <dependency> <groupId>com.mycompany</groupId> <artifactId>my-artifact</artifactId> <version>1.0</version> </dependency> </dependencies> <configuration> <generateCDNFiles>true</generateCDNFiles> </configuration> </plugin>