Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

Here's a consolidated list of debugging techniques to use during SonarQube-related development.

Debugging a plugin during sonar-runner analysis

  1. Copy your plugin's jar file to SONAR_HOME/extensions/plugins
  2. Start SonarQube normally, (debug is commented out in wrapper.config)
  3. At a command prompt, cd to the directory of the project you'll be analyzing
  4. Start sonar-runner in debug mode with the following commands

    Code Block
    export SONAR_RUNNER_OPTS="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000" && sonar-runner
  5. Attach the IDE to the debug process on port 8000, set breakpoints in the source, and debug!

Debugging a plugin during Maven analysis

Simply run mvnDebug sonar:sonar and attach your IDE to the remote process. Example in Intellij Idea: Run > Edit configurations > Add new configuration > Remote.

Debugging a plugin server-side

  1. Copy your plugin's jar file to extensions/plugins
  2. Edit SONAR_HOME/conf/wrapper.conf and uncomment the line : wrapper.java.additional.3=-agentlib:jdwp=transport=dt_socket,server=y,address=8000
  3. Launch SonarQube normally. The following line will appear in the log : Listening for transport dt_socket at address: 8000
  4. Attach the IDE to the debug process on port 8000, set breakpoints in the source, and debug!