开发者

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

开发者 https://www.devze.com 2023-03-29 01:11 出处:网络
I\'ve got开发者_如何转开发 a Maven2 project with two submodules, laid out like this: parentproject

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?


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.


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}


You have to define a dependency in the war-project to your applet-project.

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

精彩评论

暂无评论...
验证码 换一张
取 消