未找到 ID 为“org.sonarqube"的插件 [英] Plugin with id 'org.sonarqube' not found

查看:40
本文介绍了未找到 ID 为“org.sonarqube"的插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 gradle 为我的项目实施代码覆盖率测量的声纳.我们正在使用 gradle-4.0.1 和 sonarqube-6.4 .

I am trying to implement sonar with gradle for code-coverage measure for my project. we are using gradle-4.0.1 and sonarqube-6.4 .

当我从命令行运行 gradle sonarqube 时出现此错误-

when I run gradle sonarqube from command line I get this error-

Plugin with id 'org.sonarqube' not found.

我尝试了一些代码更改,但没有成功,请帮助.我的 build.gradle 文件如下 -

I tried few code changes but no luck, please help. My build.gradle file is as below-

buildscript {
    ext {
        springBootVersion = '1.5.4.RELEASE'
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

apply plugin: 'org.sonarqube'
apply plugin: "jacoco"
apply plugin: "java"
apply plugin: "war"
apply plugin: "org.springframework.boot"


sonarqube {
  properties {
    property "sonar.projectName","Spring4WebService Code Coverage Demo"
    property "sonar.projectKey", "org.sonarqubeJacocoCodeCoverage"
    property "sonar.reportPath" , "${project.buildDir}/jacoco/test.exec"
  }
}


test{
  ignoreFailures = true
}


ext {
    jacocoVersion = '0.7.6.201602180812'
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
    mavenCentral()
}


sourceSets {
  main.java.srcDir "src/main/java"
  test.java.srcDir "src/test/java"
}

springBoot {
  mainClass = "com.concretepage.config.WebAppInitializer"
}

dependencies {
    compile('org.springframework.boot:spring-boot-starter-web','com.fasterxml.jackson.core:jackson-databind')
    testCompile('org.springframework.boot:spring-boot-starter-test')
}

jacoco{
  toolVersion = "${jacocoVersion}"
}

jacocoTestReport {
 reports{
  html.enabled=true
  xml.enabled=true
  csv.enabled=true
 }
}

推荐答案

就像'org.springframework.boot'插件,'org.sonarqube'插件不属于 Gradle.它是一个第三方插件,所以你需要将它添加为 buildscript 依赖:

Just like the 'org.springframework.boot' plugin, the 'org.sonarqube' plugin does not belong to Gradle. It is a third-party plugin, so you need to add it as a buildscript dependency:

buildscript {
    ext {
        springBootVersion = '1.5.4.RELEASE'
    }
    repositories {
        mavenCentral()
        maven {
            url "https://plugins.gradle.org/m2/"
        }
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
        classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.5"
    }
}

现在 apply plugin: 'org.sonarqube' 应该可以正常工作了.

Now apply plugin: 'org.sonarqube' should work fine.

这篇关于未找到 ID 为“org.sonarqube"的插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆