-
Notifications
You must be signed in to change notification settings - Fork 365
Build the Plugin
Learn about GitHub's products, sign up for an account, and explore the GitHub community: Getting started with GitHub.
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
- Install JDK 11 or later (e.g http://jdk.java.net/archive/).
- Install Maven 3.6.x or later (https://maven.apache.org/download.cgi).
- Execute
mvn clean install
on command line in root folder of your local copy. - For development you can use e.g. Eclipse (https://www.eclipse.org/) or NetBeans (https://netbeans.org/).
- Install JDK 11 or later (e.g http://jdk.java.net/archive/).
- Install a SonarQube version: https://www.sonarqube.org/downloads/
- Follow Try Out SonarQube guide
- Set the parameter
wrapper.java.command
in the file$SONARQUBE-HOME\conf\wrapper.conf
to the Java version to be used, e.g.wrapper.java.command=C:\Program Files\Java\openjdk-11.0.2\bin\java.exe
.
- Install a SonarScanner version, use Any: https://docs.sonarqube.org/latest/analysis/scan/sonarscanner/
- Follow SonarScanner guide
- Set the
JAVA_EXEC
environment variable to the Java version to be used before you start the scanner.
- For the cxx plugin, see Scan Source Code and Scan Report Files for more information.
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.
If you want to debug your code there are at least three possibilities:
- 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.
- In case you have to debug code which is executed during analyzer run you have to prepare and start the sonar-runner for debugging.
- Copy your plugin's jar file to
SONAR_HOME/extensions/plugins
- Start SonarQube normally, (debug is commented out in wrapper.config)
- At a command prompt, cd to the directory of the project you'll be analyzing
- 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
- Attach the IDE to the debug process on port 8000, set breakpoints in the source, and debug!
- In case you have to debug code on the sever side do the following steps:
- Copy your plugin's jar file to
SONAR_HOME/extensions/plugins
- Edit
SONAR_HOME/conf/wrapper.conf
and uncomment the line:wrapper.java.additional.3=-agentlib:jdwp=transport=dt_socket,server=y,address=8000
- Launch SonarQube normally. The following line will appear in the log: Listening for transport dt_socket at address: 8000
- Attach the IDE to the debug process on port 8000, set breakpoints in the source, and debug!
See also Building your plugin
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.