maven

package
v1.15.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// UseNetwork instructs the maven resolver to use network operations to resolve maven artifacts
	UseNetwork bool `yaml:"use-network" json:"use-network" mapstructure:"use-network"`

	// Repositories are the set of remote repositories the network resolution should use
	Repositories []string `yaml:"maven-repositories" json:"maven-repositories" mapstructure:"maven-repositories"`

	// UseLocalRepository instructs the maven resolver to look in the host maven cache, usually ~/.m2/repository
	UseLocalRepository bool `yaml:"use-maven-local-repository" json:"use-maven-local-repository" mapstructure:"use-maven-local-repository"`

	// LocalRepositoryDir is an alternate directory to use to look up the local repository
	LocalRepositoryDir string `yaml:"maven-local-repository-dir" json:"maven-local-repository-dir" mapstructure:"maven-local-repository-dir"`

	// MaxParentRecursiveDepth allows for a maximum depth to use when recursively resolving parent poms and other information, 0 disables any maximum
	MaxParentRecursiveDepth int `yaml:"max-parent-recursive-depth" json:"max-parent-recursive-depth" mapstructure:"max-parent-recursive-depth"`
}

func DefaultConfig

func DefaultConfig() Config

type Dependency

type Dependency = gopom.Dependency

func DirectPomDependencies

func DirectPomDependencies(pom *Project) []Dependency

DirectPomDependencies returns all dependencies directly defined in a project, including all defined in profiles. This does not resolve any parent or transitive dependencies

type ID

type ID struct {
	GroupID    string
	ArtifactID string
	Version    string
}

ID is the unique identifier for a package in Maven

func NewID

func NewID(groupID, artifactID, version string) ID

func (ID) String

func (m ID) String() string

func (ID) Valid

func (m ID) Valid() bool

Valid indicates that the given maven ID has values for groupId, artifactId, and version

type License

type License = gopom.License

type Parent

type Parent = gopom.Parent

type Project

type Project = gopom.Project

func ParsePomXML

func ParsePomXML(content io.Reader) (project *Project, err error)

ParsePomXML decodes a pom XML file, detecting and converting non-UTF-8 charsets. this DOES NOT perform any logic to resolve properties such as groupID, artifactID, and version

type Properties

type Properties = gopom.Properties

type Resolver

type Resolver struct {
	// contains filtered or unexported fields
}

Resolver is a short-lived utility to resolve maven poms from multiple sources, including: the scanned filesystem, local maven cache directories, remote maven repositories, and the syft cache

func NewResolver

func NewResolver(fileResolver file.Resolver, cfg Config) *Resolver

NewResolver constructs a new Resolver with the given configuration. NOTE: the fileResolver is optional and if provided will be used to resolve parent poms by relative path

func (*Resolver) AddPom

func (r *Resolver) AddPom(ctx context.Context, pom *Project, location file.Location)

AddPom allows for adding known pom files with locations within the file resolver, these locations may be used while resolving parent poms by relative path

func (*Resolver) FindLicenses

func (r *Resolver) FindLicenses(ctx context.Context, groupID, artifactID, version string) ([]gopom.License, error)

FindLicenses attempts to find a pom, and once found attempts to resolve licenses traversing parent poms as necessary

func (*Resolver) FindPom

func (r *Resolver) FindPom(ctx context.Context, groupID, artifactID, version string) (*Project, error)

FindPom gets a pom from cache, local repository, or from a remote Maven repository depending on configuration

func (*Resolver) ResolveDependencyID

func (r *Resolver) ResolveDependencyID(ctx context.Context, pom *Project, dep Dependency) ID

ResolveDependencyID creates an ID from a dependency element in a pom, resolving information as necessary

func (*Resolver) ResolveID

func (r *Resolver) ResolveID(ctx context.Context, pom *Project) ID

ResolveID creates an ID from a pom, resolving parent information as necessary

func (*Resolver) ResolveLicenses

func (r *Resolver) ResolveLicenses(ctx context.Context, pom *Project) ([]License, error)

ResolveLicenses searches the pom for license, resolving and traversing parent poms if needed

func (*Resolver) ResolveParent

func (r *Resolver) ResolveParent(ctx context.Context, pom *Project) (*Project, error)

ResolveParent resolves the parent definition, and returns a POM for the parent, which is possibly incomplete, or nil

func (*Resolver) ResolveProperty

func (r *Resolver) ResolveProperty(ctx context.Context, pom *Project, propertyValue *string) string

ResolveProperty gets property values by emulating maven property resolution logic, looking in the project's variables as well as supporting the project expressions like ${project.parent.groupId}. Properties which are not resolved result in empty string ""

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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