“abc.java” can be gotten when handling ModuleB. I check context.fileSystem(), its baseDir is Root/ModuleB. Why files in ModuleA can be gotten in ModuleB?
How can I only get the files in the current module?
the version of SonarQube you are testing your plugin with
the exact interface your Sensor is implementing (ProjectSensor, Sensor, …).
the Sensor descriptor
possibly the entire code of your Sensor
analysis logs in verbose mode
FYI Global/project sensors are called once per project, but “normal” sensors are called once per module. In theory the module sensors should only “see” files of the module.
Thanks for all the details. Unfortunately the predicates hasFilename or hasExtension are broken for multi-module projects (they will return files from all modules, not limited to the current module the Sensor is running for). I created a ticket: https://jira.sonarsource.com/browse/SONAR-12421
If your goal is to query all Java files, I suggest you query directly by language: fs.predicates().hasLanguage("java");
This is more correct because it will handle custom user extensions (even if I admit this is not common in Java to have file extension different than .java).
fs.predicates().hasLanguage("java"); depends on the original java plugin which declares java language.
So if customers don’t install java plugin, my plugin will not work. It isn’t acceptable.
So far, I feel the workaround solution is to compare path prefix to filter files before your jira issues would be done.