I want to set a property conditionally in maven depending on whether it is a snapshot build or not. The pseudocode looks as follows
if ${project.version} ends with "-SNAPSHOT"
then
deployFileUrl = ${project.distributionManagement.snapshotRepository.url}
else
deployFileUrl = ${project.distributionManagement.repository.url}
How can I implement this in maven?
I tried it with the build-helper-maven-plugin as follows
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>regex-properties</id>
<goals>
<goal>regex-properties</goal>
</goals>
<configuration>
<regexPropertySettings>
<regexPropertySetting>
<name>deployFileUrl</name>
<value>${project.version}</value>
<regex>.*-SNAPSHOT</regex>
<replacement>${project.distributionManagement.snapshotRepository.url}</replacement>
<failIfNoMatch>false</failIfNoMatch>
</regexPropertySetting>
</regexPropertySettings>
</configuration>
</execution>
</executions>
</plugin>
The problem with this approach is that I can not implement the else-condition.