You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Q: Is there a way from my project to programmatically detect that it is in vscode #1155
I have a situation where a Gradle plugin I'm developing needs to take conditional actions depending on whether or not the project in which my Gradle plugin is applied, is currently being edited inside vscode.
I'm wondering if there might be someway for any random Java code that is part of a project, to programmatically detect that the project is currently opened in vscode.
Maybe something like querying the hierarchy of class loaders to see if some class that is only ever loaded by vscode-java is present? Or maybe there is something like a .lock file somewhere that would only exist if vscode-java is editing a specific project? Anything like that?
I realize I could have the code look in the root folder to see if a .vscode folder is there — or something along those lines. But I very often open projects in all of the different Java IDEs at different times. So although the project might be open in IntelliJ at any given time, it would be a false positive in the IntelliJ scenario when the detection code finds a .vscode folder from the previous times I might have edited the project in vscode.
My apologies if I should have asked this in the Buildship project instead. I guess I figured vscode-java had closer ties to the Java Language Server. I was thinking that closeness might give it some kind of knowledge of what classes and such were in play at any given time.
I don't think you will have much success with this. If the plugin recognizes it's running inside jdt-ls, there's no good way to discover that by looking at classloaders. The project would easily get confused and suspect it's being run in eclipse, or equinox.
I'm going to close this, as a gradle plug-in running within jdt-ls is out of scope for vscode-java. Sorry.
Activity
fbricon commentedon Nov 21, 2019
I have no idea. @donat is there a way for Gradle to detect it's running within Buildship?
lingocoder commentedon Nov 21, 2019
Hey Thanks, fbricon
My apologies if I should have asked this in the Buildship project instead. I guess I figured vscode-java had closer ties to the Java Language Server. I was thinking that closeness might give it some kind of knowledge of what classes and such were in play at any given time.
fbricon commentedon Nov 21, 2019
no problem. vscode-java embeds the Java Language Server which embeds Buildship
robstryker commentedon Oct 29, 2026
I don't think you will have much success with this. If the plugin recognizes it's running inside jdt-ls, there's no good way to discover that by looking at classloaders. The project would easily get confused and suspect it's being run in eclipse, or equinox.
I'm going to close this, as a gradle plug-in running within jdt-ls is out of scope for vscode-java. Sorry.