Skip to content

KAFKA-1714: Fix gradle wrapper bootstrapping#6031

Merged
ijuma merged 6 commits intoapache:trunkfrom
granthenke:gradle-wrapper
Nov 21, 2019
Merged

KAFKA-1714: Fix gradle wrapper bootstrapping#6031
ijuma merged 6 commits intoapache:trunkfrom
granthenke:gradle-wrapper

Conversation

@granthenke
Copy link
Copy Markdown
Member

@granthenke granthenke commented Dec 13, 2018

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.

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

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.
@granthenke
Copy link
Copy Markdown
Member Author

Note: This pattern has been used successfully on the Apache Kudu project:
https://github.com/apache/kudu/blob/master/java/gradle/wrapper.gradle

@granthenke
Copy link
Copy Markdown
Member Author

Looking at previously closed Gradle patches I see a few folks that have done reviews:
@ijuma @cmccabe @lindong28

Would any of you be able to review this or suggest someone who could?

Comment thread wrapper.gradle
# 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.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you remove the jar too?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The jar shouldn't be removed, just not checked in. The .gitignore entry handles this.

Comment thread wrapper.gradle Outdated
Comment thread wrapper.gradle
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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

@viktorsomogyi viktorsomogyi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed and tried it out. LGTM.

Copy link
Copy Markdown
Member

@ijuma ijuma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR.

Comment thread gradlew
##
## Gradle start up script for UN*X
##
##############################################################################
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, is this script copied from somewhere?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the script that is generated by the gradle wrapper task.

Comment thread wrapper.gradle
task removeWindowsScript(type: Delete) {
delete "$rootDir/gradlew.bat"
}
wrapper.finalizedBy removeWindowsScript
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, people do seem to build on Windows even if we don't support it. Should we keep this?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@granthenke
Copy link
Copy Markdown
Member Author

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

@chbatey
Copy link
Copy Markdown

chbatey commented Nov 20, 2019

👍 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

Copy link
Copy Markdown
Member

@ijuma ijuma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ijuma ijuma merged commit 09f700a into apache:trunk Nov 21, 2019
ijuma pushed a commit that referenced this pull request Nov 21, 2019
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
ijuma pushed a commit that referenced this pull request Nov 21, 2019
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
ijuma pushed a commit that referenced this pull request Nov 21, 2019
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
ijuma pushed a commit that referenced this pull request Nov 21, 2019
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
ijuma pushed a commit that referenced this pull request Nov 21, 2019
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
ijuma pushed a commit that referenced this pull request Nov 21, 2019
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
ijuma pushed a commit that referenced this pull request Nov 21, 2019
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
ijuma added a commit to confluentinc/kafka-streams-examples that referenced this pull request Apr 21, 2020
…invocation of `gradle`

See apache/kafka#7677 for more details with regards to
the former and apache/kafka#6031 with regards to the latter.
ijuma added a commit to confluentinc/kafka-streams-examples that referenced this pull request Apr 21, 2020
…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.
hachikuji pushed a commit to confluentinc/kafka that referenced this pull request Jun 2, 2020
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
hachikuji pushed a commit to confluentinc/kafka that referenced this pull request Jul 9, 2020
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants