We're using the Gradle Wrapper for all of our projects but one of our tools (IntelliJ IDEA) frequently re-runs the wrapper task which changes the first line - a comment about when the file was generated - every time it's run. This change has a tendency to be added to pull requests meaning that there's a high potential for unnecessary merge conflicts.
The proper solution would be to have all developers never check in the file unless it has actually changed in a meaningful way, but developers (me included) can be hasty and forgetful so the file shows up regularly in pull requests.
I've had a few ideas to solve this but can't really decide on any of them.
Make Git ignore the first line of gradle-wrapper.properties like this, feels cumbersome and will have to be done by every developer since it's local.
Add a tail to the gradle wrapper task that removes the first line of gradle-wrapper.properties, feels a bit hackish.
Somehow make IDEA not re-run the wrapper task automatically every time we sync the project, no idea how to do this.
I'm leaning towards 2. right now but I'd like to hear if anyone else have any better ideas.
Open gradle-wrapper. properties(go to Gradle > wrapper > gradle-wrapper. properties and manually change the distributionUrl property in the file.
The Gradle Wrapper itself does not execute your tasks. All it does is ensure you have the desired Gradle distribution and then invoke it.
Using the wrapper task ensures that any optimizations made to the Wrapper shell script or batch file with that specific Gradle version are applied to the project. As usual, you should commit the changes to the Wrapper files to version control.
The content of gradle-wrapper properties file is as follows: distributionBase=GRADLE_USER_HOME. distributionPath=wrapper/dists. distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-bin.zip.
It seems that selecting Use the default Gradle wrapper is the correct option to choose when importing a Gradle project and that Use customizable gradle wrapper (Gradle wrapper customization in script, works with Gradle 1.7 or later) is the option that causes IDEA to re-run the wrapper task all the time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With