Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use wrapper distribution when gradle-wrapper.properties exists. #3012

Merged
merged 1 commit into from
Jan 9, 2024

Conversation

jdneo
Copy link
Contributor

@jdneo jdneo commented Jan 5, 2024

In GradleProjectImporter, the previously implementation will use GradleDistribution.fromBuild() when the gradlew exists.

While checking the source of Gradle, the Gradle tooling api will check gradle/wrapper/gradle-wrapper.properties instead of the gradlew.

See:

This PR changes the logic to use wrapper distribution (GradleDistribution.fromBuild()) when gradle/wrapper/gradle-wrapper.properties exists.

Meanwhile, this PR moves the gradle wrapper jar checksum validation into a non-blocking job, because tooling api will not use that jar to import the project. So, it's not necessary to do it during import synchronized.

Copy link
Contributor

@testforstephen testforstephen left a comment

Choose a reason for hiding this comment

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

LGTM.

Checking the gradle-wrapper.properties file is the correct approach to enable the gradle wrapper importer. This file tells the tooling api where to get the gradle distribution from the distributionUrl. The tooling api will download the distribution using its own download utility. It doesn't depend on the local gradle-wrapper.jar for downloading, so it's ok to move the checksum validator to a separate job.

@testforstephen testforstephen added this to the Early January 2024 milestone Jan 5, 2024
Copy link
Contributor

@snjeza snjeza left a comment

Choose a reason for hiding this comment

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

Meanwhile, this PR moves the gradle wrapper jar checksum validation into a non-blocking job, because tooling api will not use that jar to import the project. So, it's not necessary to do it during import synchronized.

The gradle tooling API doesn't use gradle-wrapper.jar - https://github.com/gradle/gradle/blob/dc132c9b9b14ab88545cdceac90259ecd1ae1198/platforms/core-runtime/wrapper-shared/src/main/java/org/gradle/wrapper/BootstrapMainStarter.java#L45
We could remove the gradle wrapper jar checksum validation.

Copy link
Contributor

@rgrunber rgrunber left a comment

Choose a reason for hiding this comment

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

Feel free to merge when ready. Placing the code into a Job would normally open it up to progress reporting, but since no monitor is used, it should be silent, which is fine.

Update: It does report, but it's nothing major.

[Trace - 17:48:53] Received notification '$/progress'.
Params: {
    "token": "35218318-2d27-46a6-9d55-bf30bd6d7f63",
    "value": {
        "kind": "begin",
        "title": "Validating Gradle wrapper checksum...",
        "message": "Validating Gradle wrapper checksum..."
    }
}


[Trace - 17:49:09] Received notification '$/progress'.
Params: {
    "token": "35218318-2d27-46a6-9d55-bf30bd6d7f63",
    "value": {
        "kind": "end",
        "message": "Validating Gradle wrapper checksum..."
    }
}

Signed-off-by: Sheng Chen <sheche@microsoft.com>
@rgrunber rgrunber merged commit 8d54b96 into eclipse-jdtls:master Jan 9, 2024
7 checks passed
@jdneo jdneo deleted the cs/gradle-importer branch January 11, 2024 03:11
@jdneo
Copy link
Contributor Author

jdneo commented Jan 11, 2024

We could remove the gradle wrapper jar checksum validation.

This requires to remove java.imports.gradle.wrapper.checksums at vscode-java. I think we need to check some data first to see the usage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants