Documentation
¶
Index ¶
- func AccessorFor(prefix, alias string) string
- func AccessorToPath(accessor string) string
- func FindVersionCatalog(rootDir string) string
- func GroupFilesByModule(graph *Graph, allFiles []*scanner.File) map[string][]*scanner.File
- func ParseAllDependencies(graph *Graph) error
- func ParseDependencies(graph *Graph, module *Module) error
- type CatalogEntry
- type Dependency
- type Graph
- type Module
- type PerModuleIndex
- type VersionCatalog
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AccessorFor ¶
AccessorFor returns the Kotlin accessor string for a catalog alias under the given prefix. Hyphens and underscores in the alias become dots, per Gradle's accessor convention.
func AccessorToPath ¶
AccessorToPath converts a typesafe project accessor name to a Gradle module path. For example: "circuitRuntime" -> ":circuit-runtime", "sentryAndroidCore" -> ":sentry-android-core".
func FindVersionCatalog ¶
FindVersionCatalog returns the path to gradle/libs.versions.toml under rootDir, or "" if not present.
func GroupFilesByModule ¶
GroupFilesByModule assigns parsed files to the Gradle module that owns them. Files that do not belong to any discovered module are placed in the "root" bucket so module-aware rules can still reason about them consistently.
func ParseAllDependencies ¶
ParseAllDependencies parses dependencies for every module in the graph.
func ParseDependencies ¶
ParseDependencies parses the build.gradle.kts (or build.gradle) file for a module and populates its Dependencies and IsPublished fields. It also updates the graph's Consumers reverse-index.
Types ¶
type CatalogEntry ¶
CatalogEntry is one alias line (the key) with its source location.
Value holds the trimmed RHS text. For bare string entries (`kotlin = "1.9.0"`) the surrounding quotes are stripped; inline tables (`{ module = "...", version.ref = "..." }`) keep their braces so callers can distinguish literal values.
For [libraries] entries, Module is the "group:name" coordinate when present and Version is the resolved version literal (after dereferencing version.ref against [versions]). Both are empty when the form is unrecognized. For [versions] entries, Version mirrors Value.
type Dependency ¶
type Dependency struct {
ModulePath string // Gradle path of depended-on module
Configuration string // "api", "implementation", "compileOnly", etc.
}
Dependency represents a module-to-module dependency.
type Graph ¶
type Graph struct {
Modules map[string]*Module // path -> module
Consumers map[string][]string // module path -> list of modules that depend on it
RootDir string
}
Graph holds all discovered modules and their relationships.
func DiscoverModules ¶
DiscoverModules parses a Gradle settings file to discover all modules in the project rooted at rootDir. Returns nil if no settings file is found.
func NewModuleGraph ¶
NewModuleGraph creates an empty Graph rooted at the given directory.
func (*Graph) FileToModule ¶
FileToModule maps an absolute file path to the Gradle path of the module that contains it. Returns an empty string if no module matches.
func (*Graph) FindCycles ¶
FindCycles returns all module dependency cycles as strongly connected components with size > 1. Each cycle is a sorted list of module paths.
type Module ¶
type Module struct {
Path string // Gradle path, e.g. ":app", ":core:util"
Dir string // absolute filesystem directory
Dependencies []Dependency // module-to-module deps
IsPublished bool // has maven-publish plugin
SourceRoots []string // source directories
}
Module represents a single Gradle module in a multi-module project.
type PerModuleIndex ¶
type PerModuleIndex struct {
ModuleIndex map[string]*scanner.CodeIndex // module path -> its CodeIndex
GlobalIndex *scanner.CodeIndex // unified index (backward compat)
Graph *Graph
ModuleFiles map[string][]*scanner.File // module path -> parsed files
}
PerModuleIndex holds per-module and global CodeIndex instances for module-aware cross-file analysis such as dead code detection.
func BuildPerModuleIndex ¶
func BuildPerModuleIndex(graph *Graph, allFiles []*scanner.File, workers int) *PerModuleIndex
BuildPerModuleIndex assigns each Kotlin/Java source file to its module, builds a per-module CodeIndex in parallel, and also builds a global CodeIndex from all files. The global scan happens once; per-module indexes are sliced out of the collected symbols/references instead of re-parsing the AST for each module. Files that do not belong to any module are placed in a "root" bucket.
func BuildPerModuleIndexWithGlobal ¶
func BuildPerModuleIndexWithGlobal(graph *Graph, allFiles []*scanner.File, workers int, globalIndex *scanner.CodeIndex) *PerModuleIndex
BuildPerModuleIndexWithGlobal is like BuildPerModuleIndex, but lets callers reuse an already-built global index instead of recomputing it.
type VersionCatalog ¶
type VersionCatalog struct {
Path string
Versions []CatalogEntry
Libraries []CatalogEntry
Plugins []CatalogEntry
Bundles []CatalogEntry
}
VersionCatalog is a parsed Gradle version catalog (libs.versions.toml).
func ParseVersionCatalog ¶
func ParseVersionCatalog(path string) (*VersionCatalog, error)
ParseVersionCatalog parses a libs.versions.toml file. Multi-line inline tables are not supported because Gradle catalogs in practice keep each entry on a single line.