Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mvn sonar:sonar throws exception while doing Java AST scan

Tags:

sonarqube

Please note :- My mvn clean install goes successful but when i do mvn sonar:sonar it throws me

[ERROR]  Squid Error occurs when analysing :/junk/test/src/main/java/API/com/API/HelloAPI.java
org.sonar.squid.api.AnalysisException: The source directory does not correspond to the package declaration com.API
        at org.sonar.java.ast.visitor.PackageVisitor.checkPhysicalDirectory(PackageVisitor.java:93) [sonar-squid-java-plugin-2.8.jar:na]
        at org.sonar.java.ast.visitor.PackageVisitor.createSourcePackage(PackageVisitor.java:75) [sonar-squid-java-plugin-2.8.jar:na]

http://sonar-dev.787459.n3.nabble.com/file/n3324837/squid-test.zip

like image 475
anish Avatar asked Sep 10 '11 08:09

anish


2 Answers

The message is quite clear: the package declaration is wrong. It should be API.com.API if the source directory is /junk/test/src/main/java (that is the default value in Maven). An alternative is to change the source dir to src/main/java/API.

like image 155
Simon Brandhof - SonarSource Avatar answered Oct 13 '22 23:10

Simon Brandhof - SonarSource


Could it be that your POM contains this line:

<sourceDirectory>.</sourceDirectory>

If so, changing it to this might help:

<sourceDirectory>src/main/java</sourceDirectory>

Maven doesn't care, but sonar does.

I had the same problem with sonar and a maven project generated by eclipse.

(Found the solution at http://www.digipedia.pl/usenet/thread/13899/13064/ )

like image 33
Hok Avatar answered Oct 13 '22 22:10

Hok