-
Notifications
You must be signed in to change notification settings - Fork 354
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
Adding gradle wrapper through distribution is now possible #4491
Conversation
Strange... this failing test succeeds locally 🤷♂️ |
Linking the failure here for easy access:
I'd have to dive in, but I'm about to head out. Will try to circle back! |
So the intent of the parameters |
I could always alter the validation to allow for exact versions and distributions + do the replacements in distributionurl if that sounds better for you? But at this moment it's using services.gradle for the resolution if mentioned. I also believe the distributionurl is more important in deciding the impact than the fact if services.gradle is available or not. At our site we have access to services.gradle, but have custom wrappers in local repo. |
I don't think resolving the dynamic versions should be in scope right now. The reasons that it's been avoided so far as that each repository hosting tool has a different schema for versions, so it would be difficult to make a fully workable solution that covers all cases including within an environment that completely disallows access to services.gradle.org. Personally, I don't see much of a difference between the wrapperUri being fully defined versus the exact version parameterized replacements because they both are right there in the same spot and must be configured by the user at the time of defining the recipe. Maybe @timtebeek or @sambsnyd have some more opinions, but I've been more inclined to just use the wrapperUri as is with no replacements like you've done here in this PR. |
rewrite-gradle/src/test/java/org/openrewrite/gradle/UpdateGradleWrapperTest.java
Show resolved
Hide resolved
rewrite-gradle/src/main/java/org/openrewrite/gradle/UpdateGradleWrapper.java
Outdated
Show resolved
Hide resolved
The only slight concern I see is that with this change we completely disregard the checksum when using the wrapperUri. Then again I agree with @shanman190 that we shouldn't be looking at implementing full support for every hosting tool here. I think we adopt the same mindset as during my work on #4445, if the user specifies a wrapperUri we assume they know it's valid. |
I think the checksum part is a non-issue because if the URL is anything except a services.gradle.org, it's most likely that the wrapper is being updated per some organization policy. At that point, the checksum would have been invalid anyway. As @Jenson3210 was pointing out on the linked issue, in their case services.gradle.org is available, but they were also setting an internal wrapperUri. As a result, the custom wrapperUri wasn't being used. I could see a case being made to expose the checksum as a potential parameter though, so that a user could still provide it for a custom wrapperUri. |
@shanman190 , @Laurens-W I added the checksum property like you mentioned above. |
Interesting; I saw the following locally:
I suspect it's to do with tests using overlapping remote files, and one filling/polluting the cache for another. |
Adapted the test with the following reasoning: The addition of a wrapper downloads the necessary scripts/jar from the downloadURI. If that service is unavailable, it makes sense that the result is empty. As that test before was only bumping/updating wrapper version in url, I added the wrapper files and expect that they will not be touched if downloaduri is not available. With this before state, it is better representing the current situation if the bat/sh/jar files are present already. |
rewrite-gradle/src/test/java/org/openrewrite/gradle/UpdateGradleWrapperTest.java
Show resolved
Hide resolved
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.
Looks good to me! I especially like the validate()
change to clear out conditionals in getGradleWrapper()
. Thanks for picking this up!
Since @shanman190 had some feedback earlier I'll leave a decision to merge up to him.
rewrite-gradle/src/main/java/org/openrewrite/gradle/UpdateGradleWrapper.java
Show resolved
Hide resolved
rewrite-gradle/src/test/java/org/openrewrite/gradle/UpdateGradleWrapperTest.java
Show resolved
Hide resolved
Now that all comments have been resolved. @shanman190, do you agree we can merge? |
@Jenson3210, merged. Thanks for the help on this one! |
By allowing only distributionUri OR version/distribution, we also no longer use gradle services to determine the version which could not be available on the distributionUrl
Follow up from
distributionUrl
in gradle properties should be upgraded in place #4445