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

I have a Maven2 project with two submodules that looks like this:

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

POMs in each of them have corresponding parent module relationships. applet-project contains a simple applet and is configured with JAR packaging. war-file-project contains a simple WAR file project and is configured to pack WAR.

When I create, I would like to make sure that the WAR file contains the resulting JAR file from the applet-project in the /applets .

How to do it?

+6
source share
3 answers

To do this, you can simply use the maven-dependency plugin to copy the dependencies to the appropriate location.

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

+7
source

Thanks khmarbaise for the great template!

I also found that you can configure it with the following changes:

  • add <scope>provided</scope> to the "additional" dependency in war / pom.xml - then addal.jar will not be duplicated in / WEB -INF / lib
  • add <stripVersion>true</stripVersion> to the maven-dependency-plugin configuration example - then the applet will be in the file "addal.jar" instead of "supplemenal-0.1.0-SNAPSHOT.jar"
  • change ${project.artifactId}-${project.version} in <outputDirectory> to a more robust ${project.build.finalName}
+2
source

You must determine the dependency in the military project on your applet project.

 <dependency> <groupId>${project.groupId}</groupId> <artifactId>applet-project</artifactId> <version>${project.version}</version> </dependency> 
0
source

Source: https://habr.com/ru/post/895411/


All Articles