猿问

Maven存档包含不同文件的多个战争

我有一个 Maven 项目,其中包含三个文件,如下所示:


src/main/webapp/file.xml

src/main/webapp/fileA.xml

src/main/webapp/fileB.xml

我的目标是使用相同的 jenkins 任务归档三个不同的 war 包,其中每个资源文件都被重命名并称为file.xml.


结果应该是:


package-with-file.war

package-with-fileA.war

package-with-fileB.war

第一个包应该删除fileA.xml和fileB.xml

第二应该删除file.xml,并fileB.xml和重命名fileA.xml的file.xml

第三应该删除file.xml和fileA.xml,并重新命名fileB.xml的file.xml

我的事情的方式,可以使用profiles和使用maven-deploy-plugin定义不同classifier,并filename为每个包,但我不知道如何之前重命名文件。


<plugin>

  <artifactId>maven-deploy-plugin</artifactId>

  [...]

  <configuration>

    <groupId>${project.groupId}</groupId>

    <artifactId>${project.artifactId}</artifactId>

    <packaging>war</packaging>

    <version>${project.version}</version>

    <classifier>fileA</classifier>

    <file>

       ${project.build.directory}/${project.build.finalName}-fileA.war

    </file>

  </configuration>

  [...]

</plugin>


慕容708150
浏览 118回答 2
2回答

UYOU

我会将文件放在 3 个不同的目录中:src/main/webapp-A|B|C/file.xml 然后编写 3 个不同的 maven-war-plugin 执行,每个都添加这些目录之一,如下所示:<plugin>&nbsp; <groupId>org.apache.maven.plugins</groupId>&nbsp; <artifactId>maven-war-plugin</artifactId>&nbsp; <configuration>&nbsp; &nbsp; <webResources>&nbsp; &nbsp; &nbsp; &nbsp; <resource>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <directory>src/main/webapp-A</directory>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <targetPath>/</targetPath>&nbsp; &nbsp; &nbsp; &nbsp; </resource>&nbsp; &nbsp; </webResources>&nbsp; </configuration></plugin>-- 编辑 1 --我认为从一个目录中是不可能的。您必须使用不同的目录或为文件使用不同的名称。
随时随地看视频慕课网APP

相关分类

Java
我要回答