1

Use Case

I am trying to generate a dependency tree containing all plugins and dependencies for all configurations, but org.sonarqube is not included in the tree. I am working with a basic, single-module project and am using Gradle v7.5.1.

Examples

Running the following command outputs most (but not all) dependencies and plugins.

gradlew dependencies > dependency-tree.txt

Specify SonarQube plugin within build.gradle

plugins {
  id 'org.sonarqube' version '3.2.0'
}

Specify SonarQube plugin within settings.gradle

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

apply plugin: "org.sonarqube" // set in build.gradle, not in settings.gradle

Results

Neither approach includes the org.sonarqube plugin in the dependency graph. Is there a way to get this plugin to show up in the generated dependency tree? If yes, what changes need to be made?

  • the `dependencies` only works for the main dependencies of the project and you can see if there are any configurations for the plugin. see https://docs.gradle.org/current/userguide/viewing_debugging_dependencies.html#example_rendering_the_dependency_report_for_a_custom_configuration – PrasadU Nov 08 '22 at 22:37
  • @PrasadU It doesn't appear any configurations are associated with this plugin. Also went back to the [SonarScanner for Gradle documentation](https://docs.sonarqube.org/latest/analysis/scan/sonarscanner-for-gradle/) and nothing really stood out to me... –  Nov 09 '22 at 18:50

1 Answers1

2

The dependencies task provides the projet dependencies in each configuration, this does not include the projet script classpath (plugins).

You have another similar task available, buildEnvironment (see BuildEnvironmentReportTask) which will list the project build script dependencies. you could combine both tasks outputs if you need a aggredated report of all project/plugin dependencies

> Task :buildEnvironment

------------------------------------------------------------
Root project 'demo'
------------------------------------------------------------

classpath
\--- org.sonarqube:org.sonarqube.gradle.plugin:3.2.0
     \--- org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:3.2.0
          \--- org.sonarsource.scanner.api:sonar-scanner-api:2.16.1.361

A web-based, searchable dependency report is available by adding the --scan option.

BUILD SUCCESSFUL in 452ms

M.Ricciuti
  • 11,070
  • 2
  • 34
  • 54