Deepak S
Deepak S

Reputation: 1594

Plugin with id 'org.sonarqube' not found

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 .

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

Plugin with id 'org.sonarqube' not found.

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

Upvotes: 30

Views: 48234

Answers (5)

karipe
karipe

Reputation: 11

I am able to resolve this after adding settings.gradle file in project root with

pluginManagement {
repositories {
    maven { url "<Repo_URL>" }
}
}

Upvotes: 1

Uddhav P. Gautam
Uddhav P. Gautam

Reputation: 7636

1) Using the plugins DSL:

plugins {
  id "org.sonarqube" version "4.0.0.2929"
}

Or,

2) Using legacy plugin application:

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

apply plugin: "org.sonarqube"

Upvotes: 0

eebbesen
eebbesen

Reputation: 5148

Using the plugins DSL specifying a full version (e.g., id "org.sonarqube" version "3.5.0.2730" instead of id "org.sonarqube" version "3.5.0") in the plugins section of build.gradle resolved this issue for me.

Here are examples for plugins DSL and legacy plugin application: https://plugins.gradle.org/plugin/org.sonarqube

Upvotes: 0

JackTheKnife
JackTheKnife

Reputation: 4154

In my case it looks like:

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

Upvotes: 0

Lukas K&#246;rfer
Lukas K&#246;rfer

Reputation: 14543

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

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

Upvotes: 42

Related Questions