Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Preventing gradle-wrapper.properties from changing all the time [duplicate]

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.

  1. 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.

  2. Add a tail to the gradle wrapper task that removes the first line of gradle-wrapper.properties, feels a bit hackish.

  3. 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.

like image 659
Raniz Avatar asked Mar 11 '16 09:03

Raniz


People also ask

How do you change Gradle wrapper properties?

Open gradle-wrapper. properties(go to Gradle > wrapper > gradle-wrapper. properties and manually change the distributionUrl property in the file.

What does a Gradle wrapper not do?

The Gradle Wrapper itself does not execute your tasks. All it does is ensure you have the desired Gradle distribution and then invoke it.

Should Gradle wrapper be committed?

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.

Where do Gradle wrapper properties go?

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.


1 Answers

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.

like image 139
Raniz Avatar answered Nov 12 '22 06:11

Raniz