com.autonomousapps.model.internal.intermediates.producers.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.internal.intermediates
import com.autonomousapps.internal.utils.toCoordinates
import com.autonomousapps.model.*
import com.autonomousapps.model.internal.AndroidAssetCapability
import com.autonomousapps.model.internal.AndroidManifestCapability
import com.autonomousapps.model.internal.AndroidResCapability
import com.autonomousapps.model.internal.AnnotationProcessorCapability
import com.autonomousapps.model.internal.Capability
import com.autonomousapps.model.internal.InlineMemberCapability
import com.autonomousapps.model.internal.NativeLibCapability
import com.autonomousapps.model.internal.ServiceLoaderCapability
import com.autonomousapps.model.internal.TypealiasCapability
import com.squareup.moshi.JsonClass
import org.gradle.api.artifacts.result.ResolvedArtifactResult
internal interface DependencyView : Comparable where T : DependencyView {
val coordinates: Coordinates
fun toCapabilities(): List
override fun compareTo(other: T): Int = coordinates.compareTo(other.coordinates)
}
/**
* A dependency that includes a lint jar. (Which is maybe always named lint.jar?)
*
* Example registry: `nl.littlerobots.rxlint.RxIssueRegistry`.
*
* nb: Deliberately does not implement [DependencyView]. For various reasons, this information gets embedded in
* [ExplodedJar][com.autonomousapps.model.intermediates.producer.ExplodedJar], which is the preferred access point for
* deeper analysis.
*/
@JsonClass(generateAdapter = false)
internal data class AndroidLinterDependency(
val coordinates: Coordinates,
val lintRegistry: String,
) : Comparable {
override fun compareTo(other: AndroidLinterDependency): Int = coordinates.compareTo(other.coordinates)
}
/** Metadata from an Android manifest. */
@JsonClass(generateAdapter = false)
internal data class AndroidManifestDependency(
override val coordinates: Coordinates,
/** A map of component type to components. */
val componentMap: Map>,
) : DependencyView {
constructor(
componentMap: Map>,
artifact: ResolvedArtifactResult,
) : this(
componentMap = componentMap,
coordinates = artifact.toCoordinates()
)
override fun toCapabilities(): List = listOf(AndroidManifestCapability(componentMap))
}
/** A dependency that includes Android assets (e.g., src/main/assets). A runtime dependency. */
@JsonClass(generateAdapter = false)
internal data class AndroidAssetDependency(
override val coordinates: Coordinates,
val assets: List,
) : DependencyView {
override fun toCapabilities(): List = listOf(AndroidAssetCapability(assets))
}
@JsonClass(generateAdapter = false)
internal data class AndroidResDependency(
override val coordinates: Coordinates,
/** An import that indicates a possible use of an Android resource from this dependency. */
val import: String,
val lines: List,
) : DependencyView {
override fun toCapabilities(): List = listOf(AndroidResCapability(import, lines))
}
@JsonClass(generateAdapter = false)
internal data class AnnotationProcessorDependency(
override val coordinates: Coordinates,
val processor: String,
val supportedAnnotationTypes: Set,
) : DependencyView {
constructor(
processor: String,
supportedAnnotationTypes: Set,
artifact: ResolvedArtifactResult,
) : this(
processor = processor,
supportedAnnotationTypes = supportedAnnotationTypes,
coordinates = artifact.toCoordinates()
)
override fun toCapabilities(): List = listOf(
AnnotationProcessorCapability(processor, supportedAnnotationTypes)
)
}
@JsonClass(generateAdapter = false)
internal data class InlineMemberDependency(
override val coordinates: Coordinates,
val inlineMembers: Set,
) : DependencyView {
override fun toCapabilities(): List = listOf(InlineMemberCapability(inlineMembers))
}
@JsonClass(generateAdapter = false)
internal data class TypealiasDependency(
override val coordinates: Coordinates,
val typealiases: Set,
) : DependencyView {
override fun toCapabilities(): List = listOf(TypealiasCapability(typealiases))
}
@JsonClass(generateAdapter = false)
internal data class NativeLibDependency(
override val coordinates: Coordinates,
val fileNames: Set,
) : DependencyView {
override fun toCapabilities(): List = listOf(NativeLibCapability(fileNames))
}
@JsonClass(generateAdapter = false)
internal data class ServiceLoaderDependency(
override val coordinates: Coordinates,
val providerFile: String,
val providerClasses: Set,
) : DependencyView {
constructor(
providerFile: String,
providerClasses: Set,
artifact: ResolvedArtifactResult,
) : this(
providerFile = providerFile,
providerClasses = providerClasses,
coordinates = artifact.toCoordinates()
)
override fun toCapabilities(): List = listOf(ServiceLoaderCapability(providerFile, providerClasses))
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy