将工件复制到ear lib文件夹时更改jar的文件名

问题描述 投票:0回答:1

我有以下 maven-ear-plugin,它更改运行 mvn clean install 时复制到 lib 文件夹的 jar 文件的文件名(通过在其前面添加 1)。这可行,但有没有办法只更改选定的artifactsId的名称?比如说,artifactId 是“apples.test”

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-ear-plugin</artifactId>
    <version>3.3.0</version>
    <configuration>
      <outputFileNameMapping>1_@{artifactId}@-@{version}@@{dashClassifier?}@.@{extension}@</outputFileNameMapping>
    </configuration>
  </plugin>

使用了outputFileNameMapping,但这会影响复制的所有jar。

项目结构如下所示:

ear
  -> lib
  -> META_INF
  -> war1.war
  -> war2.war
  -> war3.war
maven pom.xml maven-plugin ear
1个回答
0
投票

假设您将 pom 设置为模块化(多个子项目),您应该能够识别单个模块,从而应用 Apache Maven EAR Plugin 站点上给出的示例:

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-ear-plugin</artifactId>
        <version>3.3.0</version>
        <configuration>
           [...]
           <modules>
             <ejbModule>
               <groupId>artifactGroupId</groupId>
               <artifactId>artifactId</artifactId>
               <bundleFileName>anotherName-1.2.3.jar</bundleFileName>
             </ejbModule>
          </modules>
        </configuration>
      </plugin>
    </plugins>
  </build>

如果这还不够强大,还有另一个机会使用MVN Assembly插件。在它的程序集描述符中放入类似

的序列
<files>
    <file>
        <source>readme.md</source>
        <outputDirectory></outputDirectory>
        <destName>readme.txt</destName>
    </file>
</files>
© www.soinside.com 2019 - 2024. All rights reserved.