-
Notifications
You must be signed in to change notification settings - Fork 401
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
Check Gradle compatibility when importing fails #1965
Conversation
7467d15
to
a68bb65
Compare
Signed-off-by: Shi Chen <[email protected]>
fd266c1
to
50cba35
Compare
org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/managers/ProjectsManager.java
Outdated
Show resolved
Hide resolved
GradleBuild gradleBuild = GradleCore.getWorkspace().createBuild(build); | ||
try { | ||
gradleBuild.withConnection(connection -> { | ||
connection.newBuild().forTasks("wrapper").run(); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
...dt.ls.core/src/org/eclipse/jdt/ls/core/internal/managers/GradleCompatibilityErrorMarker.java
Outdated
Show resolved
Hide resolved
...se.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/managers/GradleCompatibilityChecker.java
Outdated
Show resolved
Hide resolved
...eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/managers/GradleProjectImporter.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Shi Chen <[email protected]>
Signed-off-by: Shi Chen <[email protected]>
test this please |
org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/ResourceUtils.java
Outdated
Show resolved
Hide resolved
...se.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/managers/GradleCompatibilityChecker.java
Outdated
Show resolved
Hide resolved
...eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/managers/GradleProjectImporter.java
Outdated
Show resolved
Hide resolved
...eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/managers/GradleProjectImporter.java
Outdated
Show resolved
Hide resolved
...eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/managers/GradleProjectImporter.java
Outdated
Show resolved
Hide resolved
@@ -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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in 87298b4
Signed-off-by: Shi Chen <[email protected]>
Signed-off-by: Shi Chen <[email protected]>
...eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/managers/GradleProjectImporter.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Shi Chen <[email protected]>
There was a problem hiding this 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.
related to redhat-developer/vscode-java#2245
Will add unit tests later.
Signed-off-by: Shi Chen [email protected]