Skip to content

Commit

Permalink
Code review:
Browse files Browse the repository at this point in the history
- change wording
- add wrapper version as custom value
- change variable name
- add a comment on distributionUrl pattern
  • Loading branch information
jprinet authored and gsmet committed Nov 21, 2023
1 parent fbf7ce5 commit 12cb0c4
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions .mvn/gradle-enterprise-custom-user-data.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -96,20 +96,23 @@ if (System.env.GITHUB_ACTIONS) {
}
}

// Check current Maven version and Maven Wrapper version alignment
// 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 currentMavenVersion = runtimeInfo?.getMavenVersion()
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 (currentMavenVersion && wrapperMavenVersion && wrapperMavenVersion != currentMavenVersion) {
log.warn("Maven Wrapper is configured with a different version (" + wrapperMavenVersion + ") than the current one (" + currentMavenVersion + "). This will negatively impact build caching.")
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 12cb0c4

Please sign in to comment.