Reputation: 1506
I am trying to build an Android java project branch: feature-Fprototype_app
I am getting this error:
[INFO] [13:38:36.470] Base dir: /Users/Shared/Jenkins/Home/jobs/Textify/workspace/mobile
[INFO] [13:38:36.470] Working dir: /Users/Shared/Jenkins/Home/jobs/Textify/workspace/mobile/target/sonar
[INFO] [13:38:36.470] Source dirs: /Users/Shared/Jenkins/Home/jobs/Textify/workspace/mobile/src
[INFO] [13:38:36.470] Binary dirs: /Users/Shared/Jenkins/Home/jobs/Textify/workspace/mobile/target/classes
[INFO] [13:38:36.470] Source encoding: UTF-8, default locale: en_US
[INFO] [13:38:36.489] Sensor JavaSourceImporter...
[INFO] [13:38:36.710] Sensor JavaSourceImporter done: 221 ms
[INFO] [13:38:36.710] Sensor JavaSquidSensor...
[INFO] [13:38:36.800] Java AST scan...
[ERROR] Sonar is unable to analyze file : '/Users/Shared/Jenkins/Home/jobs/Textify/workspace/mobile/src/main/java/com/simpragma/apps/textify/db/BookmarkDao.java'
[INFO]
------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] -------------------
[INFO] Total time:14.245s
[INFO] Finished at: Thu Oct 17 13:38:36 GMT+05:30 2013
[INFO] Final Memory: 14M/102M
[INFO]
------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.1:sonar (default-cli) on project Textify: Can not execute SonarQube analysis: Sonar is unable to analyze file :
**'/Users/Shared/Jenkins/Home/jobs/Textify/workspace/mobile/src/main/java/com/simpragma/apps/textify/db/BookmarkDao.java': The source directory does not correspond to the package declaration** com.simpragma.apps.textify.db ->
[Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.1:sonar (default-cli) on project Textify: Can not execute SonarQube analysis
In jenkins configuration Post Build Action I am trying to set the sonar.sources
in Additional properties box (because when i googled for the error, people suggested to set the correct path for sources). I tried many combinations like:
-Dsonar.sources=mobile/src/main/java
-Dsonar.sources=/Users/Shared/Jenkins/Home/jobs/Textify/workspace/mobile/src/main/java
-Dsonar.sources=/Users/Shared/Jenkins/Home/jobs/Textify/workspace/mobile
still same error. What am I doing wrong ?
ok let me clear the mess I have created. Firstly, it is an android maven project. The package structure is com.xyz.abc and source root was src/main/java. In pom.xml the sourceDirectory property was initially set to point to src. It seems maven does not have any issue with the root of source, it is compiling the project. Then, I set up jenkins and sonar for this project. I used Jenkins's Post-build Action to set up Sonar analysis on my project. The catch here is "When running an analysis with Maven, some SonarQube properties are always ignored because SonarQube internally feeds them from the POM" - SONAR-4536. One among such properties is sonar.sources . Therefore, when i tried with -Dsonar.sources in the Jenkins setup it did not worked. Later I modified my pom to point to src/main/java which resulted in successful analysis through jenkins post-build action.
I hope I have clarified.
Upvotes: 4
Views: 29850
Reputation: 5326
If your project is a Maven project and you are using SonarQube Maven plugin then source location is taken from Maven model. The property sonar.sources is only used when using SonarQube Runner to perform the analysis.
Look at your project pom.xml and check . Also please update your question to tell if you are on a regular Java project or anything else (like android).
Upvotes: 5
Reputation: 11
Vikas,
The source directory you must indicate as a Sonar properties for a Java analysis must be the root directory of the packages declaration in the code.
See: http://qualilogy.com/en/install-sonarqube-first-analysis-with-sonarqube-runner/ http://qualilogy.com/en/install-sonarqube-sonarqube-analysis-with-jenkins/
Regards, JP
Upvotes: 1