Documentation
¶
Overview ¶
Package maven is the format of maven, gradle, ivy and sbt repositories (decision 0036): Maven's naming predicates, the coordinates a repository's layout reads from a path, and the package index of decision 0018, kept by the hooks on every write path and rebuilt by Reindex.
A package is groupId:artifactId, from the layout's organisation and module; a version is the name of its version folder, so every unique build of 1.0-SNAPSHOT is a file of that one version; and versions order by types.CompareMercury, as Artifactory's metadata and searches do.
Index ¶
- Constants
- func CalculateMetadata(ctx context.Context, env format.Env, c repo.Config, folder string, ...) error
- func GeneratePOM(ctx context.Context, env format.Env, c repo.Config, jar types.Item) (string, []byte, error)
- func IsChecksum(p string) bool
- func IsClientPom(p string) bool
- func IsIndex(p string) bool
- func IsMavenLayout(l *layout.Layout) bool
- func IsMetadata(p string) bool
- func IsMetadataChecksum(p string) bool
- func IsNonUniqueSnapshot(p string) bool
- func IsPom(p string) bool
- func IsSnapshot(p string) bool
- func IsSnapshotMetadata(p string) bool
- func IsSnapshotVersion(version string) bool
- func IsUniqueSnapshot(p string) bool
- func IsUniqueSnapshotName(name string) bool
- func Serves(t repo.PackageType) bool
- func Versions(ctx context.Context, st store.Store, c repo.Config, name string) ([]types.PackageVersion, map[int64][]types.Item, error)
- type Coordinates
- type Handler
- func (Handler) Admit(ctx context.Context, env format.Env, c repo.Config, w format.Write) (format.Write, error)
- func (Handler) Annotated(ctx context.Context, env format.Env, c repo.Config, it types.Item, ...) error
- func (Handler) Classify(c repo.Config, p string) format.Class
- func (Handler) Deleted(ctx context.Context, env format.Env, c repo.Config, removed []types.Item) error
- func (Handler) Deleting(ctx context.Context, env format.Env, c repo.Config, it types.Item) error
- func (Handler) Deployed(ctx context.Context, env format.Env, c repo.Config, it types.Item) error
- func (Handler) Inspect(ctx context.Context, env format.Env, _ repo.Config, w format.Write) (any, error)
- func (Handler) Owed(c repo.Config, cached bool, p string) []format.WorkRef
- func (Handler) OwnsSidecars()
- func (Handler) Reindex(ctx context.Context, env format.Env, c repo.Config) error
- func (Handler) Resolve(ctx context.Context, env format.Env, c repo.Config, d format.Download) (string, error)
- func (Handler) Work(ctx context.Context, env format.Env, it types.WorkItem) error
- func (Handler) WorkKinds() []string
- type UniqueBuild
Constants ¶
const ( // MetadataFile is maven-metadata.xml, at the snapshot, artifact or // plugin level. MetadataFile = "maven-metadata.xml" // Snapshot is the integration revision of a non-unique snapshot. Snapshot = "SNAPSHOT" // SnapshotSuffix ends a snapshot version, as in 1.0-SNAPSHOT. SnapshotSuffix = "-" + Snapshot )
Names Maven gives its files.
const ( // KindMetadata rebuilds a package's maven-metadata.xml files, its // artifact-level one and each snapshot folder's, keyed by // groupId:artifactId. KindMetadata = "maven.metadata" // KindPlugins rebuilds a group's plugin metadata, keyed by groupId. KindPlugins = "maven.plugins" )
The kinds of derived work the Maven format queues (decisions 0033 and 0036). A key is "<repository key>/<name>": repository keys hold no slash.
const Deriver = "_system_"
Deriver is recorded as the creator and modifier of the metadata the format writes: Artifactory's system user, SecurityService.USER_SYSTEM. It is how a run tells its own file from one a client uploaded, which it keeps when it has nothing to replace it with.
const KindSnapshots = "maven.snapshots"
KindSnapshots applies a package's maxUniqueSnapshots, keyed by groupId:artifactId (decision 0036, #283). It is periodic work: a deploy marks the package, and the runtime runs the marked packages on a timer (work.Queue.HandleEvery), as Artifactory 7.x marks the builds over the limit on deploy and deletes them in a background process every five minutes.
const PluginProperty = "artifactory.maven.mavenPlugin"
PluginProperty marks a POM whose packaging is maven-plugin, as Artifactory's MavenPomInterceptor does (PropertiesService .MAVEN_PLUGIN_PROPERTY_NAME); the plugin-level metadata (#279) lists them.
Variables ¶
This section is empty.
Functions ¶
func CalculateMetadata ¶
func CalculateMetadata( ctx context.Context, env format.Env, c repo.Config, folder string, recursive bool, ) error
CalculateMetadata does calculateMetadata's work on folder in c, a local repository of the Maven group (decision 0036, #282). In one transaction it brings the package index of the files under folder, or directly in it when recursive is false, back in line with the tree, as a reindex would, then queues the metadata of each package those files belong to, and of the package and group each maven-metadata.xml there describes, so a file with nothing left to describe is removed. The work runs when the queue reaches it, and a read of the metadata waits for it, so the answer need not wait: Artifactory's also answers once its calculation is queued.
func GeneratePOM ¶
func GeneratePOM( ctx context.Context, env format.Env, c repo.Config, jar types.Item, ) (string, []byte, error)
GeneratePOM returns where generatePom writes the POM of the file jar in c, and what it writes (decision 0036, #282): the jar's own META-INF/maven/<groupId>/<artifactId>/pom.xml for the coordinates its path gives, or a default POM. The path is the jar's descriptor path in the repository's layout, without its classifier, as the POM of a classifier artifact is its main artifact's. A file the layout reads no coordinates from, or a POM, is refused with 400.
func IsChecksum ¶
IsChecksum reports a checksum sidecar by its extension, with the algorithms item.Sidecar accepts.
func IsClientPom ¶
IsClientPom reports the pom.xml a project keeps beside its sources, which a jar carries under META-INF/maven.
func IsMavenLayout ¶
IsMavenLayout reports a layout equal to maven-2-default by value, name included, as RepoLayoutUtils.isDefaultM2 compares them: only under it does Artifactory rename snapshots, map their checksum sidecars and resolve -SNAPSHOT downloads to a unique build. A descriptor that edits maven-2-default turns those off; a copy of it under another name does not turn them on.
func IsMetadataChecksum ¶
IsMetadataChecksum reports a checksum sidecar of maven-metadata.xml.
func IsNonUniqueSnapshot ¶
IsNonUniqueSnapshot reports a file of a snapshot folder named with -SNAPSHOT before its classifier or extension, such as 1.0-SNAPSHOT/app-1.0-SNAPSHOT.jar.
func IsSnapshot ¶
IsSnapshot reports a snapshot file, unique or not, or a snapshot version folder.
func IsSnapshotMetadata ¶
IsSnapshotMetadata reports the maven-metadata.xml of a snapshot version folder.
func IsSnapshotVersion ¶
IsSnapshotVersion reports a non-unique snapshot version, such as 1.0-SNAPSHOT.
func IsUniqueSnapshot ¶
IsUniqueSnapshot reports a file of a snapshot folder whose name carries a timestamp and build number, such as 1.0-SNAPSHOT/app-1.0-20261017.090000-1.jar.
func IsUniqueSnapshotName ¶
IsUniqueSnapshotName reports a unique snapshot's file name.
func Serves ¶
func Serves(t repo.PackageType) bool
Serves reports the package types of Artifactory's Maven group that artifactweave serves. p2, which Artifactory also counts, is only ever a remote or virtual repository.
func Versions ¶
func Versions( ctx context.Context, st store.Store, c repo.Config, name string, ) ([]types.PackageVersion, map[int64][]types.Item, error)
Versions returns the versions the index holds for package name in c, oldest first in Mercury order, as the artifact-level metadata lists them; none for a package the index does not know. Each comes with the files it links.
Types ¶
type Coordinates ¶
type Coordinates struct {
layout.Coordinates
// Package is groupId:artifactId, the layout's organisation with dots
// and its module.
Package string
// Version is the name of the version's folder, such as 1.0 or
// 1.0-SNAPSHOT.
Version string
}
Coordinates are a file's place in the package index (decision 0036): the layout's reading of its path, the package it belongs to and the version.
func Read ¶
func Read(l *layout.Layout, fullPath string) (Coordinates, bool)
Read returns the coordinates l reads from a repository-relative file path; ok is false when the file is no file of a version: the layout does not fit it or names no organisation, or it is metadata, a checksum or a Nexus index file, which belong to no version even where a layout would read one.
type Handler ¶
type Handler struct {
// The generic format's hooks, which Admit's own checks replace.
generic.Handler
}
Handler is the Maven format: its deploy rules (admit.go) and snapshot naming (snapshot.go), its download policy and version tokens (policy.go, resolve.go), the package index, and maven-metadata.xml derived through the work queue (work.go, #279).
func (Handler) Admit ¶
func (Handler) Admit( ctx context.Context, env format.Env, c repo.Config, w format.Write, ) (format.Write, error)
Admit applies Artifactory's checks in its order (RealRepoBase .assertValidPath, then UploadServiceImpl): a blacked-out repository, the release and snapshot policy, the include and exclude patterns, and then what each kind of write adds, a snapshot file's name under the repository's snapshotVersionBehavior included (snapshot.go).
func (Handler) Annotated ¶
func (Handler) Annotated( ctx context.Context, env format.Env, c repo.Config, it types.Item, a format.Annotation, ) error
Annotated queues a group's plugin metadata when a POM in it gains or loses PluginProperty, by a deploy's properties or later.
func (Handler) Classify ¶
Classify reports maven-metadata.xml as derived, since #279 writes it from the index and a replica recomputes it, except under deployer, where the client writes every level and only a delete has it rewritten; a non-unique snapshot and a Nexus index file as metadata, since a later deploy changes them under the same path; and every other file as unique.
func (Handler) Deleted ¶
func (Handler) Deleted( ctx context.Context, env format.Env, c repo.Config, removed []types.Item, ) error
Deleted syncs every version a removal touched with the tree: a version that kept files may have lost its earliest, which dates it. It queues each touched package's metadata, under deployer as well: JFrog says a deployer repository's metadata is recalculated when other files are deleted (RTFACT-26651), and 7.27.3 fixed that recalculation emptying it (RTFACT-26126). Deleting a maven-metadata.xml touches no version, so the client's file is not written back.
func (Handler) Deleting ¶
Deleting runs before a file is removed. The item service drops the file's version link with it; Deleted settles the rest. A plugin POM, whose mark goes with it, queues its group's plugin metadata here, under deployer too, as a delete there recalculates.
func (Handler) Deployed ¶
Deployed indexes a file stored in a version: the version is synced with the tree, so its date and files are what a reindex would read. It queues the package's metadata, whose run rebuilds the group's plugin metadata too, and a plugin POM queues its group's plugin metadata of its own, which a read of that file waits for. A snapshot build in a repository with maxUniqueSnapshots marks the package for its cleanup.
func (Handler) Inspect ¶
func (Handler) Inspect( ctx context.Context, env format.Env, _ repo.Config, w format.Write, ) (any, error)
Inspect reads the POM a deploy, copy or move lands, outside the write's transaction; Admit checks it and the index keeps what it names.
func (Handler) Owed ¶
Owed names the work a download of a maven-metadata.xml, or of its sidecar, waits for: a snapshot folder's belongs to its package, and any other may be its folder's artifact-level or plugin metadata, so it waits for both. Waiting for work no one asked for costs one lookup.
func (Handler) OwnsSidecars ¶
func (Handler) OwnsSidecars()
OwnsSidecars makes every upload named as a checksum sidecar in a Maven repository a checksum of its file, as in Artifactory, so one whose file is missing answers 404 rather than being stored.
func (Handler) Reindex ¶
Reindex rebuilds the repository's package index from its tree, in one transaction.
func (Handler) Resolve ¶
func (Handler) Resolve( ctx context.Context, env format.Env, c repo.Config, d format.Download, ) (string, error)
Resolve resolves a download's version tokens and non-unique snapshot name (resolveTokens), then refuses the resolved path when the repository's release and snapshot policy does, as Artifactory's assertValidPath does for downloads and deploys alike. The policy reads the resolved path: a [RELEASE] that names a release is a release download.
func (Handler) Work ¶
Work rebuilds the metadata one item names from the package index as it stands now, under deployer as under the other behaviours, since only a delete asks for it there, or applies the package's maxUniqueSnapshots. A repository that is gone, or no longer a local repository of the Maven group, owes nothing.
type UniqueBuild ¶
UniqueBuild is the timestamp and build number a unique snapshot's file name carries.
func ParseUniqueBuild ¶
func ParseUniqueBuild(name string) (UniqueBuild, bool)
ParseUniqueBuild reads the build from a unique snapshot's file name; ok is false for any other name.
func (UniqueBuild) String ¶
func (b UniqueBuild) String() string
String is the build's part of a file name, as in 20261017.090000-1.