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

Check Gradle compatibility when importing fails #1965

Merged

Conversation

CsCherrYY
Copy link
Contributor

@CsCherrYY CsCherrYY commented Dec 8, 2021

compatibility

related to redhat-developer/vscode-java#2245

Will add unit tests later.

Signed-off-by: Shi Chen [email protected]

GradleBuild gradleBuild = GradleCore.getWorkspace().createBuild(build);
try {
gradleBuild.withConnection(connection -> {
connection.newBuild().forTasks("wrapper").run();
Copy link
Contributor

Choose a reason for hiding this comment

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

gradle wrapper --gradle-version 7.3.1 --distribution-type all

You can pass the wrapper version argument in forTasks directly, no need to create "gradle-wrapper.properties" file in advance.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we keep the properties file unchanged and try to execute the wrapper task, the Gradle will try to configure the project with the old Gradle version before executing this task, and it will result in the same compatibility error. So we should modify the properties file manually in advance.

@CsCherrYY
Copy link
Contributor Author

test this please

@@ -387,8 +463,83 @@ public boolean accept(File dir, String name) {
return shouldSynchronize;
}

public static boolean upgradeGradleVersion(String projectDir, IProgressMonitor monitor) {
String newDistributionUrl = String.format("https://services.gradle.org/distributions/gradle-%s-bin.zip", GradleCompatibilityChecker.CURRENT_GRADLE);
Path projectFolder = Paths.get(projectDir);
Copy link
Contributor

Choose a reason for hiding this comment

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

projectDir is passed as a uri string, doesPaths.get(uriString) support uri string?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently it's a path string actually. I'll correct the naming of this variable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed in 87298b4

@rgrunber rgrunber added this to the End January 2022 milestone Jan 19, 2022
Signed-off-by: Shi Chen <[email protected]>
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.

Works for me, and the error marker gets displayed as well.

@testforstephen testforstephen merged commit 8d6dc0e into eclipse-jdtls:master Jan 21, 2022
@CsCherrYY CsCherrYY deleted the cs-gradle-compatibility branch February 9, 2022 02:47
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.

3 participants