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

Cannot see Delegate Test to Gradle option in VS Code #1606

Open
Tracked by #1609
jdneo opened this issue Sep 14, 2024 · 6 comments
Open
Tracked by #1609

Cannot see Delegate Test to Gradle option in VS Code #1606

jdneo opened this issue Sep 14, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@jdneo
Copy link
Member

jdneo commented Sep 14, 2024

          @jdneo I don't see Delegate Test to Gradle option in my VS Code:

Screenshot 2024-09-13 at 17 36 30
Screenshot 2024-09-13 at 17 38 08
Screenshot 2024-09-13 at 17 37 01

Screenshot 2024-09-13 at 17 39 07
Screenshot 2024-09-13 at 17 39 40

Any hints how to enable that feature?

Originally posted by @piotr-rachwalik in microsoft/vscode-java-test#1045 (comment)

@jdneo jdneo added the bug Something isn't working label Sep 14, 2024
@piotr-rachwalik
Copy link

@jdneo I checked and this feature works on my Windows machine. On my Mac, it doesn't work. Perhaps I need to reinstall the VS Code to make this work.

@piotr-rachwalik
Copy link

@jdneo I've changed this setting
Screenshot 2024-09-16 at 09 48 07
and now I can see the Delegate to Gradle test option.

But when I try to run the test, I'm getting this error:

Project is not a Gradle build server project: <my_project>
java.lang.IllegalArgumentException: Project is not a Gradle build server project: <my_project>
	at com.microsoft.gradle.bs.importer.handler.GradleDelegateCommandHandler.executeCommand(GradleDelegateCommandHandler.java:40)
	at org.eclipse.jdt.ls.core.internal.handlers.WorkspaceExecuteCommandHandler$1.run(WorkspaceExecuteCommandHandler.java:230)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)
	at org.eclipse.jdt.ls.core.internal.handlers.WorkspaceExecuteCommandHandler.executeCommand(WorkspaceExecuteCommandHandler.java:220)
	at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$4(JDTLanguageServer.java:606)
	at org.eclipse.jdt.ls.core.internal.BaseJDTLanguageServer.lambda$0(BaseJDTLanguageServer.java:87)
	at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:646)
	at java.base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:483)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)

I also tried with on/off setting of build gradle server, but the error is still the same:
Screenshot 2024-09-16 at 09 55 31

@piotr-rachwalik
Copy link

@jdneo perhaps it is because, the delegate test to gradle option does not honor the settings.gradle, where I have the settings:

rootProject.name = '<root_project_name>'
def subProjectsDir = new File(rootDir, 'subprojects')
fileTree(subProjectsDir) {
  include '**/build.gradle'
  exclude '**/bin/**/build.gradle'
  exclude '**/build/**/build.gradle'
  exclude '**/src/**/build.gradle'
}.collect {
  subProjectsDir.toPath().relativize(it.parentFile.toPath()).toString()
}.each {
  def projectName = ':' + rootProject.name + '-' + it.replace(File.separator, '-')
  include(projectName)
  project(projectName).projectDir = new File(subProjectsDir, it)
}

Please note that when I use Eclipse IDE with Buildship then I'm able to run a test using gradle.

@jdneo
Copy link
Member Author

jdneo commented Sep 17, 2024

@piotr-rachwalik Thank you for sharing.

The error that Project is not a Gradle build server project is caused by the fact that the project is not imported by gradle build server, but buildship instead. There are several cases that will lead to this.

Have you tried running Java: Clean Java Language Server Workspace? If does vscode command does not help, would you mind sharing the folder structure of your project?

@jdneo jdneo changed the title @jdneo I don't see Delegate Test to Gradle option in my VS Code: Cannot see Delegate Test to Gradle option in VS Code Sep 17, 2024
@piotr-rachwalik
Copy link

@jdneo I've tried running Java: Clean Java Language Server Workspace but it didn't help.
Here is my folder structure:

/build.gradle
/settings.gradle
/.gitignore
/subprojects/
   /project1/src/
                       main/java/
                       main/resources/
                       test/java/
                       test/resources/
                       build.gradle

and so we have multiple gradle projects in the subprojects directory.

@piotr-rachwalik
Copy link

@jdneo I think the root cause might be the ./gradlew eclipse command that I'm using to make my project usable in Eclipse / VS Code. Without that, the dependencies are not resolved, etc.
I think that command builds the projects into Buildship readable format.

@J44951 J44951 mentioned this issue Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants