检查Maven pom是否为SNAPSHOT [英] Check if Maven pom is SNAPSHOT
问题描述
如果项目当前为 SNAPSHOT 版本,我需要一种将属性is.snapshot
设置为0
的方法,否则将属性设置为1
.
I need a way to set a property is.snapshot
to 0
if project is currently a SNAPSHOT version, otherwise set the property to 1
.
我的尝试是使用build-helper-plugin
My attempt was to use the build-helper-plugin
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>version-helper</id>
<goals>
<goal>regex-property</goal>
</goals>
</execution>
</executions>
<configuration>
<name>is.snapshot</name>
<value>${project.version}</value>
<regex>.*(-SNAPSHOT)$</regex>
<replacement>0</replacement>
<failIfNoMatch>false</failIfNoMatch>
</configuration>
</plugin>
如果project.version
是 SNAPSHOT ,则is.snapshot
属性设置为0
.这很好.
但是,如果project.version
不是 SNAPSHOT ,则该属性将设置为project.version
.
If project.version
is SNAPSHOT the is.snapshot
property is set to 0
. This works fine.
However, if project.version
is not a SNAPSHOT the property gets set to the project.version
.
有什么方法可以解决这个问题,或者我可以使用其他插件吗?
Any way to correct this or is there another plugin I could use?
推荐答案
您可以设置发行版,如果确实需要rpm-maven-plugin.
You can set the the release version of the rpm-maven-plugin manually if you really need it.
这篇关于检查Maven pom是否为SNAPSHOT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!