Skip to content

Build the Plugin

Günter Wirth edited this page May 24, 2021 · 6 revisions

Getting started with GitHub

Learn about GitHub's products, sign up for an account, and explore the GitHub community: Getting started with GitHub.

Checkout Sources

If you have never used Git before, you need to do some setup first. Run the following commands so that GIT knows your name and email.

git config --global user.name "Your Name"
git config --global user.email "your@email.com"

Setup line endings preferences:

# For Unix/Mac users
git config --global core.autocrlf input
git config --global core.safecrlf true

# For _Microsoft Windows_ users
git config --global core.autocrlf true
git config --global core.safecrlf true

Get sources by executing:

git clone https://github.com/SonarOpenCommunity/sonar-cxx.git

Committers must configure their SSH key (see GitHub documentation for Microsoft Windows and Mac) and clone repository:

git clone git@github.com:SonarOpenCommunity/sonar-cxx.git

Build

Setup a local SonarQube instance

Hint: SonarQube scanners require version 8 or 11 of the JVM and the SonarQube Server requires version 11.
Versions beyond Java 11 are not officially supported.

Debug

If you want to debug your code there are at least three possibilities:

  1. Best and easiest possibility is to write an Unit Test for your changes. In this case you can run your debugger for your particular Unit Test to debug into your code within the IDE. Any other changes are not needed in this case.
  2. In case you have to debug code which is executed during analyzer run you have to prepare and start the sonar-runner for debugging.
  3. Copy your plugin's jar file to SONAR_HOME/extensions/plugins
  4. Start SonarQube normally, (debug is commented out in wrapper.config)
  5. At a command prompt, cd to the directory of the project you'll be analyzing
  6. Start sonar-runner in debug mode with the following commands
    SET SONAR_RUNNER_OPTS=-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
  7. Attach the IDE to the debug process on port 8000, set breakpoints in the source, and debug!
  8. In case you have to debug code on the sever side do the following steps:
  9. Copy your plugin's jar file to SONAR_HOME/extensions/plugins
  10. Edit SONAR_HOME/conf/wrapper.conf and uncomment the line: wrapper.java.additional.3=-agentlib:jdwp=transport=dt_socket,server=y,address=8000
  11. Launch SonarQube normally. The following line will appear in the log: Listening for transport dt_socket at address: 8000
  12. Attach the IDE to the debug process on port 8000, set breakpoints in the source, and debug!

See also Building your plugin

Testing

We have plenty of unit tests (not all of them being really 'unit') and a couple of integration-level smoke-tests. The former can be run with e.g. mvn test; refer to Integration Test Suite on how to use the latter.

Helpful links

Clone this wiki locally