[英]War external dependency overlay - move jars from WEB-INF/lib-new to WEB-INF/lib
I am working on a maven project with a war external dependency (let's call this war dependency WAR-DEP )我正在开发一个具有战争外部依赖项的 maven 项目(我们称之为战争依赖项 WAR-DEP )
After the build and during the package phase I am taking the content of WAR-DEP and merging it with the content of the current build using the overlay feature of the maven-war plugin.在构建之后和 package 阶段期间,我正在获取WAR-DEP的内容,并使用 maven-war 插件的覆盖功能将其与当前构建的内容合并。
In WAR-DEP we have some required jars in it's WEB-INF/lib folder so with the overlay we end up getting everything we need in our final war but our problem started when the project providing us with the WAR-DEP war added a new folder in the WEB-INF/lib-new and moved some of the jars we had before in the WEB-INF/lib folder to this new folder WEB-INF/lib-new .在WAR-DEP中,我们在它的WEB-INF/lib文件夹中有一些必需的 jars,因此通过覆盖,我们最终获得了最终战争所需的一切,但是当为我们提供WAR-DEP战争的项目添加了一个新的项目时,我们的问题就开始了WEB-INF/lib-new中的文件夹,并将我们之前在WEB-INF/lib文件夹中的一些 jars 移动到这个新文件夹WEB-INF/lib-new 。
After building with this new version of the WAR-DEP the overlay worked as expected so we ended up having two folders in the WEB-INF (lib and lib-new) and our application stopped working since this WEB-INF/lib-new is not recognized by tomcat server .在使用这个新版本的WAR-DEP构建后,覆盖按预期工作,所以我们最终在 WEB-INF 中有两个文件夹(lib 和 lib-new),并且我们的应用程序停止工作,因为这个WEB-INF/lib-new 是tomcat 服务器无法识别。 So without changing the classpath on tomcat side is there a way I can move the content of lib-new into the lib folder before generating the war?因此,在不更改 tomcat 端的类路径的情况下,有没有办法可以在生成战争之前将 lib-new 的内容移动到 lib 文件夹中? I mean for example during the overlay but I am not sure how to do this.我的意思是例如在覆盖期间,但我不确定如何执行此操作。 Thanks for your inputs.感谢您的投入。
maven-war-plugin
does not have required functionality, however maven-dependency-plugin
may help , smth. maven-war-plugin
没有所需的功能,但是maven-dependency-plugin
可能会有所帮助,smth。 like:喜欢:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<id>unpack-lib-new</id>
<goals>
<goal>unpack</goal>
</goals>
<phase>prepare-package</phase>
<configuration>
<artifactItems>
<artifactItem>
<groupId>dep-group-id</groupId>
<artifactId>dep-artifiact-id</artifactId>
<version>dep-version</version>
<type>war</type>
<outputDirectory>${project.build.directory}/${build.finalName}/WEB-INF/lib</outputDirectory>
<includes>WEB-INF/lib-new/*</includes>
<fileMappers>
<org.codehaus.plexus.components.io.filemappers.FlattenFileMapper/>
</fileMappers>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.2</version>
<configuration>
...
<overlays>
<!-- current project -->
<overlay/>
<overlay>
<id>dep-skip-lib-new</id>
<groupId>dep-group-id</groupId>
<artifactId>dep-artifact-id</artifactId>
<excludes>
<exclude>WEB-INF/lib-new/*</exclude>
</excludes>
</overlay>
</overlays>
...
</configuration>
</plugin>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.