Documentation
¶
Overview ¶
Package gradle implements Gradle build tool support for Java projects.
It mirrors the Maven build tool's behavior: omnibump finds the best place to apply each requested bump across the mechanisms Gradle projects use to define dependency versions — version catalogs (gradle/libs.versions.toml and settings-script inline catalogs), version variables (gradle.properties, version.properties files, Groovy ext properties and version maps), and direct declarations in build scripts. Dependencies not declared anywhere are pinned through an omnibump-managed resolutionStrategy force block, the Gradle analog of Maven's DependencyManagement fallback for transitive dependencies.
File parsing and editing is delegated to pkg/gradlefile, which performs format-preserving edits on both Groovy and Kotlin DSL files.
Index ¶
- Variables
- type Gradle
- func (g *Gradle) Detect(ctx context.Context, dir string) (bool, error)
- func (g *Gradle) GetAnalyzer() analyzer.Analyzer
- func (g *Gradle) GetManifestFiles() []string
- func (g *Gradle) Name() string
- func (g *Gradle) Update(ctx context.Context, cfg *languages.UpdateConfig) error
- func (g *Gradle) Validate(ctx context.Context, cfg *languages.UpdateConfig) error
- type GradleAnalyzer
- func (ga *GradleAnalyzer) Analyze(ctx context.Context, projectPath string) (*analyzer.AnalysisResult, error)
- func (ga *GradleAnalyzer) AnalyzeRemote(ctx context.Context, files map[string][]byte) (*analyzer.RemoteAnalysisResult, error)
- func (ga *GradleAnalyzer) RecommendStrategy(ctx context.Context, analysis *analyzer.AnalysisResult, ...) (*analyzer.Strategy, error)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoBuildFiles is returned when no build.gradle files are found. ErrNoBuildFiles = errors.New("no build.gradle or build.gradle.kts files found") // ErrValidationFailed is returned when dependency validation fails. ErrValidationFailed = errors.New("validation failed") // ErrUnknownFileType is returned when an unknown Gradle file type is encountered. ErrUnknownFileType = errors.New("unknown Gradle file type") // ErrManifestTooLarge is returned when a manifest file exceeds size limits. ErrManifestTooLarge = errors.New("manifest file too large") )
var ( // ErrVersionConflict is returned when two updates try to set different // versions for the same dependency, variable or catalog key. ErrVersionConflict = errors.New("conflicting version update detected") // ErrPropertyNotFound is returned when a requested property update does // not match any catalog version key, version variable or properties-file // entry in the project. ErrPropertyNotFound = errors.New("property not found") // ErrSymlinkTarget is returned when a build file omnibump would write // already exists as a symlink, which os.WriteFile would follow out of // the project root. ErrSymlinkTarget = errors.New("refusing to write through a symlink") )
Functions ¶
This section is empty.
Types ¶
type Gradle ¶
type Gradle struct{}
Gradle implements the BuildTool interface for Gradle projects.
func (*Gradle) GetAnalyzer ¶
GetAnalyzer returns the Gradle analyzer.
func (*Gradle) GetManifestFiles ¶
GetManifestFiles returns Gradle manifest files.
func (*Gradle) Update ¶
Update performs dependency updates on a Gradle project. It builds a model of every Gradle file that can define a version, routes each requested update to the mechanism that defines it (version catalog, version variable, direct declaration), pins dependencies found nowhere via a dependency constraint, and applies coordinate swaps via dependency substitution — both hosted in the managed block of the settings script so they apply before any configuration resolves.
type GradleAnalyzer ¶
type GradleAnalyzer struct{}
GradleAnalyzer implements dependency analysis for Gradle projects.
func (*GradleAnalyzer) Analyze ¶
func (ga *GradleAnalyzer) Analyze(ctx context.Context, projectPath string) (*analyzer.AnalysisResult, error)
Analyze analyzes a Gradle project's dependencies. Version catalog keys and version variables are surfaced as properties (with their defining file in PropertySources); dependencies declared through a catalog reference or a variable interpolation report UsesProperty with the key they resolve through, mirroring how the Maven analyzer reports ${property} versions.
func (*GradleAnalyzer) AnalyzeRemote ¶
func (ga *GradleAnalyzer) AnalyzeRemote(ctx context.Context, files map[string][]byte) (*analyzer.RemoteAnalysisResult, error)
AnalyzeRemote performs dependency analysis on remotely-fetched Gradle files. It mirrors Analyze, building the project model from the in-memory file contents instead of disk, and returns a single aggregated FileAnalysis the way the Maven analyzer aggregates all pom.xml files into one.
func (*GradleAnalyzer) RecommendStrategy ¶
func (ga *GradleAnalyzer) RecommendStrategy(ctx context.Context, analysis *analyzer.AnalysisResult, deps []analyzer.Dependency) (*analyzer.Strategy, error)
RecommendStrategy recommends an update strategy for given dependencies.