com.avito.android.critical_path.TaskExt.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of critical-path-api Show documentation
Show all versions of critical-path-api Show documentation
Collection of infrastructure libraries and gradle plugins of Avito Android project
package com.avito.android.critical_path
import com.avito.android.Result
import org.gradle.api.Task
import org.gradle.api.internal.TaskInternal
import org.gradle.api.tasks.TaskDependency
public val Task.type: Class
get() = (this as TaskInternal).taskIdentity.type
public val Task.predecessors: TaskDependenciesResolutionResult
get() {
val dependenciesByInputs = project.gradle.taskGraph.getDependencies(this)
val resolutionResults = listOf(
taskDependencies.resolveDependencies(this),
mustRunAfter.resolveDependencies(this),
shouldRunAfter.resolveDependencies(this)
)
val tasks: Set = dependenciesByInputs +
resolutionResults.flatMap {
it.getOrElse { emptySet() }
}
val errors = resolutionResults
.filterIsInstance(Result.Failure::class.java)
.map { it.throwable }
return TaskDependenciesResolutionResult.create(tasks, errors)
}
internal fun TaskDependency.resolveDependencies(task: Task): Result> =
Result.tryCatch {
getDependencies(task)
}