Mvn sonar: sonar throws an exception by performing Java AST scan

Please note: - My clean mvn installation was successful, but when I do mvn sonar: the sonar 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

+5
source share
3 answers

The message is quite obvious: the package declaration is incorrect. This should be API.com.API if the source directory is / junk / test / src / main / java (this is the default value in Maven). An alternative is to change the source directory in src / main / java / API.

+3
source

Maybe your POM contains this line:

<sourceDirectory>.</sourceDirectory>

If so, changing it to this may help:

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

Maven doesn't care, but the sonar does.

maven, eclipse.

( http://www.digipedia.pl/usenet/thread/13899/13064/)

+2

I got the same error message after upgrading to a newer sonar plugin (sonar-maven3-plugin: 3.7.1 / 3.7.3 / 4.0, working against SonarQube Server 3.5.1) for the source file that worked with 3.6 - RC3 / 3.6.3 / 3.7.0. Apparently, 3.7.1 introduced the question: - /

0
source

All Articles