0

Configuration Management team at my workplace mandates 4 digit version numbers for artefacts - say, 1.2.3.4 - for released artefact and 1.2.3.5-SNAPSHOT for development pom

In addition to this, our version control system (clearcase) has pre-label trigger which enforces a certain naming convention for label/tag.

So, if the pom version is 1.2.3.4-SNAPSHOT and artifactId is, for instance, shopcart then, as per the tag naming requirement, tag name should be:

XXX_1.2.3_SHOPCART_DROP4_SRC

where XXX is project code - constant string value.

As you see, in order to achieve this format, I need to make following customisations to tag name format:

  • artifactId - convert to uppercase
  • first 3 digits of 4 digit version number to be extracted
  • last digit of 4 digit version number to be extracted
  • concatenate everything as per the format.

I thought I would use gmaven plugin to get this done and populate a custom property to be used in tag or tagNameFormat configuration property of maven release plugin (v2.3.2) - but that doesn't work at all.

maven release plugin supports only 3 properties (artifactId, version, groupId) and doesn't support any other property.

gmaven plugin works as expected and sets a final user property in the tag name format I need - I verified it using the ant run maven plugin to echo the property.

Problem is with maven release plugin - it doesn't understand any user property...

Can anyone help how can I achieve this?

EDIT:

Interactive run is not a possibility - need to configure this to run for about 15 projects on jenkins ...

Many thanks, Tapasvi

4

1 回答 1

0

您应该仔细阅读 maven-release-plugin 的文档,因为有一个可用于此类目的的参数。tagNameFormat用于更改将要创建的标签的格式(哦,抱歉。您已经阅读过)。该版本可以通过buildhelper-maven-plugin提取到属性中。此外,buildhelper-maven-plugin 可用于制作工件 id 的大写:

通过对值应用正则表达式替换来设置属性

regex-property 目标可用于在应用正则表达式替换后将属性设置为一个值。例如,执行以下插件配置来设置 clearcase.artifact 属性。

<project>
  ...
  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <version>1.7</version>
        <executions>
          <execution>
            <id>regex-property</id>
            <goals>
              <goal>regex-property</goal>
            </goals>
            <configuration>
              <name>clearcase.artifactid</name>
              <value>$\{project.artifactId}</value>
              <regex>(.*)</regex>
              <replacement>???</replacement>
              <failIfNoMatch>false</failIfNoMatch>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  ...
</project>

但是你需要小心设置属性,因为 release:perform fork 一个 Maven 进程。您可能需要使用 -Darguments 选项来设置适当的参数。

于 2013-03-18T12:03:48.467 回答