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 24, 2024
1 parent 0f7a4e1 commit aef2dad
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 11 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.2</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
2 changes: 1 addition & 1 deletion scripts/integration_test
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ readonly JDK_VERSIONS=(
# shellcheck disable=SC2034
readonly MVU_MVN_OPTS=(
"${MVU_DEFAULT_MVN_OPTS[@]}"
-DperformRelease -P'!gen-sign'
-DperformRelease -P'!gen-sign' -P'!enforce-project-version-when-release'
${CI_MORE_MVN_OPTS:+${CI_MORE_MVN_OPTS}}
)

Expand Down

0 comments on commit aef2dad

Please sign in to comment.