Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding an applet in a submodule to a WAR file in Maven

I've got a Maven2 project with two submodules, laid out like this:

parentproject
|---war-file-project
|---applet-project

The POMs in each of them have the appropriate parent-module relationships. The applet-project contains a simple applet and is set up with JAR packaging. The war-file-project contains a simple WAR file project and is set up with WAR packaging.

When I build, I'd like to make sure that the WAR file contains the resulting JAR file from the applet-project in the /applets directory.

How do I do this?

like image 693
Jonathan Avatar asked Aug 19 '11 11:08

Jonathan


2 Answers

To achieve that you can simply use the maven-dependency-plugin to copy the dependency to an appropriate location.

Created a complete example which you can use as a template.

like image 98
khmarbaise Avatar answered Oct 22 '22 21:10

khmarbaise


Thanks khmarbaise for an excellent template!

I've also found one might want to adjust it with the following changes:

  • add <scope>provided</scope> to the 'supplemental' dependency in war/pom.xml - then supplemental.jar will not be duplicated at /WEB-INF/lib
  • add <stripVersion>true</stripVersion> to the example maven-dependency-plugin configuration - then applet will be in 'supplemental.jar' instead of something like 'supplemenal-0.1.0-SNAPSHOT.jar'
  • change ${project.artifactId}-${project.version} in <outputDirectory> to a more reliable ${project.build.finalName}
like image 27
Dzmitry Avatar answered Oct 22 '22 22:10

Dzmitry