简体   繁体   English

如何配置Hudson / Maven2将SVN版本添加到EAR名称?

[英]How to configure Hudson/Maven2 to add SVN revision to name of EAR?

We use Hudson, Maven2 and maven-ear-plugin. 我们使用Hudson,Maven2和maven-ear-plugin。

Is it possible to have the built EAR files to contain SVN revision in their filename (something like project-1234.ear)? 是否有可能使生成的EAR文件的文件名包含SVN修订版(类似project-1234.ear)?

You can use the buildnumber-maven-number for this. 您可以为此使用buildnumber-maven-number Basically, this plugin sets a ${buildNumber} property that you can use later in the maven ear plugin configuration. 基本上,此插件设置一个${buildNumber}属性,您稍后可以在maven ear插件配置中使用。

First, setup the Build Number Maven Plugin as documented here : 首先,按照此处所述设置内部版本号Maven插件:

<plugins>
  <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>buildnumber-maven-plugin</artifactId>
    <version>1.0-beta-4</version>
    <executions>
      <execution>
        <phase>validate</phase>
        <goals>
          <goal>create</goal>
        </goals>
      </execution>
    </executions>
    <configuration>
      <doCheck>true</doCheck>
      <doUpdate>true</doUpdate>
    </configuration>
  </plugin>
  ...
</plugins>

Then, use the finalName parameter to customize the name of the generated ear. 然后,使用finalName参数来自定义生成的耳朵的名称。 For example: 例如:

<plugins>
  ...
  <plugin>
    <artifactId>maven-ear-plugin</artifactId>
    <version>2.4</version>
    <configuration>
      <finalName>${project.artifactId}-r${buildNumber}</finalName> 
      ...
    </configuration>
  </plugin>
  ...
</plugins>

Hudson nows the revision. 哈德森现在修订。 So you have two options. 因此,您有两个选择。 Just rename the output afterwards or supply Maven with the revision and it can change the name as needed. 只需稍后重命名输出或向Maven提供修订版本,它就可以根据需要更改名称。

Thinkking about it, there might also be another way. 考虑一下,也许还有另一种方式。 Let Maven query svn for the revision and than incorporate it in the earname 让Maven查询svn以获取修订,然后将其合并到耳名中


However, Do you really need it? 但是,您真的需要吗? Hudson offers the option to fingerprint ears. Hudson提供了对耳朵进行指纹识别的选项。 This way you can submit the file later to Hudson and it gives the the build number back. 这样,您可以稍后将文件提交给Hudson,它会返回内部版本号。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM