【问题标题】:Hide the version of a jar in a build having packaging type "ear"在打包类型为“ear”的构建中隐藏 jar 的版本
【发布时间】:2010-10-12 13:34:26
【问题描述】:

我使用 Maven2。 我想知道有没有办法隐藏 jar 版本 构建 包装类型耳朵”。

例如,如果:

  1. 我使用的是版本 5 的 junit,我想将其命名为 junit.jar 而不是 junit-5.jar。
  2. 我使用了一个名为“file.jar”的外部 jar,并且我使用打包类型“ear”进行构建,我希望在构建之后,这个 jar 将添加到具有相同原始名称“file.jar”的 ear 中,并且不是“file-version.jar”。

我没有使用插件,我只是依赖: 例如,我有这个 pom:

<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>project</groupId>
  <artifactId>project</artifactId>
  <version>1</version>
  <packaging>ear</packaging>
  <dependencies>
    <dependency>
        <groupId>file</groupId>
        <artifactId>file</artifactId>
        <version>1</version> // just because it can't be empty
        <type>jar</type>
    </dependency>
  </dependencies>
</project>

我已经使用 mvn install:install-file 在我的本地存储库中安装了 file.jar

我想要一个包含 file.jar 没有版本名称(不是 file-1.jar)的耳朵“project.ear”作为工件!

【问题讨论】:

    标签: maven-2


    【解决方案1】:

    您只需在&lt;***Module&gt; 中使用&lt;bundleFileName&gt; 标签设置名称。

    但我必须说,我真的不明白为罐子取一个更晦涩的名字有什么意义。


    资源:

    【讨论】:

    • 我使用了一个名为“file.jar”的外部 jar,并且我使用打包类型“ear”进行构建,我希望在构建之后,这个 jar 将与他的原件一起添加到耳朵中命名为“file.jar”而不是“file-version.jar”。
    【解决方案2】:

    设置耳塞的fileNameMapping属性:

    <configuration>
      <fileNameMapping>no-version</fileNameMapping>
    </configuration>
    

    这不在文档中,但应该可以。

    编辑: 我只是看了一下插件的来源,这仅在最新的 ear 插件快照版本(2.5-SNAPHOT)中可用

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-12-15
    • 2015-11-22
    • 2018-04-19
    • 1970-01-01
    • 2014-02-23
    • 2021-03-05
    • 1970-01-01
    • 2014-03-12
    相关资源
    最近更新 更多