Skip to content

Q: Is there a way from my project to programmatically detect that it is in vscode #1155

Closed

Description

@lingocoder

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.

Environment
  • Operating System: Windows/Linux/Mac OS
  • JDK version: Java 1.5 to Java 13+
  • Visual Studio Code version: 1.40.1 (system setup)
  • Java extension version: 0.53.1
  • Gradle 3.x - 6.x
Steps To Reproduce

Not Applicable

Current Result

Not Applicable

Expected Result

Not Applicable

Additional Informations

Not Applicable

Activity

  1. fbricon commented on Nov 21, 2019

    @fbricon
    Collaborator

    I have no idea. @donat is there a way for Gradle to detect it's running within Buildship?

  2. lingocoder commented on Nov 21, 2019

    @lingocoder
    Author

    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.

  3. fbricon commented on Nov 21, 2019

    @fbricon
    Collaborator

    no problem. vscode-java embeds the Java Language Server which embeds Buildship

  4. robstryker commented on Oct 29, 2026

    @robstryker
    Contributor

    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.

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

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions