删除版本号从文件的名称与Maven [英] Removing version number from file name with Maven

查看:209
本文介绍了删除版本号从文件的名称与Maven的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有Maven中的5个模块的项目。现在,当我做了MVN全新安装,从其他模块生成包含两个罐耳,一场战争和一个特区。

I have a project with 5 modules in maven. Right now, when I do a "mvn clean install", it generates an ear containing the two jars, one war and one sar from the other modules.

所有的文件名包含版本,例如,projectX创建入耳式2.0.0.ear,projectX创建客户端-2.0.0.jar等。

All the file names contain the version, e.g., projectx-ear-2.0.0.ear, projectx-client-2.0.0.jar, etc.

我需要重新命名的罐子之一,最终的耳朵省略文件名的版本。它应该是这样的:

I need to rename one of the jars and the final ear to omit the version in the file name. It should look like this:

projectx-ear.ear
|
+-- projectx-client.jar
|
+-- projectx-misc-2.0.0.jar
|
+-- projectx-sar-2.0.0.sar
|
\-- projectx-web-2.0.0.web

现在,我使用下面的插件来构建:
Maven的编译器插件和Maven释放-插件

Right now I'm using the following plugins to build: maven-compiler-plugin and maven-release-plugin

什么是达到我预期的结果的最佳方式?

What would be the best way to achieve the results I expect?

推荐答案

在你的耳朵的模块,您可以使用 project.build.finalName 元素也可以配置它支持<一的 Maven的耳插件 href=\"http://maven.apache.org/plugins/maven-ear-plugin/ear-mojo.html#finalName\"><$c$c>finalName可选参数。并配置捆绑JAR的最终名称,你需要定义一个<一个href=\"http://maven.apache.org/plugins/maven-ear-plugin/modules.html#jarModule\"><$c$c>jarModule并设置 bundleFileName 属性吧。

In your ear module, you can either use the project.build.finalName element or you can configure the maven-ear-plugin which supports a finalName optional parameter. And to configure the final name of a bundled jar, you'll need to define a jarModule and to set the bundleFileName property for it.

最后的配置可能看起来就像这样(我将演示如何在插件配置此处设置的最后耳名):

The final configuration might looks something like that (I'll demonstrate how to set the the final ear name in the plugin configuration here):

<project>
  [...]
  <dependencies>
    <dependency>
      <groupId>yourgroupid</groupId>
      <artifactId>projectx-client</artifactId>
      <version>2.0.0</version><!-- not mandatory if inherited -->
    </dependency>
    [...]
  </dependencies>
  [...]  
  <build>
    [...]
    <plugins>
      [...]
      <plugin>
        <artifactId>maven-ear-plugin</artifactId>
        <version>2.4</version>
        <configuration>
          <finalName>projectx-ear</finalName>
          <modules>
            <jarModule>
              <groupId>yourgroupid</groupId>
              <artifactId>projectx-client</artifactId>
              <bundleFileName>anotherName.jar</bundleFileName>
            </jarModule>
          </modules>
        </configuration>
      </plugin>
      [...]
</project>

这篇关于删除版本号从文件的名称与Maven的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆