Alternative for the deprecated ProjectBuilder class

Hello people at SonarSource!

At my company we have created a plugin for SonarQube which analyses our own product. For some context about our issue. People can model their applications in our product, which then can be executed via another product of ours. The application models are not stored on disk in form of a folder structure, but is stored in a database.

In the plugin we have created, we use the ProjectBuilder class from the org.sonar.api.batch.bootstrap package to create a folder and file structure We parse our application models to create ProjectDefinitions that are based on our own application structure. After we have created the ProjectDefinitions we then create file system structure which represents our application structure.

After the ProjectBuilder has ran, SonarQube will index the created files and we are able to report issues and metrics on the folder and files.

With the ProjectBuilder being deprecated and going to be removed in a further release, we are trying to look for an alternative which we can use to create ProjectDefinitions and file system structure which represent our application structure. Do you have any idea how we can solve this problem?

Terry van der Griend

Hi Terry,

What about doing the same processing your plugin does, but before running the SonarQube scanner? A SonarQube scanner is not supposed to be used as a build pipeline framework. To my point of view, you should try to decouple:

  • prepare your project structure + generate configuration in sonar-project.properties
  • run the SonarQube scanner

FYI this is exactly what we are doing for .NET solutions, which was the original use case of this extension point.

Hi Julien,

We are currently (ab)using the maven sonar runner with some extra defined properties to retrieve our application model and generate the project file structure and ProjectDefinitions.

If you understand you correclty. we would first need to create our project structure and then the SonarQube Scanner would create the ProjectDefinitions for us? or do we need to do something extra in order detect what projects are?