Skip to content

Commit 50e87a4

Browse files
feat: new dependencyAnalysis.reporting.printBuildHealth DSL option.
1 parent 239127f commit 50e87a4

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

src/main/kotlin/com/autonomousapps/Flags.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,13 @@ object Flags {
3535

3636
internal fun Project.shouldAnalyzeTests() = getGradleOrSysProp(FLAG_TEST_ANALYSIS, true)
3737

38+
/**
39+
* Whether to print the buildHealth report to console.
40+
*
41+
* @see [com.autonomousapps.extension.ReportingHandler.printBuildHealth]
42+
*/
3843
internal fun Project.printBuildHealth() = getGradlePropForConfiguration(FLAG_PRINT_BUILD_HEALTH, false)
44+
3945
internal fun Project.androidIgnoredVariants() = getGradlePropForConfiguration(
4046
FLAG_ANDROID_IGNORED_VARIANTS, ""
4147
).split(",")

src/main/kotlin/com/autonomousapps/extension/ReportingHandler.kt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ import javax.inject.Inject
1414
* dependencyAnalysis {
1515
* reporting {
1616
* onlyOnFailure(false) // when true, only prints postscript when there are failure-level issues.
17+
*
1718
* postscript(/* Some text to help out end users who may not be build engineers. */)
19+
*
20+
* printBuildHealth(false) // when true, prints buildHealth report to console
1821
* }
1922
* }
2023
* ```
@@ -24,6 +27,10 @@ abstract class ReportingHandler @Inject constructor(private val objects: ObjectF
2427
internal val onlyOnFailure: Property<Boolean> = objects.property<Boolean>().convention(false)
2528
internal val postscript: Property<String> = objects.property<String>().convention("")
2629

30+
// nb: this intentionally does not have a convention set. If the user does not supply a value, we then check the
31+
// value of the Gradle property, which itself supplies a default value.
32+
internal val printBuildHealth: Property<Boolean> = objects.property<Boolean>()
33+
2734
/**
2835
* Whether to always include the postscript, or only when the report includes failure-level issues.
2936
*/
@@ -40,6 +47,16 @@ abstract class ReportingHandler @Inject constructor(private val objects: ObjectF
4047
this.postscript.disallowChanges()
4148
}
4249

50+
/**
51+
* Whether to print the buildHealth report to console.
52+
*
53+
* @see [com.autonomousapps.Flags.FLAG_PRINT_BUILD_HEALTH]
54+
*/
55+
fun printBuildHealth(printBuildHealth: Boolean) {
56+
this.printBuildHealth.set(printBuildHealth)
57+
this.printBuildHealth.disallowChanges()
58+
}
59+
4360
internal fun config(): Config {
4461
val config = objects.newInstance<Config>()
4562
config.onlyOnFailure.set(onlyOnFailure)

src/main/kotlin/com/autonomousapps/subplugin/RootPlugin.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ internal class RootPlugin(private val project: Project) {
127127
shouldFail.set(generateBuildHealthTask.flatMap { it.outputFail })
128128
buildHealth.set(generateBuildHealthTask.flatMap { it.output })
129129
consoleReport.set(generateBuildHealthTask.flatMap { it.consoleOutput })
130-
printBuildHealth.set(printBuildHealth())
130+
printBuildHealth.set(dagpExtension.reportingHandler.printBuildHealth.orElse(printBuildHealth()))
131131
postscript.set(dagpExtension.reportingHandler.postscript)
132132
}
133133

0 commit comments

Comments
 (0)