Open Jenson3210 opened 1 week ago
I have test case + this code fix almost ready but having dpendency issues in our firewall (timeouts)
Downloading the other required files like gradlew
, gradlew.bat
, gradle/wrapper/gradle-wrapper.jar
is failing as the goal here is to access a non-publicly available distributionUrl.
Moderne platform does not have the ability to reach this endpoint.
Capturing some of the details from chat here as well, in case that's helpful for others.
Some unit tests we run make use of okhttp3's MockWebServer; perhaps that can get you past the hump of testing with a remote server?
Beyond that, if you create an "http tool" in your agent config, recipes can access it through your agent.
The existing test is only working because the 8.0.x gets retrieved to 8.0.2 by https://services.gradle.org/distributions/ I believe either the version should be translated/resolved by https://company.com/repo/ or should not be resolvable. There is no guarantee that company repo is capable of resolving 8.0.2 (imagine that one was not created yet). Using the central services repo to determine the version and then updating the url feels off to me. What do you think?
What I propose is not allowing wildcard matchers if you specify the distribution url. Very limited value I see in allowing the placeholder resolution even if you are already setting the distribution url with the version and distribution variables. 1 variable vs 2 or 3 in the yaml.
So either provide version & optionally distribution OR provide entire distribution url. What do you think?
In the event of a gradle wrapper that needs to be added to a project that does not contain one AND the distributionUrl is mentioned, this code will no add the correct wrapper.
If the outside world is reachable, this try block does not fail -> the distribution url is not used and the wrong wrapper gets added.
https://github.com/openrewrite/rewrite/blob/0b6914b82be589bb6924f273c7ee2cb6c873b853/rewrite-gradle/src/main/java/org/openrewrite/gradle/UpdateGradleWrapper.java#L124-L160
The Gradle wrapper will be created using the outside world services gradle and we will never reach the distributionUrl wrapper additions.
https://github.com/openrewrite/rewrite/blob/0b6914b82be589bb6924f273c7ee2cb6c873b853/rewrite-gradle/src/main/java/org/openrewrite/gradle/util/GradleWrapper.java#L60-L90
The recipe from the list:
The output:
I think if we rework the getWrapper method we could fix this.