gpt4 book ai didi

maven-2 - 可以使用 maven 版本插入到过滤的资源文件中吗?

转载 作者:行者123 更新时间:2023-12-01 00:05:35 25 4
gpt4 key购买 nike

我想知道,是否有可能获得当前使用的 maven 版本来过滤资源文件。

我有一个资源文件,由 maven 过滤:

version=${project.version}
buildDate=${timestampFormatted}
buildBy=${user.name}
name=${project.artifactId}
buildVersion=${build.number}
osName=${os.name}
osArch=${os.arch}
osVersion=${os.version}
fileEncoding=${file.encoding}

现在我也更愿意保存当前使用的 maven 版本。

有没有类似 ${maven.version} 的东西?

非常感谢。

最佳答案

build-helper-maven-plugin可以做到这一点。查看 build-helper:maven-version目标,它设置一个包含当前 maven 版本的属性(默认为 maven.version)。

例如,下面的 pom 设置了该属性,然后使用该属性将 maven 版本保存到项目 jar 的 list 中。

<project>
...
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.3</version>
<executions>
<execution>
<id>maven-version</id>
<goals>
<goal>maven-version</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.2</version>
<configuration>
<archive>
<manifestEntries>
<Maven-Version>${maven.version}</Maven-Version>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>
...
</project>

关于maven-2 - 可以使用 maven 版本插入到过滤的资源文件中吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1531001/

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