Can't debug custom rules plugin

Hi. I’m trying to develop a plugin with an extended set of rules for my project. I have created a plugin based on the sample plugin example. I built it with maven and added it to extensions/plugins folder.

After that I added the following to sonar.properties :
sonar.web.javaAdditionalOpts=-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005

Running sonarqube ( native instance, no docker image )

./sonar.sh console

Debugger settings:

After attaching a debugger to the process, and the debugger even stops in my plugin’s entrypoint

After which the sonar starts up correctly
And I’m running a sonar scanner.

sonar-scanner -Dsonar.token="<token>" -Dsonar.projectKey=magento2 -Dsonar.sources=. -Dsonar.scanner.debug=true

The analysis went correctly. I can see that my rule worked ( the error appeared after the analysis). But the debugger did not stop at the classes of custom checks.
I also tried to do it with
export SONAR_SCANNER_OPTS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8001”
Before starting the scanner, but neither the process on port 5005 nor on port 8001 stops.
Please help(

Hi,

The rules are executed by the scanner, so you don’t need to start the SonarQube Server in the debugger.

The SonarScanner distribution comes with a handy “sonar-scanner-debug” script which sets the correct environment variables.

2 Likes

Thanks, that saved me a lot of time. Oh, my God.
Btw, why is there no any information about “sonar-scanner-debug” in the docs?

1 Like

@Scott :exploding_head: I did not know about this.

It probably deserves a mention in Developing a plugin. I’ll ping our Docs folks and get that in the backlog.