项目不包括gradle / sonar / Jacoco

时间:2016-04-25 20:52:08

标签: gradle sonarqube jacoco sonarqube-scan

所以我们有一个包含90多个子项目的构建,其中目录通常与项目名称不完全匹配。在某些情况下,我们有空的无项目父目录,而在其他情况下,名称与目录结构不匹配。例如,项目abc-toaster的子目录可能只被命名为toaster。错误是:

模块的基本目录' :commons:thingamajig'不存在:/dev/abc/:commons:thingamajig

...除了build.gradle中没有commons/thingamajig 我怎样才能得到Sonar?我试过了:

  1. build.gradle中放置一个空的假人commons/thingamajig - 没有骰子。同样的错误。
  2. 如此处所述设置someModule.sonar.projectBaseDirSonar properties files
  3. 运行完整的调试跟踪以查看弹出的内容。结果:没什么明显的。
  4. 我在哪里加油?

    示例更新:

    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}"
            }
        }
    }
    

    以上给出:

    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
    

    另一个更新: 所以我已经弄清楚如何排除那些实际上没有Java的项目,但无论如何都要被Java插件选中。这有帮助,但我还没有走出困境。我还添加了这个以试图获得项目目录的真正价值:

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

    稍后详细介绍......好的......这里有一些调试级别的东西:

    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'.
    

    如果我正确阅读,可能是遗失或不正确的财产。有没有更好的方法来转储这些以便我可以检查它?

    好的,也想出来了:

    gradle sonarqube -DsonarRunner.dumpToFile=out.properties
    

    虽然没有明显的东西。我看到项目失败的地方,但是为基本目录设置的值似乎是正确的。

    好的,这里真的很奇怪。如果我执行上述操作,我会得到:

    BUILD SUCCESSFUL
    

    ...特别是因为据我所知它没有成功。

    好的,我刚发现这些,并且我已经更新了调试级别的内容:

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

    但我仍然没有看到任何相关内容。

1 个答案:

答案 0 :(得分:0)

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

对我有用,请尝试