Maven WAR 覆盖 - 将资源合并到不同的路径中
我使用的是maven 4.0.0。我在 maven-war-plugin 中使用覆盖层将 app1 合并到 app2 中。我想将 app1 中的一些目录合并到 app2 中的不同位置。本质上是将 SomeContent 目录中的内容向上移动一级。这可能吗?我需要以某种方式使用 maven-resources-plugin 吗?
以下是 app1 战争中存在问题的文件:
SomeContent/admin/index.jsp
SomeContent/images/header.png
我希望在叠加后在 app2 战争中得到这样的文件:
admin/index.jsp <-- from app1
images/header.png <-- from app1
app2.jsp <-- from app2
WEB-INF/... <-- from app2
... <-- from app2
app1< /strong> 的 pom:
<groupId>com.testing</groupId>
<artifactId>app1</artifactId>
<packaging>war</packaging>
...
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.3</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
</configuration>
</plugin>
app2 的 pom:
<groupId>com.testing</groupId>
<artifactId>app2</artifactId>
<packaging>war</packaging>
...
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.3</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<overlays>
<overlay>
<groupId>com.testing</groupId>
<artifactId>app1</artifactId>
</overlay>
</overlays>
</configuration>
</plugin>
I'm using maven 4.0.0. I'm using an overlay in the maven-war-plugin to merge app1 into app2. I want to merge some of the directories in app1 into a different location in app2. Essentially move the content inside the SomeContent directory up one level. Is this even possible? Do I need to use the maven-resources-plugin somehow?
Here are the files in question in the war of app1:
SomeContent/admin/index.jsp
SomeContent/images/header.png
I want to end up with the files like this in app2's war after the overlay:
admin/index.jsp <-- from app1
images/header.png <-- from app1
app2.jsp <-- from app2
WEB-INF/... <-- from app2
... <-- from app2
app1's pom:
<groupId>com.testing</groupId>
<artifactId>app1</artifactId>
<packaging>war</packaging>
...
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.3</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
</configuration>
</plugin>
app2's pom:
<groupId>com.testing</groupId>
<artifactId>app2</artifactId>
<packaging>war</packaging>
...
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.3</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<overlays>
<overlay>
<groupId>com.testing</groupId>
<artifactId>app1</artifactId>
</overlay>
</overlays>
</configuration>
</plugin>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想通了。覆盖战争被解压到(默认)
target/war/work//
目录。因此,我在覆盖中排除了我想要的不同路径的目录,并确保覆盖在当前构建之前执行。然后我添加了一个资源,将相关目录复制到构建目录中,然后将其添加到我指定的路径中的 war 中。I figured it out. The overlay war is unpacked to the (default)
target/war/work/<groupId>/<artifactId>
directory. So I excluded in the overlay the directory I want at a different path, and make sure that overlay is executed before the current build. Then I added a resource to copy the directory in question into the build directory, which then gets added to the war at the path I specify.