Honoring configured networkTimeout when calling ./gradle wrapper#14043
Conversation
9553f04 to
6fa2d2f
Compare
| sig { params(properties_file: T.any(Pathname, String)).returns(T.nilable(String)) } | ||
| def get_validate_distribution_url_option(properties_file) | ||
| return nil unless File.exist?(properties_file) | ||
| # For the same reason, we apply the same for `--network-timeout`. |
There was a problem hiding this comment.
Let's add the right context here please. It is not exactly the same reason.
Hopefully we can merge #14037 first, or you can cherry-pick my commit and we merge it as a single change; It does not matter to me as long as the context is captured
There was a problem hiding this comment.
If we follow the pattern in #14037, we can add it as we define the argument rather that in the method docs
There was a problem hiding this comment.
Just solved conflicts and added some wording for it. Feel free to make it better ;)
| # For the same reason, we apply the same for `--network-timeout`. | ||
| sig { params(properties_file: T.any(Pathname, String)).returns(T::Array[T.nilable(String)]) } | ||
| def read_wrapper_options(properties_file) | ||
| return [nil, nil] unless File.exist?(properties_file) |
There was a problem hiding this comment.
I think that this check should not be here, instead, it should be before this method is called
If there is no property file all the way to this context, the subsequent logic should not run at all
To be fair, based on what I currently see in the code, I don't even think that's possible either
There was a problem hiding this comment.
I'd prefer to keep it in here to be honest. If, for whatever reason, the file is not there, then there are no values to read, so it's the same as if they are not present at all in the .properties file. It keeps the logic encapsulated.
There was a problem hiding this comment.
In what situation can the property file not exist and get to this context? Maybe I am missing something
There was a problem hiding this comment.
The reason I ask is because extra error handling does not help if it can never happen. It does not hurt in terms of error handling, it is just dead code
But maybe I am missing something
| env = { "JAVA_OPTS" => proxy_args.join(" ") } # set proxy for gradle execution | ||
|
|
||
| command_parts = %w(--no-daemon --stacktrace) + command_args(target_requirements, network_timeout) | ||
| command = Shellwords.join([has_local_script ? "./gradlew" : "gradle"] + command_parts) |
There was a problem hiding this comment.
Can we remove this workaround in this change or in a future change?
I am honestly not too sure this can happen. From what I remember, this was added because of fears that users may not commit the Unix variant, but honestly, I am not too sure if we should actually even do this. Of all the hacks, this is the one I regret the most because Dependabot works in Unix and we can set that as an expectation
There was a problem hiding this comment.
No, this was because:
- It could be possible that
./gradlewscript was altered, not working (without+xpermission) or even not existing at all, and that willdependabotto fail. - Or the
gradle-wrapper.jaris corrupted, compiled for an incompatible java version, et.
So, panic condition, if updating with the current wrapper helper code fails, we'll try with system's native gradle instalation before giving up.
Actually, one of the smoke tests is validating this scenario.
There was a problem hiding this comment.
Sorry, I meant the has_local_script check. I understand the fallback mechanism, what I don't understand is when has_local_script can be false
There was a problem hiding this comment.
We don't know the structure of a project. Is possible they do have a gradle/gradle-wrapper.properties file, but for some reason (for instance, they only support Windows) they have decided not to commit the ./gradlew script.
That's the thing, we don't know. This is more to have a robust code prepared for any kind of scenario (that we can predict, without entering too much complexity).
There was a problem hiding this comment.
Thanks, I think that we should log this behavior in a follow up change. Just for user's awareness.
|
This change closes #14026 |
17f0f51 to
3d826d2
Compare
|
Changes look good to me. Thanks for the effort @kbukum1 Please review when you are ready. Also see the discussion as to why I believe that we should still do this even if it feels that Gradle should do it |
| its(:content) do | ||
| expected_command = %W( | ||
| ./gradlew --no-daemon --stacktrace wrapper --gradle-version 9.0.0 --no-validate-url | ||
| --network-timeout 10000 |
There was a problem hiding this comment.
As this is the default value, can we please create a test to ensure that other than the default is respected? Maybe an integration test?
@gmazzo , thanks for the effort. I did review it roughly. I will review again later. Currently there are issues on actions and pipeline is failing. I will review later and most probably approve since I see you guys did great job went on every detail. @yeikel thank you for all reviews and questions. It helps a lot. |
c47aa13 to
15dabae
Compare
15dabae to
2a4d4d1
Compare
Co-authored-by: Yeikel Santana <email@yeikel.com>
2a4d4d1 to
2dd6bf3
Compare
|
The build failure seems like a temporary downtime. Retrying the build should fix it |
What are you trying to accomplish?
Fixes #14027 by workaround gradle/gradle#36172, by reading
networkTimeoutproperty fromgradle-wrapper.propertiesand passing it as--network-timeoutwhen calling./gradlew wrapper.Anything you want to highlight for special attention from reviewers?
As I commented at #14024 (comment), I don't think we should be patching Gradle's defects. But in case you decide to move forward, this should be a way to do it.
How will you know you've accomplished your goal?
Tests and smoke tests will cover it
Checklist