Maven in a multi-module web project: how to output output modules to WEB-INF / classes, and not to WEB-INF / lib like JAR?

I have a multi-module Maven project. By default, when I create a web module, all sibling modules of the JAR type that it depends on are copied to the WEB-INF / lib folder. I want the sibling output modules to be placed in the WEB-INF / classes folder without packaging in the JAR.

A more general question: how to save the configuration files of sibling modules from the JAR so that they can be easily edited after deployment?

+4
source share
2 answers

If anyone is interested, I have found this solution. I had exactly the same problem.

<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <configuration> <packagingExcludes>WEB-INF/lib/MYPACKAGE_TO_EXCLUDE.jar</packagingExcludes> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <executions> <execution> <id>unpack-MYPACKAGE_TO_EXCLUDE</id> <phase>compile</phase> <goals> <goal>unpack</goal> </goals> <configuration> <artifactItems> <artifactItem> <groupId>${project.groupId}</groupId> <artifactId>MYPACKAGE_TO_EXCLUDE</artifactId> <version>${project.version}</version> <type>jar</type> <outputDirectory>${project.build.directory}/classes </outputDirectory> </artifactItem> </artifactItems> </configuration> </execution> </executions> </plugin> </plugins> </build> 
+2
source

You can use overlay , although this requires the sibling to have a type of war, not a jar. It also uses the dependency plugin to unzip the jar, but it will only unpack the version in your local repository, and not the one you just packed.

As for your more general question, it excludes the tag for the jar plugin.

+1
source

All Articles