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

'Go To Type ' not working for srcDirs with include #421

Open
markokaestner opened this issue Mar 26, 2019 · 15 comments
Open

'Go To Type ' not working for srcDirs with include #421

markokaestner opened this issue Mar 26, 2019 · 15 comments

Comments

@markokaestner
Copy link

markokaestner commented Mar 26, 2019

I have a multi-module project which has only one src directory for all subprojects. The srcDirs then use an include to select the correct packages:

subprojects {
    sourceSets {
        main {
            java {
                srcDirs = ["${rootDir}/src/main/java"]
                include 'some/common/prefix/' + project.name.replace('-', '/') + '/**'
            }
        }
    }
}

This works as far as all packages, that are not included, are empty in the project view. Java files in included packages are correctly shown in the project view.

If I try to open a class that I can clearly see in the project view via "Go To Type", the class is not found. This also affects imports of classes from the same subproject. The imports are highlighted with "package not found".

issue

@kelemen
Copy link
Owner

kelemen commented Mar 27, 2019

I have tried this and I'm not experiencing the same issue. Do you have a sample project to try this with?

@markokaestner
Copy link
Author

You can find a sample project here.

@kelemen
Copy link
Owner

kelemen commented Mar 28, 2019

I'm assuming this has something to do with the modules. Does it happen if you disable modules in the project properties? (Java Modules/Allow Modules)

@kelemen
Copy link
Owner

kelemen commented Mar 28, 2019

Since disabling modules is a bit of a hack, you might want to restart NB after that.

@markokaestner
Copy link
Author

markokaestner commented Mar 29, 2019

I updated to the latest plugin version and disabled the java modules globally. But as the project is only JDK8, that had no effect. It's still not working.

I checked the logs and found these entries:

WARNING [org.netbeans.modules.project.ui.OpenProjectList]: Project dir with file:/SOME_PATH/nb-gradle-test/a/ not found!
WARNING [org.netbeans.modules.localhistory]: source group a returned null root folder
...
WARNING [org.netbeans.modules.java.source.indexing.JavaIndex]: Ignoring root with no ClassPath: /home/mk/Projekte/nb-gradle-test/src/main/java

The rest of the logs looks unsuspicious

@kelemen
Copy link
Owner

kelemen commented Mar 30, 2019

Does "/SOME_PATH/nb-gradle-test/a/" actually exist? Can you still try disabling modules to check if there is really nothing because of that (to check if the module support does not create a problem in your case for some weird reason)?

@markokaestner
Copy link
Author

The path "/SOME_PATH/nb-gradle-test/a/" does exist. It's an empty folder which exists for each of the submodules. Java 9 modules have been disabled in global settings and NB was restarted. The issue still persists.

@kelemen
Copy link
Owner

kelemen commented Apr 2, 2019

I'm not sure because it works for me fine. Have you tried removing the NB cache?

@markokaestner
Copy link
Author

Yes I tried all of that. I removed the nb cache as well as the .gradle folder and the .nb-gradle settings file. I also tried it with NB 8.2 - 10.0.

Can you please try to add a new class to one of the subprojects. That should break the demo project for sure.

@kelemen
Copy link
Owner

kelemen commented Apr 3, 2019

Hmmm, now I can reproduce it in NB 8.2 (without adding new classes) but not in 10. I'll try to find out what might be happening.

@kelemen
Copy link
Owner

kelemen commented Apr 3, 2019

The NB repo says its temporary unavailable, so I can't build the plugin for 8.2 at the moment. I'll check it tomorrow.

@kelemen
Copy link
Owner

kelemen commented Apr 4, 2019

I think I know what the issue is (not 100% because I didn't track down the issue to what actually happening in NB). That is, this is the problem: Your project has the same source root (regardless that it is distinctly filtered) for multiple projects and this confuses NB, because NB requires ownership for files and dirs, and now multiple projects provides source roots with the same root. So, the ownership is ambigous, and can (and does) confuse NB completely. I don't think this is fixable, because this is such an integral part of the NB infrastructure. So, I recommend you not share source root between projects if possible but if you need it shared then have a 3rd project which includes both (this I have done with buildSrc, and should work).

@markokaestner
Copy link
Author

That solves the issue although I don't like to have IDE specific settings in the gradle files especially when working in a team where different iDEs are in use. But that's at least better than being forced to switch to eclipse. Thanks for your help.

@kelemen
Copy link
Owner

kelemen commented Apr 12, 2019

You can always use an init script and pass an afterEvaluate there (you can check for some properties, if you are in the right build, or check for the presence of an excluded build script, and apply that).

@markokaestner
Copy link
Author

I was looking into that but did not find a reliable way to add an addition subproject from the init.gradle without any modifications to the project gradle files. Any hints would be appreciated.

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

2 participants