Where is the new SonarQube Gradle Plugin?

2019-03-03 02:42发布

Having recently upgraded from a previous version of Gradle, I started getting a warning that I should use the official SonarQube plugin:

The 'sonar-runner' plugin has been deprecated and is scheduled to be removed in Gradle 3.0. please use the official plugin from SonarQube (the docs).

From that link, I was directed to the Gradle Plugins page for the new plugin (https://plugins.gradle.org/plugin/org.sonarqube), which tells me to use:

buildscript {
  repositories {
    maven {
      url "https://plugins.gradle.org/m2/"
    }
  }
  dependencies {
    classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:1.2"
  }
}

apply plugin: "org.sonarqube"

But that fails. The error I'm seeing in my Gradle output is:

Could not GET 'https://plugins.gradle.org/m2/org/sonarsource/scanner/gradle/sonarqube-gradle-plugin/1.2/sonarqube-gradle-plugin-1.2.pom'.  
> peer not authenticated

When I try to access the same location through a browser, I get a 404, and if I browse the file structure from https://plugins.gradle.org/m2/org, I can go as far as https://jcenter.bintray.com/org/sonarsource/scanner/, but the only subdirectories I see there are 'ant', 'cli' and 'maven', no 'gradle'. Presumably this is the root cause of my problem.

From other questions on here, I can see that others are using the plugin, so presumably it's available somewhere, but I can't find it. Any suggestions on a working source?

1条回答
萌系小妹纸
2楼-- · 2019-03-03 03:17

We got the plugin into Gradle by adding

classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:1.2"

to buildscript dependencies. We then added

apply plugin: 'org.sonarqube'

to activate it. Our local Artifactory instance is set up to proxy jCenter and mavenCentral.

查看更多
登录 后发表回答