SonarLint configuration APIs for custom Intellij plugin


I am creating an Intellij plugin which will help my fellow developers create our proprietary project types in Intellij. After my plugin successfully creates the project(s) , I want to configure SonarLint so that the developers can start using it immediately instead of having to configure it themselves.
My configuration worksflow will be as follows:

1)Create and complete our proprietary Java project type in the Intellij
2)Install SonarLint in the Intellij
3)Bind SonarQube/SonarLint by providing the appropriate URL, username, password. We basically already have SonarQube/SonarCloud project. I want to bind this cloud project to local workspace project

Do you provide APIs to perform steps 2 and 3 ? I don’t see 2) being big deal because I can force developers to install SonarLint even before they can start using my plugin. Step 3) is really where I am stuck right now.

Hello @vishalkhobare,

Firstly, SonarLint does not expose any “official” API to achieve that, and we don’t plan to do so anytime soon. I think it’s the first time we get such a request.

That said, I think there could still be a way for you to achieve what you want. Disclaimer: I never tried.

This doc page explains how to declare a dependency to another plugin from your plugin. With this you should be able to tell IntelliJ that your plugin depends on SonarLint, and you can then use it as a library. If you browse the code, you should be able to find classes that let you create the connection and bind a project.

Please note that the code you might rely on is not considered as an API, so it might change in the future without notice.

I’m curious if this approach could work, so give us some news!

1 Like