autonomousapps / dependency-analysis-gradle-plugin

Gradle plugin for JVM projects written in Java, Kotlin, Groovy, or Scala; and Android projects written in Java or Kotlin. Provides advice for managing dependencies and other applied plugins
Apache License 2.0
1.67k stars 115 forks source link

No console or JSON output from `buildHealth` #1099

Closed FelixZY closed 2 months ago

FelixZY commented 5 months ago

Plugin version 1.28.0

Gradle version 8.2

JDK version OpenJDK 19

(Optional) Kotlin and Kotlin Gradle Plugin (KGP) version Kotlin 1.8.20

(Optional) Android Gradle Plugin (AGP) version AGP 8.2.1

Describe the bug I'm probably missing something but the wiki clearly states:

The plugin enables these use-cases through the concept of "advice". When you execute the buildHealth task, it analyzes your entire project, including all variants for Android projects, and does two things:

  1. Prints that advice to the console in an easy-to-read format.
  2. Prints that advice to disk as JSON for advanced users who want to automate post-processing the results.

When I execute the buildHealth I do not get any console output. Neither do I get a json file.

To Reproduce Steps to reproduce the behavior:

  1. add id 'com.autonomousapps.dependency-analysis' version '1.28.0' to the plugins section of the project-wide build.gradle
  2. Add the following configuration at the top-level of the project-wide build.gradle:
    dependencyAnalysis {
    issues {
        all {
            onAny {
                severity('fail')
            }
        }
    }
    }

Expected behavior

  1. Prints [...] advice to the console in an easy-to-read format.
  2. Prints [...] advice to disk as JSON for advanced users who want to automate post-processing the results.

Additional context

$ ./gradlew buildHealth

> Configure project :
The Dependency Analysis plugin is only known to work with versions of AGP between 7.4.2 and 8.2.0-alpha16. You are using 8.2.1. Proceed at your own risk.

> Configure project :app
Android Gradle Plugin version 8.2.1
Using register source type API
Not using sources add API
applied

> Task :buildHealth FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':buildHealth'.
> There were dependency violations. See report at file:///[REDACTED]/build/reports/dependency-analysis/build-health-report.txt 

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

BUILD FAILED in 5s
1419 actionable tasks: 11 executed, 1408 up-to-date
autonomousapps commented 5 months ago

Is there no file at

> There were dependency violations. See report at file:///[REDACTED]/build/reports/dependency-analysis/build-health-report.txt 

?

FelixZY commented 5 months ago

The file:///[REDACTED]/build/reports/dependency-analysis/build-health-report.txt file does exist but it is not printed to stdout, neither is it in json format.

autonomousapps commented 5 months ago

There is a file build-health-report.json that is machine readable. The console report can be auto-printed by setting the flag

# gradle.properties
dependency.analysis.print.build.health=true
FelixZY commented 5 months ago

Indeed, next to build-health-report.txt there was a build-health-report.json. Setting dependency.analysis.print.build.health=true in the project-wide gradle.properties also caused the expected printout. Thank you!

I think the dependency.analysis.print.build.health=true requirement should be more obviously documented as current documentation makes it sound like the stdout print should happen by default.

Perhaps by updating the wiki like this?

The plugin enables these use-cases through the concept of "advice". When you execute the buildHealth task, it analyzes your entire project, including all variants for Android projects, and does two things:

  1. Prints that advice to disk in an easy-to-read format (build/reports/dependency-analysis/build-health-report.txt).
  2. Prints that advice to disk as JSON for advanced users who want to automate post-processing the results (build/reports/dependency-analysis/build-health-report.json).

You can also print the easy-to-read advice to stdout by setting dependency.analysis.print.build.health=true in your project-wide gradle.properties.

autonomousapps commented 2 months ago

I've decided I'll just update the readme. Thanks for the report!