【问题标题】:Plugin [id: 'org.sonarqube', version: '2.8'] was not found in any of the following sources:在以下任何来源中都找不到插件 [id: 'org.sonarqube', version: '2.8']:
【发布时间】:2020-07-28 00:04:04
【问题描述】:

早安,

以下是我在build.gradle中的部分代码:

buildscript {
    repositories {
        jcenter()
        mavenCentral()
        maven {
           url "https://plugins.gradle.org/m2/"
        }
    }
  dependencies {
   classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.8"
  }
}

plugins {
  //id 'org.sonarqube' version '2.6.2'
  id 'org.sonarqube' version '2.8'
}

apply plugin: 'nebula.nebula-release'

apply plugin: "org.sonarqube"

apply from: "gradle/locations.gradle"
apply from: "gradle/buildEnvironment.gradle"
apply from: "gradle/project.gradle"
apply from: "gradle/versions.gradle"
apply from: "gradle/jacoco.gradle"
apply from: "gradle/sonarqube.gradle"
apply from: "gradle/testing.gradle"

当我运行 gradle 命令时,它会遇到以下错误:

* What went wrong:
Plugin [id: 'org.sonarqube', version: '2.8'] was not found in any of the following sources:

- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (could not resolve plugin artifact 'org.sonarqube:org.sonarqube.gradle.plugin:2.8')
  Searched in the following repositories:
    Gradle Central Plugin Repository

但是,如果我将 build.gradle 中的 id 'org.sonarqube' version '2.8' 更改为 id 'org.sonarqube' version '2.6.2',它将构建成功。

我可以知道我犯了什么错误吗?

** 我对 gradle 很陌生 **

【问题讨论】:

    标签: gradle plugins sonarqube version jcenter


    【解决方案1】:

    不建议手动添加依赖项并应用它(阅读Legacy Plugin Application)。 Plugins DSL 是推荐的方式。绝对不能同时使用两者。

    您的片段应更改为:

    plugins {
      id 'nebula.nebula-release' version '4.0.1'
      id 'org.sonarqube' version '2.8'
    }
    
    repositories {
      jcenter()
      mavenCentral()
    }
    
    apply from: "gradle/locations.gradle"
    apply from: "gradle/buildEnvironment.gradle"
    apply from: "gradle/project.gradle"
    apply from: "gradle/versions.gradle"
    apply from: "gradle/jacoco.gradle"
    apply from: "gradle/sonarqube.gradle"
    apply from: "gradle/testing.gradle"
    

    不知道你用的是哪个版本的nebula.nebula-release插件,所以我拿了最新的。

    【讨论】:

      【解决方案2】:

      我刚刚遇到了同样的问题。就我而言,我是离线运行 Gradle,所以它无法下载插件。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-05-17
        • 2022-06-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-03-04
        • 2022-12-29
        相关资源
        最近更新 更多