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

Disabling maven importer prevents project from being imported at all. #3161

Closed
ethan-vanderheijden opened this issue May 21, 2024 · 5 comments

Comments

@ethan-vanderheijden
Copy link
Contributor

If you disable the maven (or gradle) importer (java.import.maven.enabled), it won't be imported as a maven project, but it also won't be imported as a standard project because it is still detected as a maven project. The project is left in a strange state where every file is marked as a "non-project" file. Is this the desired behavior? Or should it fall back on a standard project importer when the maven importer is disabled?

@snjeza
Copy link
Contributor

snjeza commented May 21, 2024

@ethan-vanderheijden Could you attach a project example?

@ethan-vanderheijden
Copy link
Contributor Author

ethan-vanderheijden commented May 21, 2024

my_project
│   pom.xml
│   
└───src
    └───main
        └───java
            └───my_package
                    Foo.java

Foo.java and pom.xml can both be empty. Disable "java.import.maven.enabled" and run "Java: Clean Java Language Server Workspace". Then, open up Foo.java and you should see the yellow squiggle saying this is a non-project file.

You can force the project to be imported as a standard project in two ways:

  • rename "pom.xml" to anything else
  • create a java file at the project root

If it is supposed to fall back on the standard importer when the maven/gradle importer is disabled, I think the fix is as simple as checking if maven/gradle is disabled here:

return container.append(MavenProjectImporter.POM_FILE).toFile().exists()
|| container.append(GradleProjectImporter.BUILD_GRADLE_DESCRIPTOR).toFile().exists()
|| container.append(GradleProjectImporter.SETTINGS_GRADLE_DESCRIPTOR).toFile().exists()
|| container.append(GradleProjectImporter.BUILD_GRADLE_KTS_DESCRIPTOR).toFile().exists()
|| container.append(GradleProjectImporter.SETTINGS_GRADLE_KTS_DESCRIPTOR).toFile().exists();

@testforstephen
Copy link
Contributor

I don't think this is a typical scenario. The question is why you want to use InvisibleProjectImporter to import your project instead of Maven importer?

@ethan-vanderheijden
Copy link
Contributor Author

We don't support Maven projects in our environment, and I was caught a little off guard when disabling Maven turned everything into non-project files. At first, I thought that falling back to the invisible project importer would allow some language features (e.g. resolving references between files) to start working again, but in retrospect, this doesn't make much sense. After all, if I turn off Maven projects, I should expect that they aren't supported.

@testforstephen
Copy link
Contributor

The lightweight mode ("java.server.launchMode": "LightWeight") can satisfy your need. It can provide reference navigation between your own source code, but it doesn't cover the dependencies.

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

No branches or pull requests

3 participants