0

我尝试将项目版本解析为名为 build-number 的新变量,我使用以下插件

    <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>build-helper-maven-plugin</artifactId>
    <version>1.7</version>
    <executions>
        <execution>
            <id>rename-property</id>
            <goals>
                <goal>regex-property</goal>
            </goals>
            <phase>package</phase>
            <configuration>
                <name>build-number</name>
                <value>${project.version}</value>
                <regex>\.</regex>
                <replacement>_</replacement>
                <failIfNoMatch>false</failIfNoMatch>
            </configuration>
        </execution>
    </executions>
</plugin>

我在 pom.xml 中的属性部分看起来像这样

 <modelVersion>4.0.0</modelVersion>

 <groupId>xxx.xxx.xxx</groupId>
 <artifactId>xxx</artifactId>
 <version>1.1.2</version>
 <packaging>rar</packaging>

 <properties>
     <build-number></build-number>
 </properties>

我的问题是如何访问这个变量,启动 mvn build 后我可以看到

[INFO] --- build-helper-maven-plugin:1.7:regex-property (rename-property) @ xxx--- [INFO] 将属性 'build-number' 设置为 '1_1_2'。

4

1 回答 1

1

我发现当我们将相位设置为 validate then 时一切正常。

于 2018-08-29T13:22:42.347 回答