开发者

mvn sonar:sonar throws exception while doing Java AST scan

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(PackageVisito开发者_JS百科r.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


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.


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/ )


I got the same error message after upgrading to a more recent sonar plugin (sonar-maven3-plugin:3.7.1/3.7.3/4.0 running against SonarQube Server 3.5.1) for a source file which worked with 3.6-RC3/3.6.3/3.7.0. Apparently 3.7.1 introduced the issue :-/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜