Sonar scanner is not scanning the JAVA custom rules

I created a new Java custom plug. I created a profile as well. I can see all those rules in SonarQube. When I am running “sonar-scanner”, I am not able to issue reports against those plugins. But When I am running “mvn clean install sonar:sonar”, it is showing an issue against those plugins in sonarQube.

In Sonar-scanner properties, I have set the below parameters: Can you please let me know why Sonar-Scanner is not scanning those custom java rules?

sonar.projectKey=APINAME
sonar.projectName=APINAME
sonar.projectVersion=1.1
sonar.sources=C:/Users/git/APINAME/src
sonar.java.binaries=target/classes
sonar.password=password
sonar.login=username
sonar.qualitygate.wait=true

Please let me know if u need more details.

Versions are given below:

SonarQube : 8.9.1.44547
Scanner : 4.6.2.2472
Plugin : Created new custom Java plugin
Java 11.0.3 AdoptOpenJDK (64-bit)
Windows 10 10.0 amd64

Thanks,
Pragati Jain.

Hi,

Welcome to the community!

I guess you’re testing with both scanners in the name of thoroughness (:clap:) but the difference you’re seeing is going to be down to the parameters the scanner is getting, and not how your custom rules work. If they work from one scanner they’ll work from all the others (when properly configured).

If you really want to track this down, the thing to do is add -Dsonar.scanner.dumpToFile=[path to file] to the command line of each analysis and then compare the output.

 
HTH,
Ann

Thanks a lot for your reply. It started working. sonar.java.libraries were missing in sonar-scanner property file. Your suggestion worked. I compared both the dump file and got to know this. Thanks a lot for unblocking me.