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

java.project.exclusion is not working as expected #2075

Closed
jdneo opened this issue Aug 19, 2021 · 1 comment · Fixed by eclipse-jdtls/eclipse.jdt.ls#1850
Closed

java.project.exclusion is not working as expected #2075

jdneo opened this issue Aug 19, 2021 · 1 comment · Fixed by eclipse-jdtls/eclipse.jdt.ls#1850

Comments

@jdneo
Copy link
Collaborator

jdneo commented Aug 19, 2021

Steps to repro:

  1. Use the project: https://github.com/eclipse/eclipse.jdt.ls/tree/master/org.eclipse.jdt.ls.tests/projects/maven/multimodule,
  2. Before open it in VS Code, set the java.import.exlusions in settings.json:
"java.import.exclusions": [
    "**",
    "!**/module1/**"
]
  1. Open it in VS Code
Expected result

modules under **/module1/** gets imported

Actual result

no projects imported into workspace

Investigation of the root cause

In the code here, we will skip subtree scan if a folder is excluded.

In the above case, since we have **/* in the setting, all the sub folder are ignored even we have the negative (!) pattern in the exclusion setting.

It seems that having the early return logic here makes the negative pattern never takes effect.

Can we just exclude the unwanted folders?

What if we set the java.import.exclusions to:

"java.import.exclusions": [
    "**/module2/**",
    "**/module3/**",
]

The result is that all the modules are still get imported into the workspace. This is because the MavenImporter will collect all the related projects from the scanning result, as long as the parent pom is included, all the child poms will be included as well.

@jdneo
Copy link
Collaborator Author

jdneo commented Aug 19, 2021

One solution I can think of is to scan twice when java.import.exclusions contains negative patterns.

  1. The first scan includes those folders which match the negative patterns
  2. Then remove those negative patterns and leave all the positive exclusion and do a second scan

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

Successfully merging a pull request may close this issue.

2 participants