KAFKA-1714: Fix gradle wrapper bootstrapping#6031
Conversation
Given we need to follow the Apache rule of not checking any binaries into the source code, Kafka has always had a bit of a tricky Gradle bootstrap. Using ./gradlew as users expect doesn’t work and a local and compatible version of Gradle was required to generate the wrapper first. This patch changes the behavior of the wrapper task to instead generate a gradlew script that can bootstrap the jar itself. Additionally it adds a license, removes the bat script, and handles retries. The documentation in the readme was also updated. Going forward patches that upgrade gradle should run `gradle wrapper` before checking in the change. With this change users using ./gradlew can be sure they are always building with the correct version of Gradle.
|
Note: This pattern has been used successfully on the Apache Kudu project: |
|
Looking at previously closed Gradle patches I see a few folks that have done reviews: Would any of you be able to review this or suggest someone who could? |
| # limitations under the License.""" | ||
|
|
||
| // Custom task to inject support for downloading the gradle wrapper jar if it doesn't exist. | ||
| // This allows us to avoid checking in the jar to our repository. |
There was a problem hiding this comment.
Did you remove the jar too?
There was a problem hiding this comment.
The jar shouldn't be removed, just not checked in. The .gitignore entry handles this.
| def wrapperJarPath = wrapperBasePath + "/gradle-wrapper.jar" | ||
|
|
||
| // Add a trailing zero to the version if needed. | ||
| def fullVersion = project.gradleVersion.count(".") == 1 ? "${project.gradleVersion}.0" : versions.gradle |
There was a problem hiding this comment.
If I understand correctly here you would use the project's gradle version instead of the distributionUrl in the gradle-wrapper.properties, right? That would make sure to always use the correct version of gradle.
I think perhaps we could make a comment there that people should not expect the distributionUrl to work anymore, neither gradle wrapper --gradle-version x.y as they'd expect.
There was a problem hiding this comment.
All of those things would still work as expected and as it did before.
What this patch does is edit the gradlew script to support downloading the wrapper jar if it doesn't exist. That jar is technically gradle version agnostic. It hasn't changed for a very long time.
Running the gradle wrapper task will still output a gradle/wrapper/gradle-wrapper.properties file and passing --gradle-version x.y.x, distribution-type=foo or --gradle-distribution-url=bar will all still override the task defaults.
viktorsomogyi
left a comment
There was a problem hiding this comment.
I reviewed and tried it out. LGTM.
| ## | ||
| ## Gradle start up script for UN*X | ||
| ## | ||
| ############################################################################## |
There was a problem hiding this comment.
Out of curiosity, is this script copied from somewhere?
There was a problem hiding this comment.
This is the script that is generated by the gradle wrapper task.
| task removeWindowsScript(type: Delete) { | ||
| delete "$rootDir/gradlew.bat" | ||
| } | ||
| wrapper.finalizedBy removeWindowsScript |
There was a problem hiding this comment.
Hmm, people do seem to build on Windows even if we don't support it. Should we keep this?
There was a problem hiding this comment.
Users could still build with a local install of gradle, they just can't use the wrapper. Given we don't support it, I don't want to do more work to make it easier.
There was a problem hiding this comment.
Does that mean that we need different instructions for Windows? Given the number of complaints we get from Windows users, I think we should not make things worse for them if we can avoid it. If you have concerns about this working for Windows users, we could simply state in the README that they have to do it the old way.
|
@ijuma I still plan to create a separate patch to update the readme with more docs around using gradle and the wrapper. I just haven't had time. |
|
👍 as it stands bootstrapping from the latest version of gradle doesn't work so I needed to delete parts of the build.gradle file to get the latest gradle to generate a gradle wrapper |
Given we need to follow the Apache rule of not checking any binaries into the source code, Kafka has always had a bit of a tricky Gradle bootstrap. Using ./gradlew as users expect doesn’t work and a local and compatible version of Gradle was required to generate the wrapper first. This patch changes the behavior of the wrapper task to instead generate a gradlew script that can bootstrap the jar itself. Additionally it adds a license, removes the bat script, and handles retries. The documentation in the readme was also updated. Going forward patches that upgrade gradle should run `gradle wrapper` before checking in the change. With this change users using ./gradlew can be sure they are always building with the correct version of Gradle. Reviewers: Viktor Somogyi <viktorsomogyi@gmail.com>, Ismael Juma <ismael@juma.me.uk
Given we need to follow the Apache rule of not checking any binaries into the source code, Kafka has always had a bit of a tricky Gradle bootstrap. Using ./gradlew as users expect doesn’t work and a local and compatible version of Gradle was required to generate the wrapper first. This patch changes the behavior of the wrapper task to instead generate a gradlew script that can bootstrap the jar itself. Additionally it adds a license, removes the bat script, and handles retries. The documentation in the readme was also updated. Going forward patches that upgrade gradle should run `gradle wrapper` before checking in the change. With this change users using ./gradlew can be sure they are always building with the correct version of Gradle. Reviewers: Viktor Somogyi <viktorsomogyi@gmail.com>, Ismael Juma <ismael@juma.me.uk
Given we need to follow the Apache rule of not checking any binaries into the source code, Kafka has always had a bit of a tricky Gradle bootstrap. Using ./gradlew as users expect doesn’t work and a local and compatible version of Gradle was required to generate the wrapper first. This patch changes the behavior of the wrapper task to instead generate a gradlew script that can bootstrap the jar itself. Additionally it adds a license, removes the bat script, and handles retries. The documentation in the readme was also updated. Going forward patches that upgrade gradle should run `gradle wrapper` before checking in the change. With this change users using ./gradlew can be sure they are always building with the correct version of Gradle. Reviewers: Viktor Somogyi <viktorsomogyi@gmail.com>, Ismael Juma <ismael@juma.me.uk
Given we need to follow the Apache rule of not checking any binaries into the source code, Kafka has always had a bit of a tricky Gradle bootstrap. Using ./gradlew as users expect doesn’t work and a local and compatible version of Gradle was required to generate the wrapper first. This patch changes the behavior of the wrapper task to instead generate a gradlew script that can bootstrap the jar itself. Additionally it adds a license, removes the bat script, and handles retries. The documentation in the readme was also updated. Going forward patches that upgrade gradle should run `gradle wrapper` before checking in the change. With this change users using ./gradlew can be sure they are always building with the correct version of Gradle. Reviewers: Viktor Somogyi <viktorsomogyi@gmail.com>, Ismael Juma <ismael@juma.me.uk
Given we need to follow the Apache rule of not checking any binaries into the source code, Kafka has always had a bit of a tricky Gradle bootstrap. Using ./gradlew as users expect doesn’t work and a local and compatible version of Gradle was required to generate the wrapper first. This patch changes the behavior of the wrapper task to instead generate a gradlew script that can bootstrap the jar itself. Additionally it adds a license, removes the bat script, and handles retries. The documentation in the readme was also updated. Going forward patches that upgrade gradle should run `gradle wrapper` before checking in the change. With this change users using ./gradlew can be sure they are always building with the correct version of Gradle. Reviewers: Viktor Somogyi <viktorsomogyi@gmail.com>, Ismael Juma <ismael@juma.me.uk
Given we need to follow the Apache rule of not checking any binaries into the source code, Kafka has always had a bit of a tricky Gradle bootstrap. Using ./gradlew as users expect doesn’t work and a local and compatible version of Gradle was required to generate the wrapper first. This patch changes the behavior of the wrapper task to instead generate a gradlew script that can bootstrap the jar itself. Additionally it adds a license, removes the bat script, and handles retries. The documentation in the readme was also updated. Going forward patches that upgrade gradle should run `gradle wrapper` before checking in the change. With this change users using ./gradlew can be sure they are always building with the correct version of Gradle. Reviewers: Viktor Somogyi <viktorsomogyi@gmail.com>, Ismael Juma <ismael@juma.me.uk
Given we need to follow the Apache rule of not checking any binaries into the source code, Kafka has always had a bit of a tricky Gradle bootstrap. Using ./gradlew as users expect doesn’t work and a local and compatible version of Gradle was required to generate the wrapper first. This patch changes the behavior of the wrapper task to instead generate a gradlew script that can bootstrap the jar itself. Additionally it adds a license, removes the bat script, and handles retries. The documentation in the readme was also updated. Going forward patches that upgrade gradle should run `gradle wrapper` before checking in the change. With this change users using ./gradlew can be sure they are always building with the correct version of Gradle. Reviewers: Viktor Somogyi <viktorsomogyi@gmail.com>, Ismael Juma <ismael@juma.me.uk
…invocation of `gradle` See apache/kafka#7677 for more details with regards to the former and apache/kafka#6031 with regards to the latter.
…invocation of `gradle` (#329) See apache/kafka#7677 for more details with regards to the former and apache/kafka#6031 with regards to the latter.
Given we need to follow the Apache rule of not checking any binaries into the source code, Kafka has always had a bit of a tricky Gradle bootstrap. Using ./gradlew as users expect doesn’t work and a local and compatible version of Gradle was required to generate the wrapper first. This patch changes the behavior of the wrapper task to instead generate a gradlew script that can bootstrap the jar itself. Additionally it adds a license, removes the bat script, and handles retries. The documentation in the readme was also updated. Going forward patches that upgrade gradle should run `gradle wrapper` before checking in the change. With this change users using ./gradlew can be sure they are always building with the correct version of Gradle. Reviewers: Viktor Somogyi <viktorsomogyi@gmail.com>, Ismael Juma <ismael@juma.me.uk
Given we need to follow the Apache rule of not checking any binaries into the source code, Kafka has always had a bit of a tricky Gradle bootstrap. Using ./gradlew as users expect doesn’t work and a local and compatible version of Gradle was required to generate the wrapper first. This patch changes the behavior of the wrapper task to instead generate a gradlew script that can bootstrap the jar itself. Additionally it adds a license, removes the bat script, and handles retries. The documentation in the readme was also updated. Going forward patches that upgrade gradle should run `gradle wrapper` before checking in the change. With this change users using ./gradlew can be sure they are always building with the correct version of Gradle. Reviewers: Viktor Somogyi <viktorsomogyi@gmail.com>, Ismael Juma <ismael@juma.me.uk
Given we need to follow the Apache rule of not checking
any binaries into the source code, Kafka has always had
a bit of a tricky Gradle bootstrap.
Using ./gradlew as users expect doesn’t work and a
local and compatible version of Gradle was required to
generate the wrapper first.
This patch changes the behavior of the wrapper task to
instead generate a gradlew script that can bootstrap the
jar itself. Additionally it adds a license, removes the bat
script, and handles retries.
The documentation in the readme was also updated.
Going forward patches that upgrade gradle should run
gradle wrapperbefore checking in the change.With this change users using ./gradlew can be sure they
are always building with the correct version of Gradle.
Committer Checklist (excluded from commit message)