com.autonomousapps.model.ProjectAdvice.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
package com.autonomousapps.model
import com.autonomousapps.internal.utils.LexicographicIterableComparator
import com.squareup.moshi.JsonClass
/** Collection of all advice for a single project, across all variants. */
@JsonClass(generateAdapter = false)
data class ProjectAdvice(
val projectPath: String,
val dependencyAdvice: Set = emptySet(),
val pluginAdvice: Set = emptySet(),
val moduleAdvice: Set = emptySet(),
val warning: Warning = Warning.empty(),
/** True if there is any advice in a category for which the user has declared they want the build to fail. */
val shouldFail: Boolean = false
) : Comparable {
fun isEmpty(): Boolean = dependencyAdvice.isEmpty() && pluginAdvice.isEmpty() && warning.isEmpty()
fun isNotEmpty(): Boolean = !isEmpty()
override fun compareTo(other: ProjectAdvice): Int {
return compareBy(ProjectAdvice::projectPath)
.thenBy(LexicographicIterableComparator()) { it.dependencyAdvice }
.thenBy(LexicographicIterableComparator()) { it.pluginAdvice }
.thenBy(LexicographicIterableComparator()) { it.moduleAdvice }
.thenBy(ProjectAdvice::warning)
.thenBy(ProjectAdvice::shouldFail)
.compare(this, other)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy