Skip to content

Commit

Permalink
chore: improve pom version check ✅
Browse files Browse the repository at this point in the history
  • Loading branch information
oldratlee committed Apr 11, 2024
1 parent 30a8cb7 commit 75eff79
Showing 1 changed file with 39 additions and 10 deletions.
49 changes: 39 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>${project.build.sourceEncoding}</project.reporting.outputEncoding>
<maven.deploy.skip>false</maven.deploy.skip>
<maven.enforcer.pom.version.regex>^\d(\.\d+)?\.(\d+|x)-SNAPSHOT$</maven.enforcer.pom.version.regex>
<release.pom.version.regex>^\d\.\d+\.\d+(-(Alpha|Beta|RC)\d+)?$</release.pom.version.regex>

<spotbugs.annotations.version>4.8.4</spotbugs.annotations.version>
<jsr305.version>3.0.2</jsr305.version>
Expand Down Expand Up @@ -305,17 +307,23 @@
</goals>
<configuration>
<rules>
<!-- official docs: https://maven.apache.org/enforcer/enforcer-rules/requireMavenVersion.html -->
<requireMavenVersion>
<version>3.3.9</version>
</requireMavenVersion>
<!--
add maven-enforcer-plugin to make sure the right jdk is used
https://stackoverflow.com/a/18420462/922688
-->
<requireJavaVersion>
<version>19</version>
</requireJavaVersion>
<!-- official docs: https://maven.apache.org/enforcer/enforcer-rules/requireMavenVersion.html -->
<requireMavenVersion>
<version>3.3.9</version>
</requireMavenVersion>
<!-- https://maven.apache.org/enforcer/enforcer-rules/requireProperty.html -->
<requireProperty>
<property>project.version</property>
<regex>${maven.enforcer.pom.version.regex}</regex>
<regexMessage>Project version(${project.version}) format is invalid!</regexMessage>
</requireProperty>
</rules>
</configuration>
</execution>
Expand Down Expand Up @@ -511,6 +519,7 @@
</plugins>
</build>
</profile>

<profile>
<id>enforce-when-release</id>
<activation>
Expand All @@ -532,12 +541,6 @@
<requireJavaVersion>
<version>21</version>
</requireJavaVersion>
<!-- https://maven.apache.org/enforcer/enforcer-rules/requireProperty.html -->
<requireProperty>
<property>project.version</property>
<regex>^\d\.\d+\.\d+(-(Alpha|Beta|RC)\d+)?$|^\d(\.\d+)?\.(\d+|x)-SNAPSHOT$</regex>
<regexMessage>"Project version(${project.version}) format is invalid!"</regexMessage>
</requireProperty>
<!-- https://www.mojohaus.org/extra-enforcer-rules/enforceBytecodeVersion.html -->
<enforceBytecodeVersion>
<maxJdkVersion>${maven.compiler.source}</maxJdkVersion>
Expand All @@ -557,6 +560,32 @@
</plugins>
</build>
</profile>
<profile>
<id>enforce-project-version-when-release</id>
<activation>
<property>
<name>performRelease</name>
<value>true</value>
</property>
</activation>
<properties>
<maven.enforcer.pom.version.regex>${release.pom.version.regex}</maven.enforcer.pom.version.regex>
</properties>
</profile>
<profile>
<id>enforce-project-version-when-github-actions-triggered-by-tag</id>
<activation>
<property>
<!-- https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables -->
<name>env.GITHUB_REF_TYPE</name>
<value>tag</value>
</property>
</activation>
<properties>
<maven.enforcer.pom.version.regex>${release.pom.version.regex}</maven.enforcer.pom.version.regex>
</properties>
</profile>

<profile>
<id>gen-src</id>
<activation>
Expand Down

0 comments on commit 75eff79

Please sign in to comment.