0

So we have a build with 90+ sub-projects where it's often the case that the directory doesn't perfectly match the project name. In some cases we have empty project-less parent directories and in others the name just doesn't match the directory structure. For example, the sub-directory for project abc-toaster might be named just toaster. The error is:

The base directory of the module ':commons:thingamajig' does not exist:/dev/abc/:commons:thingamajig

...except there is no build.gradle in commons/thingamajig How can I get Sonar around this? I've tried:

  1. Putting an empty dummy build.gradle in commons/thingamajig - No dice. Same error.
  2. Setting someModule.sonar.projectBaseDir as mentioned here: Sonar properties files
  3. Running a full debug trace to see what pops up. Result: Nothing obvious.

Where am I hosing this up?

Example Update:

allprojects {
    sonarqube {
        file("$buildDir/classes").mkdirs();
        properties {
            property "sonar.exclusions", ["**/generated-src/**"]
            property "sonar.projectName", "ABC"
            property "sonar.projectKey", "$project.group:$project.name"
            property "sonar.jacoco.reportPath", "${project.buildDir}/jacoco/test.exec"
            property "sonar.projectBaseDir", "${project.rootDir}"
        }
    }
}

The above gives:

Caused by: java.lang.IllegalStateException: Unable to load component class org.sonar.batch.scan.ProjectLock
...
Caused by: java.lang.IllegalStateException: Unable to load component class org.sonar.api.batch.bootstrap.ProjectReactor
...
Caused by: java.lang.IllegalStateException: The base directory of the module ':commons:thingamajig' does not exist: /dev/abc/:commons:thingamajig

Another update: So I've figured out how to exclude projects that don't actually have any Java in them but get picked up by the Java plugin anyway. This has helped but I'm not out of the woods yet. I've also added this in an attempt to get the real value of the project's directory:

subprojects {
    sonarqube {
        println "*************"
        println "$project.name"
        properties.each {
            println "$it.key, $it.value"
        }
        println "Project Dir: $projectDir"
        println "Project Dir: $project.projectDir"

        println "*************"
    }
}

More on this in a bit.... OK... here is some debug level stuff:

15:49:31.419 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter] Executing actions for task ':sonarqube'.
15:49:31.512 [INFO] [org.sonarqube.gradle.SonarQubeTask] User cache: /home/user/.sonar/cache
15:49:31.512 [DEBUG] [org.sonarqube.gradle.SonarQubeTask] Extract sonar-scanner-api-batch in temp...
15:49:31.512 [DEBUG] [org.sonarqube.gradle.SonarQubeTask] Get bootstrap index...
15:49:31.512 [DEBUG] [org.sonarqube.gradle.SonarQubeTask] Download: http://localhost:9000/batch_bootstrap/index
15:49:31.518 [DEBUG] [org.sonarqube.gradle.SonarQubeTask] Get bootstrap completed
15:49:31.519 [DEBUG] [org.sonarqube.gradle.SonarQubeTask] Create isolated classloader...
15:49:31.520 [DEBUG] [org.sonarqube.gradle.SonarQubeTask] Start temp cleaning...
15:49:31.521 [DEBUG] [org.sonarqube.gradle.SonarQubeTask] Temp cleaning done
15:49:31.521 [DEBUG] [org.sonarqube.gradle.SonarQubeTask] Execution getVersion
15:49:31.522 [DEBUG] [org.sonarqube.gradle.SonarQubeTask] Execution start
15:49:31.607 [DEBUG] [org.sonarqube.gradle.SonarQubeTask] Publish global mode
15:49:31.639 [DEBUG] [org.sonarqube.gradle.SonarQubeTask] cache: /home/user/.sonar/ws_cache/http%3A%2F%2Flocalhost%3A9000/global
15:49:31.653 [INFO] [org.sonarqube.gradle.SonarQubeTask] Load global repositories
15:49:31.730 [DEBUG] [org.sonarqube.gradle.SonarQubeTask] GET 200 http://localhost:9000/batch/global | time=75ms
15:49:31.761 [INFO] [org.sonarqube.gradle.SonarQubeTask] Load global repositories (done) | time=109ms
15:49:31.778 [INFO] [org.sonarqube.gradle.SonarQubeTask] User cache: /home/user/.sonar/cache
15:49:32.035 [INFO] [org.sonarqube.gradle.SonarQubeTask] Load plugins index
15:49:32.036 [DEBUG] [org.sonarqube.gradle.SonarQubeTask] GET 200 http://localhost:9000/deploy/plugins/index.txt | time=1ms
15:49:32.037 [INFO] [org.sonarqube.gradle.SonarQubeTask] Load plugins index (done) | time=2ms
15:49:32.037 [DEBUG] [org.sonarqube.gradle.SonarQubeTask] Load plugins
15:49:32.041 [DEBUG] [org.sonarqube.gradle.SonarQubeTask] Load plugins (done) | time=4ms
15:49:32.048 [DEBUG] [org.sonarqube.gradle.SonarQubeTask] API compatibility mode is enabled on plugin C# [csharp] (built with API lower than 5.2)
15:49:32.048 [DEBUG] [org.sonarqube.gradle.SonarQubeTask] API compatibility mode is enabled on plugin Java [java] (built with API lower than 5.2)
15:49:32.048 [DEBUG] [org.sonarqube.gradle.SonarQubeTask] API compatibility mode is enabled on plugin SVN [scmsvn] (built with API lower than 5.2)
15:49:32.048 [DEBUG] [org.sonarqube.gradle.SonarQubeTask] API compatibility mode is enabled on plugin Git [scmgit] (built with API lower than 5.2)
15:49:32.048 [DEBUG] [org.sonarqube.gradle.SonarQubeTask] API compatibility mode is enabled on plugin JavaScript [javascript] (built with API lower than 5.2)
15:49:32.092 [DEBUG] [org.sonarqube.gradle.SonarQubeTask] Plugins:
15:49:32.092 [DEBUG] [org.sonarqube.gradle.SonarQubeTask]   * C# 4.4 (csharp)
15:49:32.092 [DEBUG] [org.sonarqube.gradle.SonarQubeTask]   * Java 3.10 (java)
15:49:32.092 [DEBUG] [org.sonarqube.gradle.SonarQubeTask]   * SVN 1.2 (scmsvn)
15:49:32.092 [DEBUG] [org.sonarqube.gradle.SonarQubeTask]   * Git 1.0 (scmgit)
15:49:32.092 [DEBUG] [org.sonarqube.gradle.SonarQubeTask]   * JavaScript 2.10 (javascript)
15:49:32.099 [INFO] [org.sonarqube.gradle.SonarQubeTask] Default locale: "en_US", source code encoding: "UTF-8" (analysis is platform dependent)
15:49:32.099 [DEBUG] [org.sonarqube.gradle.SonarQubeTask] Work directory: /development/eas/build/sonar
15:49:32.099 [DEBUG] [org.sonarqube.gradle.SonarQubeTask] Execution getVersion
15:49:32.099 [DEBUG] [org.sonarqube.gradle.SonarQubeTask] Execution execute
15:49:32.237 [INFO] [org.sonarqube.gradle.SonarQubeTask] Process project properties
15:49:32.244 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ':sonarqube'
15:49:32.244 [LIFECYCLE] [class org.gradle.TaskExecutionLogger] :sonarqube FAILED
15:49:32.244 [INFO] [org.gradle.execution.taskgraph.AbstractTaskPlanExecutor] :sonarqube (Thread[Daemon worker Thread 22,5,main]) completed. Took 5.151 secs.
15:49:32.244 [DEBUG] [org.gradle.execution.taskgraph.AbstractTaskPlanExecutor] Task worker [Thread[Daemon worker Thread 22,5,main]] finished, busy: 24.352 secs, idle: 0.053 secs
15:49:32.245 [ERROR] [org.gradle.BuildExceptionReporter] 
15:49:32.245 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception.
15:49:32.245 [ERROR] [org.gradle.BuildExceptionReporter] 
15:49:32.245 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong:
15:49:32.245 [ERROR] [org.gradle.BuildExceptionReporter] Execution failed for task ':sonarqube'.

Could be a missing or incorrect property if I'm reading this correctly. Is there a better way for me to dump these so I can check em?

OK, figured that out too:

gradle sonarqube -DsonarRunner.dumpToFile=out.properties

Nothing obvious in there though. I see where the project is failing but the value set for the base directory seems correct.

OK here is something really weird. If I run the above, I get:

BUILD SUCCESSFUL

...especially since it was not successful as far as I can tell.

OK I just found these and I've updated the debug level stuff:

property "sonar.verbose", "true"
property "sonar.log.level", "TRACE"

I still don't see anything pertinent there though.

Community
  • 1
  • 1
user447607
  • 4,109
  • 7
  • 29
  • 53
  • What is the version of the SonarQube Scanner for Gradle you are using? Have you tested release candidate of the version 2.0? https://plugins.gradle.org/plugin/org.sonarqube/2.0-rc1 – Julien H. - SonarSource Team Apr 26 '16 at 12:27
  • id "org.sonarqube" version "2.0-rc1" – user447607 Apr 26 '16 at 13:05
  • So, yes. This is exactly that version. – user447607 Apr 26 '16 at 13:19
  • Something I find odd is that the error is all one line with no space between /dev/abc and :commons:thingamajig. It's as if Sonar thinks that entire line is the directory name. – user447607 Apr 26 '16 at 14:01
  • can you show your settings.gradle? How are you organizing your subprojects? – RaGe Apr 26 '16 at 16:53
  • Well we have two subprojects with many sub-subprojects. The root project is an empty parent. There are many other empty parents but I've figured out how to exclude them when Sonar complains. We have one project that is strictly for the flyway plugin. Often times names do not match directories. settings.gradle is 219 lines. It's a lot of redacting if we go and do that. – user447607 Apr 26 '16 at 17:01
  • I've set up a local instance of SonarQube however I did not go so far as to set up the database. It shouldn't be necessary for just a bunch of test runs. What ever embedded database is present should be sufficient for just a run or two. Question: Am I correct about this or do I really have to configure a DB? – user447607 Apr 26 '16 at 20:18
  • K, SonarSource guys. Request you put in an error message that says, "Hey, numbscull! You've got the wrong server version." – user447607 Apr 27 '16 at 20:11

1 Answers1

0
sonarqube {
    properties {
        property "sonar.exclusions", "src/AbstractData.java,src/preprocessor/*.java,src/Service.java"
               }
          }

It's Worked for me, Try

Martin Brisiak
  • 2,957
  • 12
  • 32
  • 48
Dinakar N
  • 1
  • 1