maven

package
v0.10.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 4, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package maven implements Maven build tool support for Java projects. Ported from pombump with enhancements for the unified omnibump architecture.

Index

Constants

View Source
const (

	// MaxPatchFileSize limits patch/properties file size to prevent resource exhaustion.
	MaxPatchFileSize = 10 * 1024 * 1024 // 10 MB

	// MaxPomFileSize limits POM file size to prevent resource exhaustion.
	MaxPomFileSize = 10 * 1024 * 1024 // 10 MB
)

Default scope and type for a dependency.

Variables

View Source
var (

	// ErrInvalidVersion is returned when a version string fails validation.
	ErrInvalidVersion = errors.New("invalid version string")

	// ErrPomNotFound is returned when pom.xml is not found.
	ErrPomNotFound = errors.New("pom.xml not found")

	// ErrPropertyValidationFailed is returned when property validation fails.
	ErrPropertyValidationFailed = errors.New("property validation failed")

	// ErrRemoteAnalysisNotImplemented is returned when remote analysis is not implemented.
	ErrRemoteAnalysisNotImplemented = errors.New("remote analysis not yet implemented")

	// ErrMissingRequiredFields is returned when a dependency is missing groupId or artifactId.
	ErrMissingRequiredFields = errors.New("missing required fields for dependency")
)
View Source
var (
	// ErrProjectNil is returned when a POM project is nil.
	ErrProjectNil = errors.New("project is nil")

	// ErrFileTooLarge is returned when a file exceeds size limits.
	ErrFileTooLarge = errors.New("file too large")

	// ErrInvalidDependencyFormat is returned when a dependency string has invalid format.
	ErrInvalidDependencyFormat = errors.New("invalid dependencies format")

	// ErrInvalidPropertyFormat is returned when a property string has invalid format.
	ErrInvalidPropertyFormat = errors.New("invalid properties format")
)

Functions

func ParsePom

func ParsePom(pomPath string) (*gopom.Project, error)

ParsePom parses a POM file and returns a gopom.Project.

func PatchProject

func PatchProject(ctx context.Context, project *gopom.Project, patches []Patch, propertyPatches map[string]string) (*gopom.Project, error)

PatchProject applies dependency and property patches to a parsed pom.xml. project is a gopom.Project — a Go struct that mirrors the Maven POM XML schema and can be round-tripped back to XML via project.Marshal().

func UpdatePom

func UpdatePom(ctx context.Context, pomPath string, patches []Patch, properties map[string]string) ([]byte, error)

UpdatePom updates a POM file with the given patches and properties. Returns the marshaled XML content of the updated POM.

Types

type Maven

type Maven struct{}

Maven implements the BuildTool interface for Maven projects.

func (*Maven) Detect

func (m *Maven) Detect(ctx context.Context, dir string) (bool, error)

Detect checks if Maven manifest files exist in the directory.

func (*Maven) GetAnalyzer

func (m *Maven) GetAnalyzer() analyzer.Analyzer

GetAnalyzer returns the Maven analyzer.

func (*Maven) GetManifestFiles

func (m *Maven) GetManifestFiles() []string

GetManifestFiles returns Maven manifest files.

func (*Maven) Name

func (m *Maven) Name() string

Name returns the build tool identifier.

func (*Maven) Update

func (m *Maven) Update(ctx context.Context, cfg *languages.UpdateConfig) error

Update performs dependency updates on a Maven project.

func (*Maven) Validate

func (m *Maven) Validate(ctx context.Context, cfg *languages.UpdateConfig) error

Validate checks if the updates were applied successfully.

type MavenAnalyzer

type MavenAnalyzer struct{}

MavenAnalyzer implements the Analyzer interface for Maven projects. Ported from pombump/pkg/analyzer.go.

func (*MavenAnalyzer) Analyze

func (ma *MavenAnalyzer) Analyze(ctx context.Context, projectPath string) (*analyzer.AnalysisResult, error)

Analyze performs dependency analysis on a Maven project.

func (*MavenAnalyzer) AnalyzeRemote

func (ma *MavenAnalyzer) AnalyzeRemote(ctx context.Context, files map[string][]byte) (*analyzer.RemoteAnalysisResult, error)

AnalyzeRemote performs dependency analysis on remotely-fetched Maven files. Not yet implemented for Maven - returns error. TODO: Implement this function and use ctx for logging and files for analysis.

func (*MavenAnalyzer) RecommendStrategy

func (ma *MavenAnalyzer) RecommendStrategy(ctx context.Context, analysis *analyzer.AnalysisResult, deps []analyzer.Dependency) (*analyzer.Strategy, error)

RecommendStrategy suggests whether to use properties or direct patches.

type Patch

type Patch struct {
	GroupID    string `json:"groupId" yaml:"groupId"`
	ArtifactID string `json:"artifactId" yaml:"artifactId"`
	Version    string `json:"version" yaml:"version"`
	Scope      string `json:"scope,omitempty" yaml:"scope,omitempty"`
	Type       string `json:"type,omitempty" yaml:"type,omitempty"`
}

Patch represents a Maven dependency patch. Ported from pombump/pkg/patch.go.

type PatchList

type PatchList struct {
	Patches []Patch `json:"patches" yaml:"patches"`
}

PatchList represents a list of patches from a YAML file.

type PropertyList

type PropertyList struct {
	Properties []PropertyPatch `json:"properties" yaml:"properties"`
}

PropertyList represents a list of property patches from a YAML file.

type PropertyPatch

type PropertyPatch struct {
	Property string `json:"property" yaml:"property"`
	Value    string `json:"value" yaml:"value"`
}

PropertyPatch represents a property override.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL