Skip to content

Gradle projects are not recognized correctly #3995

Closed

Description

@GMProg

After updating to 1.41.0 my gradle projects were not built correctly, in fact, not built using gradle, the indicator was that only bin folder was created during the build process, although gradle's default is the build folder. I tried setting the "java.import.gradle.enabled" variable to true, but it didn't help, also when I checked the debug console I didn't see the usual gradle build process.

I found nothing that I could make the current version to build with gradle, after downgrading it started to work just fine again.

Activity

  1. Detelin-Yordanov-IBM commented on Mar 31, 2025

    @Detelin-Yordanov-IBM

    We are having the same issue, it is as if suddenly Gradle projects are imported with Buildship rather than Gradle build server.

    Explicitly configuring Build server using "java.gradle.buildServer.enabled": "on" in project's settings.json does not seem to have any effect.
    There are no errors related to build server not able to start or anything similar and the Build server importer seem to be started successfully (in fact it is the older version we have been using), then suddenly project import is initiated with Buildship and it fails:

    !ENTRY org.eclipse.jdt.ls.core 1 0 2025-03-31 15:34:18.257
    !MESSAGE Started reference:file:/c:/Users/myUser/.vscode/extensions/vscjava.vscode-gradle-3.16.4/server/com.microsoft.gradle.bs.importer-0.5.3.jar
    
    ...
    !ENTRY org.eclipse.buildship.core 2 1 2025-03-31 15:34:22.761
    !MESSAGE Synchronize project num_vscode failed due to an error while importing the root project.
    !STACK 0
    org.eclipse.buildship.core.internal.ImportRootProjectException: org.eclipse.buildship.core.internal.GradlePluginsRuntimeException: Cannot add nature org.eclipse.buildship.core.gradleprojectnature to Eclipse project num_vscode.
    	at org.eclipse.buildship.core.internal.workspace.ImportRootProjectOperation.run(ImportRootProjectOperation.java:53)
    	at org.eclipse.buildship.core.internal.DefaultGradleBuild$SynchronizeOperation.runInToolingApi(DefaultGradleBuild.java:230)
    	at org.eclipse.buildship.core.internal.operation.DefaultToolingApiOperationManager$WorkspaceRunnableAdapter.run(DefaultToolingApiOperationManager.java:58)
    	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2457)
    	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2482)
    	at org.eclipse.buildship.core.internal.operation.DefaultToolingApiOperationManager.run(DefaultToolingApiOperationManager.java:39)
    	at org.eclipse.buildship.core.internal.DefaultGradleBuild$SynchronizeOperation.run(DefaultGradleBuild.java:197)
    	at org.eclipse.buildship.core.internal.DefaultGradleBuild.synchronize(DefaultGradleBuild.java:105)
    	at org.eclipse.buildship.core.internal.DefaultGradleBuild.synchronize(DefaultGradleBuild.java:86)
    	at org.eclipse.jdt.ls.core.internal.managers.GradleProjectImporter.startSynchronization(GradleProjectImporter.java:491)
    	at org.eclipse.jdt.ls.core.internal.managers.GradleProjectImporter.importDir(GradleProjectImporter.java:367)
    	at org.eclipse.jdt.ls.core.internal.managers.GradleProjectImporter.importToWorkspace(GradleProjectImporter.java:240)
    	at org.eclipse.jdt.ls.core.internal.managers.ProjectsManager.importProjects(ProjectsManager.java:164)
    	at org.eclipse.jdt.ls.core.internal.managers.ProjectsManager.initializeProjects(ProjectsManager.java:126)
    	at org.eclipse.jdt.ls.core.internal.handlers.InitHandler$1.runInWorkspace(InitHandler.java:263)
    	at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:43)
    	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
    Caused by: org.eclipse.buildship.core.internal.GradlePluginsRuntimeException: Cannot add nature org.eclipse.buildship.core.gradleprojectnature to Eclipse project num_vscode.
    	at org.eclipse.buildship.core.internal.workspace.DefaultWorkspaceOperations.addNature(DefaultWorkspaceOperations.java:230)
    	at org.eclipse.buildship.core.internal.workspace.ImportRootProjectOperation.importRootProject(ImportRootProjectOperation.java:105)
    	at org.eclipse.buildship.core.internal.workspace.ImportRootProjectOperation$1.run(ImportRootProjectOperation.java:68)
    	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2457)
    	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2477)
    	at org.eclipse.buildship.core.internal.workspace.ImportRootProjectOperation.runInWorkspace(ImportRootProjectOperation.java:58)
    	at org.eclipse.buildship.core.internal.workspace.ImportRootProjectOperation.run(ImportRootProjectOperation.java:51)
    	... 16 more
    Caused by: org.eclipse.core.internal.resources.ResourceException: Could not set the project description for 'num_vscode' because the project description file (.project) is out of sync with the file system.
    	at org.eclipse.core.internal.resources.Project.setDescription(Project.java:1344)
    	at org.eclipse.core.internal.resources.Project.setDescription(Project.java:1378)
    	at org.eclipse.buildship.core.internal.workspace.DefaultWorkspaceOperations.addNature(DefaultWorkspaceOperations.java:222)
    	... 22 more
    Caused by: java.lang.Exception: Could not set the project description for 'num_vscode' because the project description file (.project) is out of sync with the file system.
    	at org.eclipse.core.internal.resources.ResourceException.provideStackTrace(ResourceException.java:42)
    	at org.eclipse.core.internal.resources.ResourceException.<init>(ResourceException.java:38)
    	... 25 more
    

    We only upgraded to 1.41 version to get a solution for eclipse-jdtls/eclipse.jdt.ls#3371 but it seems we cannot use this version now.

  2. rgrunber commented on Mar 31, 2025

    @rgrunber
    Member

    Does anyone have a simple project that reproduces this that can be shared ? If things are falling back to buildship, then likely it's an issue with https://github.com/microsoft/vscode-gradle/.

  3. rgrunber commented on Apr 1, 2025

    @rgrunber
    Member

    Can you try the latest pre-release build of vscode-java, v1.42.2025040104, which should contain the fix.

    @testforstephen @snjeza , if you have time. Can you verify that with 1.41.0, the gradle build server does not load the project (eg. for me, I just noticed that source files had no semantic tokens coming from the server), and that the above pre-release build resolves the issue for you as well ? I can push out a bug fix for this if so.

  4. pinned this issue on Apr 1, 2025
  5. Detelin-Yordanov-IBM commented on Apr 1, 2025

    @Detelin-Yordanov-IBM

    Can you try the latest pre-release build of vscode-java, v1.42.2025040104, which should contain the fix.

    We tried it and this particular issue seem to be resolved, e.g. Java extension is able to use Gradle build server. However we are seeing other seemingly serious failures, for example:

    org.osgi.framework.BundleException: Could not resolve module: com.microsoft.java.test.plugin [117]
      Unresolved requirement: Require-Bundle: org.jacoco.core; bundle-version="0.8.12"
        -> Bundle-SymbolicName: org.jacoco.core; bundle-version="0.8.12.202403310830"
           org.jacoco.core [116]
             Unresolved requirement: Import-Package: org.objectweb.asm; version="[9.7.0,9.8.0)"
    

    Then a lot of NoSuchMethod errors:

    java.lang.NoSuchMethodError: 'java.util.List org.eclipse.jdt.internal.core.JavaProject.internalDefaultRootModules(java.lang.Iterable, java.util.function.Function, java.util.function.Function)'
    	at com.microsoft.java.builder.jdtbuilder.ClasspathJrt.selectModules(ClasspathJrt.java:278)
    
    

    This looks similar to microsoft/vscode-gradle#1651

    Here is the log: .log

  6. rgrunber commented on Apr 1, 2025

    @rgrunber
    Member
    org.osgi.framework.BundleException: Could not resolve module: com.microsoft.java.test.plugin [117]
      Unresolved requirement: Require-Bundle: org.jacoco.core; bundle-version="0.8.12"
        -> Bundle-SymbolicName: org.jacoco.core; bundle-version="0.8.12.202403310830"
           org.jacoco.core [116]
             Unresolved requirement: Import-Package: org.objectweb.asm; version="[9.7.0,9.8.0)"
    

    I see this as well. Looks like they updated to ASM 9.8.0 upstream and we started to pick it up at https://download.eclipse.org/jdtls/snapshots/repository/1.47.0.202503311844/plugins/ (our pre-release builds) . https://github.com/microsoft/vscode-java-test/blob/dfeddc4e31ec053eefb88921060ac4b35956817a/java-extension/com.microsoft.java.test.target/com.microsoft.java.test.tp.target#L29-L33 needs to be updated to include jacoco/jacoco#1862 (no release yet though) as soon as it's released.

    Then a lot of NoSuchMethod errors:

    java.lang.NoSuchMethodError: 'java.util.List org.eclipse.jdt.internal.core.JavaProject.internalDefaultRootModules(java.lang.Iterable, java.util.function.Function, java.util.function.Function)'
    	at com.microsoft.java.builder.jdtbuilder.ClasspathJrt.selectModules(ClasspathJrt.java:278)
    

    This looks similar to microsoft/vscode-gradle#1651

    Here is the log: .log

    This should be fixed by vscode-gradle 3.17.2025032611, but you would need to switch to a pre-release version there as well.

  7. added this to the Early April 2025 milestone on Apr 1, 2025
  8. rgrunber commented on Apr 2, 2025

    @rgrunber
    Member

    vscode-java version 1.41.1 should fix the main issue (projects not being recognized). The other issues regarding vscode-gradle (fix in pre-release, not in a release yet), and vscode-java-test (no fix yet, waiting on dependency update) need to be fixed in their respective extensions.

  9. Detelin-Yordanov-IBM commented on Apr 3, 2025

    @Detelin-Yordanov-IBM
    org.osgi.framework.BundleException: Could not resolve module: com.microsoft.java.test.plugin [117]
      Unresolved requirement: Require-Bundle: org.jacoco.core; bundle-version="0.8.12"
        -> Bundle-SymbolicName: org.jacoco.core; bundle-version="0.8.12.202403310830"
           org.jacoco.core [116]
             Unresolved requirement: Import-Package: org.objectweb.asm; version="[9.7.0,9.8.0)"
    

    I see this as well. Looks like they updated to ASM 9.8.0 upstream and we started to pick it up at https://download.eclipse.org/jdtls/snapshots/repository/1.47.0.202503311844/plugins/ (our pre-release builds) . https://github.com/microsoft/vscode-java-test/blob/dfeddc4e31ec053eefb88921060ac4b35956817a/java-extension/com.microsoft.java.test.target/com.microsoft.java.test.tp.target#L29-L33 needs to be updated to include jacoco/jacoco#1862 (no release yet though) as soon as it's released.

    Then a lot of NoSuchMethod errors:

    java.lang.NoSuchMethodError: 'java.util.List org.eclipse.jdt.internal.core.JavaProject.internalDefaultRootModules(java.lang.Iterable, java.util.function.Function, java.util.function.Function)'
    	at com.microsoft.java.builder.jdtbuilder.ClasspathJrt.selectModules(ClasspathJrt.java:278)
    

    This looks similar to microsoft/vscode-gradle#1651
    Here is the log: .log

    This should be fixed by vscode-gradle 3.17.2025032611, but you would need to switch to a pre-release version there as well.

    I'm testing VS Code Gradle latest pre-release version (3.17.2025040205) hoping to get a resolution for microsoft/vscode-gradle#1651 however I'm getting other problem:

    java.util.concurrent.CompletionException: org.eclipse.lsp4j.jsonrpc.ResponseErrorException: No builders are available to build a model of type 'com.microsoft.java.bs.gradle.model.GradleSourceSets'.
    	at java.base/java.util.concurrent.CompletableFuture.wrapInCompletionException(CompletableFuture.java:323)
    	at java.base/java.util.concurrent.CompletableFuture.reportJoin(CompletableFuture.java:457)
    	at java.base/java.util.concurrent.CompletableFuture.join(CompletableFuture.java:2162)
    	at com.microsoft.gradle.bs.importer.Utils.getBuildTargetsMappedByProjectPath(Utils.java:55)
    	at com.microsoft.gradle.bs.importer.GradleBuildServerProjectImporter.importProjects(GradleBuildServerProjectImporter.java:322)
    	at com.microsoft.gradle.bs.importer.GradleBuildServerProjectImporter.importToWorkspace(GradleBuildServerProjectImporter.java:226)
    	at org.eclipse.jdt.ls.core.internal.managers.ProjectsManager.importProjects(ProjectsManager.java:164)
    	at org.eclipse.jdt.ls.core.internal.managers.ProjectsManager.initializeProjects(ProjectsManager.java:126)
    	at org.eclipse.jdt.ls.core.internal.handlers.InitHandler$1.runInWorkspace(InitHandler.java:263)
    	at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:43)
    	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
    

    I'm testing this together with Language Support for Java 1.41.1. Is this something that I need to report to the VS Code Gradle project?

  10. unpinned this issue on May 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions