dependency-analysis-gradle-plugin icon indicating copy to clipboard operation
dependency-analysis-gradle-plugin copied to clipboard

No console or JSON output from `buildHealth`

Open FelixZY opened this issue 7 months ago • 4 comments

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

FelixZY avatar Jan 11 '24 14:01 FelixZY

Is there no file at

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

?

autonomousapps avatar Jan 13 '24 19:01 autonomousapps

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.

FelixZY avatar Jan 13 '24 20:01 FelixZY

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

autonomousapps avatar Jan 14 '24 18:01 autonomousapps

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.

FelixZY avatar Jan 15 '24 21:01 FelixZY

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

autonomousapps avatar Apr 21 '24 18:04 autonomousapps