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

Have run configurations and tests use Gradle #1235

Closed
JamesHutchisonCarta opened this issue Jun 8, 2022 · 7 comments
Closed

Have run configurations and tests use Gradle #1235

JamesHutchisonCarta opened this issue Jun 8, 2022 · 7 comments
Labels
enhancement New feature or request

Comments

@JamesHutchisonCarta
Copy link

JamesHutchisonCarta commented Jun 8, 2022

Is your feature request related to a problem? Please describe.
I have a project that uses Gradle. The only way to successfully compile and run it is through Gradle. It would be better if the run configurations and tests would leverage Gradle. As it stands, I do not see a way to run individual tests when your project depends on Gradle other than via the command line.

The current alternative is to use the Gradle extension's task UI. You can choose to run or debug a task, or run it with command line args. This is fine for running pre-made tasks, but clumsy for running tests, and the task UI provides no customization options you can reuse. It also is not intuitive to anyone who is not familiar with Gradle or java projects, and are expecting the project to work like it would in any other language, since it requires ignoring the existing run and test features.

Describe the solution you'd like
We can create Gradle run configurations and also define test behavior. Note, also, different test directories in the same project may have different Gradle tasks. It's also worth calling out that Gradle supports watching file changes, which may be a useful mechanism for automatically running tests.

Describe alternatives you've considered
None.

Other info
The project defines class paths and does not appear to be misconfigured in any obvious way.

@JamesHutchisonCarta JamesHutchisonCarta added the enhancement New feature or request label Jun 8, 2022
@S-p-Ace
Copy link

S-p-Ace commented Dec 22, 2022

I'm also working in a project environment where the applications only successfully launch when executed with Gradle. (though compilation is successful either way)
In my case his is most certainly caused by some missing configuration that is done in the warp/init script deployed with the custom wrapper distribution that is used for the projects.

This is not a problem for IntelliJ IDEA because there it is actually the default behavior to run and test using the build tool in Gradle projects (not changeable in the community edition).
When setting IDEA to run using the IDE, the application produces the exact same error on launch as with VS Code.

Therefore I guess the solution would be to add a new setting to delegate build/run actions to Gradle which should also help with mixed source (Java/Groovy/Kotlin) projects.

@nlaplante
Copy link

This gets my vote. This would be the last detail making me switch to VS Code for Gradle project development

@Spitfire1900
Copy link

To clarify, is this to support a gradle launch configuration in launch.json?

@ItaloBorrelli
Copy link

@Spitfire1900 I won't speak for the rest, but I would assume so. It would be helpful to have a launch type for gradle so one could, say, launch and kill a gradle run, perhaps also attaching a debugger. In my case I am running bnd and an OSGi service. I end up having to setup a preLaunchTask to run gradle then attach a debugger to that for instance. Not sure what this would entail.

@jdneo
Copy link
Member

jdneo commented Oct 10, 2024

We support test delegation now. See microsoft/vscode-java-test#1045 (comment).

Please let me know if you this meet your requirements.

@jdneo jdneo closed this as completed Oct 10, 2024
@ItaloBorrelli
Copy link

That's actually not exactly what I needed, but that is good to know!

In my case I run a web server through OSGi. Specifically I am using Bnd. It is often helpful when running that web server to set breakpoints to debug the launch of my application.

I would say that of the title of the issue "Have run configurations and tests use Gradle" the latter has been absolutely completed, but the former may not be complete, if that's what the original author meant be "run configurations".

@ItaloBorrelli
Copy link

Oh, I do see that I can use a preLaunchTask such as "gradle: project:run.bndrunfile" which probably sufficiently suits my purposes, though an launch configuration type certainly would be good I think anyways.

Thanks @jdneo !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants