com.autonomousapps.tasks.GenerateProjectHealthReportTask.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dependency-analysis-gradle-plugin Show documentation
Show all versions of dependency-analysis-gradle-plugin Show documentation
Analyzes dependency usage in Android and JVM projects
// Copyright (c) 2024. Tony Robalik.
// SPDX-License-Identifier: Apache-2.0
@file:Suppress("UnstableApiUsage")
package com.autonomousapps.tasks
import com.autonomousapps.extension.DependenciesHandler.Companion.toLambda
import com.autonomousapps.internal.advice.DslKind
import com.autonomousapps.internal.advice.ProjectHealthConsoleReportBuilder
import com.autonomousapps.internal.utils.fromJson
import com.autonomousapps.internal.utils.getAndDelete
import com.autonomousapps.model.ProjectAdvice
import org.gradle.api.DefaultTask
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.provider.MapProperty
import org.gradle.api.provider.Property
import org.gradle.api.tasks.*
import org.gradle.workers.WorkAction
import org.gradle.workers.WorkParameters
import org.gradle.workers.WorkerExecutor
import javax.inject.Inject
@CacheableTask
abstract class GenerateProjectHealthReportTask @Inject constructor(
private val workerExecutor: WorkerExecutor
) : DefaultTask() {
init {
description = "Generates console report for project health"
}
@get:PathSensitive(PathSensitivity.NONE)
@get:InputFile
abstract val projectAdvice: RegularFileProperty
@get:Input
abstract val postscript: Property
@get:Input
abstract val dslKind: Property
@get:Input
abstract val dependencyMap: MapProperty
@get:OutputFile
abstract val output: RegularFileProperty
@TaskAction fun action() {
workerExecutor.noIsolation().submit(ProjectHealthAction::class.java) {
advice.set([email protected])
postscript.set([email protected])
dslKind.set([email protected])
dependencyMap.set([email protected])
output.set([email protected])
}
}
interface ProjectHealthParameters : WorkParameters {
val advice: RegularFileProperty
val postscript: Property
val dslKind: Property
val dependencyMap: MapProperty
val output: RegularFileProperty
}
abstract class ProjectHealthAction : WorkAction {
override fun execute() {
val output = parameters.output.getAndDelete()
val projectAdvice = parameters.advice.fromJson()
val consoleText = ProjectHealthConsoleReportBuilder(
projectAdvice = projectAdvice,
postscript = parameters.postscript.get(),
dslKind = parameters.dslKind.get(),
dependencyMap = parameters.dependencyMap.get().toLambda(),
).text
output.writeText(consoleText)
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy