我正在使用 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的 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>
uj5u.com熱心網友回復:
我想到了。覆寫戰爭被解壓到(默認)target/war/work/<groupId>/<artifactId>目錄。所以我在覆寫中排除了我想要的不同路徑的目錄,并確保在當前構建之前執行覆寫。然后我添加了一個資源來將相關目錄復制到構建目錄中,然后將其添加到我指定的路徑的戰爭中。
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.3</version>
<configuration>
<overlays>
<overlay>
<groupId>com.testing</groupId>
<artifactId>app1</artifactId>
<excludes>
<exclude>SomeContent/**</exclude>
</excludes>
</overlay>
<overlay><!-- empty groupId/artifactId represents the current build --></overlay>
</overlays>
<webResources>
...
<resource>
<directory>target/war/work/com.testing/app1/SomeContent</directory>
</resource>
</webResources>
</configuration>
</plugin>
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/439489.html
