gpt4 book ai didi

java - Maven ${project.version.prefix}

转载 作者:行者123 更新时间:2023-12-02 01:41:56 28 4
gpt4 key购买 nike

我们有一个多模块 java 项目,每个模块中都有 pom.xml。我看到 pom.xml 中有 ${project.version} ,它基本上获取了项目版本。是否有类似 ${project.version.prefix} 的东西也能获取项目版本减去快照?

最佳答案

使用 build-helper-maven-plugin (通过 build helper plugin not parsing project version )

maven-antrun-plugin 仅用于显示结果

 <plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<phase>validate</phase>
<id>parse-version</id>
<goals>
<goal>parse-version</goal>
</goals>
<configuration>
<propertyPrefix>parsedVersion</propertyPrefix>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echo>Major: ${parsedVersion.majorVersion}</echo>
<echo>Minor: ${parsedVersion.minorVersion}</echo>
<echo>Incremental: ${parsedVersion.incrementalVersion}</echo>
<echo>Qualifier: ${parsedVersion.qualifier}</echo>
<echo>BuildNumber: ${parsedVersion.buildNumber}</echo>
<echo>Project version: ${project.version}</echo>
<echo>No qualifier: ${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}</echo>
</tasks>
</configuration>
</execution>
</executions>
</plugin>

输出:

 [INFO] --- maven-antrun-plugin:1.1:run (default) @ XXX ---
[INFO] Executing tasks
[echo] Major: 1
[echo] Minor: 2
[echo] Incremental: 0
[echo] Qualifier: SNAPSHOT
[echo] BuildNumber: 0
[echo] Project version: 1.2.0-SNAPSHOT
[echo] No qualifier: 1.2.0

关于java - Maven ${project.version.prefix},我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54350831/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com