Documentation
¶
Index ¶
- Constants
- Variables
- func Checksum(suffix string, data []byte) string
- func CompareVersions(a, b string) int
- func ComputeChecksums(r io.Reader) (string, string, string, string, error)
- func IsSnapshot(version string) bool
- func ParseRepositoryPath(path string) (string, string, string, string, error)
- func ParseSnapshotTimestamp(filename string) (string, int, string, error)
- func RepositoryPath(c Coordinate) string
- func SortVersions(versions []string)
- type Coordinate
- type Dependency
- type License
- type Metadata
- type POM
- type Parent
- type Plugin
- type Snapshot
- type SnapshotVersion
- type Versioning
Constants ¶
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 ¶
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
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
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 IsSnapshot ¶
func ParseRepositoryPath ¶
func ParseSnapshotTimestamp ¶
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 Dependency ¶
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
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
ParseMetadata decodes a maven-metadata.xml document.
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"`
}
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.