-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Check runtime Maven version is aligned with wrapper Maven version #36357
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. would it be valuable to add a custom value with the wrapper version? I'm assuming that the runtime version is already part of the scan There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't think it was necessary at first thought as the version can be obtained in the Git repo, let's add it to simplify investigation if any 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point. I'm not sure it is needed if it is in the repo then. It was just a thought. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll add it, Guillaume will decide if they want it or not |
||
buildScan.value("wrapper-maven-version", wrapperMavenVersion) | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will work for Quarkus but we if the maven wrapper is distributed from a custom URL will this still work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am parsing here a standard URL, this could not work with a custom URL indeed.
I am adding a comment to describe what is expected.