Skip to content

Commit

Permalink
Merge pull request #36357 from jprinet/feature/check-maven-version-al…
Browse files Browse the repository at this point in the history
…ignment

Check runtime Maven version is aligned with wrapper Maven version
  • Loading branch information
gsmet authored Nov 21, 2023
2 parents 914698e + 325a1a8 commit d353f20
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .mvn/gradle-enterprise-custom-user-data.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,23 @@ if (System.env.GITHUB_ACTIONS) {
}
}

// Check runtime Maven version and Maven Wrapper version are aligned
def runtimeInfo = (org.apache.maven.rtinfo.RuntimeInformation) session.lookup("org.apache.maven.rtinfo.RuntimeInformation")
def runtimeMavenVersion = runtimeInfo?.getMavenVersion()
Properties mavenWrapperProperties = new Properties()
File mavenWrapperPropertiesFile = new File(".mvn/wrapper/maven-wrapper.properties")
if(mavenWrapperPropertiesFile.exists()) {
mavenWrapperPropertiesFile.withInputStream {
mavenWrapperProperties.load(it)
}
// assuming the wrapper properties contains:
// distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/VERSION/apache-maven-VERSION-bin.zip
if(regexp = mavenWrapperProperties."distributionUrl" =~ /.*\/apache-maven-(.*)-bin\.zip/) {
def wrapperMavenVersion = regexp.group(1)
if (runtimeMavenVersion && wrapperMavenVersion && wrapperMavenVersion != runtimeMavenVersion) {
log.warn("Maven Wrapper is configured with a different version (" + wrapperMavenVersion + ") than the runtime version (" + runtimeMavenVersion + "). This will negatively impact build consistency and build caching.")
buildScan.tag("misaligned-maven-version")
buildScan.value("wrapper-maven-version", wrapperMavenVersion)
}
}
}

0 comments on commit d353f20

Please sign in to comment.