Spring Boot 未找到ID为'unship.com'的插件

pxiryf3j  于 2022-12-29  发布在  Spring
关注(0)|答案(3)|浏览(131)

我正在尝试用gradle实现声纳,以便为我的项目进行代码覆盖测量。我们正在使用gradle-4.0.1和sonarqube-6.4。
当我从命令行运行gradle sonarqube时,我会收到此错误-

Plugin with id 'org.sonarqube' not found.

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

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

kdfy810k1#

'org.springframework.boot'插件一样,'org.sonarqube'插件不属于Gradle,而是第三方插件,因此您需要将其添加为buildscript依赖项:

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'应该可以正常工作了。

31moq8wy

31moq8wy2#

在我的例子中,它看起来像:

plugins {
   id 'groovy'
   id 'application'
   id 'org.sonarqube' version '3.0'
}

repositories {
   mavenCentral()
}

sonarqube {
   properties {
      property "sonar.host.url", "http://sonarqube:9000"
      property "sonar.sources", "src"
   }
}

tasks['sonarqube'].dependsOn test
fnatzsnv

fnatzsnv3#

使用插件DSL在build.gradle的plugins部分指定完整版本(例如,id "org.sonarqube" version "3.5.0.2730"而不是id "org.sonarqube" version "3.5.0"),我解决了这个问题。
以下是插件DSL和遗留插件应用程序的示例:https://plugins.gradle.org/plugin/org.sonarqube

相关问题