Post Project Analysis missing default javaScannerContext

Hello,

My team and I are currently working on a custom SonarQube plugin (with a custom set of rules) and we have the need to use some kind of post project analysis.
However, we are still stuck on it after some research and tests like trying to use the class made for it, PostProjectAnalysisTask, but we can’t manage to catch the javaFileScannerContext when doing a projectAnalysis.
We assume this scanner context is linked with the class we use to create rules : IssuableSubscriptionVisitor.

We are currently using SonarQube version 6.9 but we are planning on updating it. If a fix is possible without updating the plugin, please let us know.

Here are some snippets of our code :

// === Add JavaFileScannerContext ===
context.addExtension(JavaFileScannerContext.class);
// === Add PostProjectAnalysisTask ===
context.addExtension(PostProjectAnalysisTaskJava.class);
ScannerContext scannerContext = context.getProjectAnalysis().getScannerContext();

Best regards

Hi,

Welcome to the community!

Your version is past EOL. You should upgrade to either the latest version or the current LTS at your earliest convenience. Your upgrade path is:

6.9 → 7.9.6 → 8.9.7 → 9.3 (last step optional)

You may find the Upgrade Guide and the LTS-to-LTS Upgrade Notes helpful. If you have questions about upgrading, feel free to open a new thread for that here.

You will find there have been many API changes since 6.9, and I don’t know the answer to your question using the current API. But better to start catching up now than after you’ve written your plugin.

 
Ann