maven

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: AGPL-3.0 Imports: 15 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const MaxPOMBytes = 4 << 20

MaxPOMBytes bounds the pom bytes read: element text accumulates in memory, so an unbounded document could exhaust it. Uploads of larger poms are refused.

Variables

View Source
var (
	// ErrNoMetadata is returned when MergeMetadata is given nothing to merge.
	ErrNoMetadata = errors.New("maven: no metadata documents to merge")
)

Functions

func Checksum added in v0.6.0

func Checksum(suffix string, data []byte) string

Checksum returns the hex digest of data for one Maven checksum file suffix (".md5", ".sha1" or ".sha512"), hashing with that algorithm only. Any other suffix returns "".

func CompareVersions added in v0.2.0

func CompareVersions(a, b string) int

CompareVersions compares two Maven versions following the semantics of Maven's ComparableVersion (numeric segments numerically, well-known qualifiers alpha < beta < milestone < rc < snapshot < release < sp). It returns -1, 0 or 1.

Comparing many versions against each other (sorting) should use SortVersions, which parses each version once instead of once per comparison.

func ComputeChecksums

func ComputeChecksums(r io.Reader) (string, string, string, string, error)

func IsSnapshot

func IsSnapshot(version string) bool

func ParseRepositoryPath

func ParseRepositoryPath(path string) (string, string, string, string, error)

func ParseSnapshotTimestamp

func ParseSnapshotTimestamp(filename string) (string, int, string, error)

func RepositoryPath

func RepositoryPath(c Coordinate) string

func SortVersions added in v0.9.0

func SortVersions(versions []string)

SortVersions sorts versions in place in Maven order (as CompareVersions), stably, parsing every version exactly once. All parsed segments share one backing array, so a sort of n versions costs O(1) allocations instead of O(n log n) per-comparison ones.

Types

type Coordinate

type Coordinate struct {
	GroupID    string
	ArtifactID string
	Version    string
	Classifier string
	Extension  string
}

type Dependency

type Dependency struct {
	GroupID    string `xml:"groupId"`
	ArtifactID string `xml:"artifactId"`
	Version    string `xml:"version"`
	Scope      string `xml:"scope"`
	Type       string `xml:"type"`
	Classifier string `xml:"classifier"`
	Optional   string `xml:"optional"`
}

type License

type License struct {
	Name string `xml:"name"`
	URL  string `xml:"url"`
}

type Metadata added in v0.4.0

type Metadata struct {
	XMLName    xml.Name    `xml:"metadata"`
	GroupID    string      `xml:"groupId,omitempty"`
	ArtifactID string      `xml:"artifactId,omitempty"`
	Version    string      `xml:"version,omitempty"`
	Versioning *Versioning `xml:"versioning,omitempty"`
	Plugins    []Plugin    `xml:"plugins>plugin,omitempty"`
}

Metadata is a maven-metadata.xml document at any of its three levels: group (plugin prefixes), artifact (version list) or version (snapshot resolution).

func MergeMetadata added in v0.4.0

func MergeMetadata(docs ...*Metadata) (*Metadata, error)

MergeMetadata merges the maven-metadata.xml documents of several repositories serving the same path, the way a group repository exposes its members:

  • artifact level: the version lists are united and ordered by Maven version order; latest is the highest version, release the highest non-SNAPSHOT version, lastUpdated the newest of the inputs;
  • group level: plugin prefix mappings are united (first member wins per prefix);
  • version (snapshot) level: the document with the newest lastUpdated wins as a whole, since snapshot builds of different members cannot be mixed.

func ParseMetadata added in v0.4.0

func ParseMetadata(data []byte) (*Metadata, error)

ParseMetadata decodes a maven-metadata.xml document.

func (*Metadata) Marshal added in v0.4.0

func (m *Metadata) Marshal() ([]byte, error)

Marshal renders the document with an XML declaration.

type POM

type POM struct {
	XMLName      xml.Name     `xml:"project"`
	GroupID      string       `xml:"groupId"`
	ArtifactID   string       `xml:"artifactId"`
	Version      string       `xml:"version"`
	Packaging    string       `xml:"packaging"`
	Parent       *Parent      `xml:"parent"`
	Name         string       `xml:"name"`
	Description  string       `xml:"description"`
	URL          string       `xml:"url"`
	Licenses     []License    `xml:"licenses>license"`
	Dependencies []Dependency `xml:"dependencies>dependency"`
}

func ParsePOM

func ParsePOM(r io.Reader) (*POM, error)

type Parent added in v0.8.0

type Parent struct {
	GroupID    string `xml:"groupId"`
	ArtifactID string `xml:"artifactId"`
	Version    string `xml:"version"`
}

Parent is the <parent> reference of a pom.

type Plugin added in v0.4.0

type Plugin struct {
	Name       string `xml:"name,omitempty"`
	Prefix     string `xml:"prefix"`
	ArtifactID string `xml:"artifactId"`
}

Plugin is one plugin-prefix mapping of a group-level document.

type Snapshot added in v0.4.0

type Snapshot struct {
	Timestamp   string `xml:"timestamp,omitempty"`
	BuildNumber int    `xml:"buildNumber,omitempty"`
	LocalCopy   bool   `xml:"localCopy,omitempty"`
}

Snapshot identifies the latest deployed snapshot build.

type SnapshotVersion added in v0.4.0

type SnapshotVersion struct {
	Classifier string `xml:"classifier,omitempty"`
	Extension  string `xml:"extension"`
	Value      string `xml:"value"`
	Updated    string `xml:"updated,omitempty"`
}

SnapshotVersion maps one snapshot file kind to its timestamped version.

type Versioning added in v0.4.0

type Versioning struct {
	Latest           string            `xml:"latest,omitempty"`
	Release          string            `xml:"release,omitempty"`
	Versions         []string          `xml:"versions>version,omitempty"`
	LastUpdated      string            `xml:"lastUpdated,omitempty"`
	Snapshot         *Snapshot         `xml:"snapshot,omitempty"`
	SnapshotVersions []SnapshotVersion `xml:"snapshotVersions>snapshotVersion,omitempty"`
}

Versioning is the <versioning> element of a Metadata document.

Jump to

Keyboard shortcuts

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