Documentation ¶
Index ¶
- func AllDependencies(f *Fetch, artifacts []Artifact, concurrency int, indent, buildRules bool) []string
- type Artifact
- func (a *Artifact) FromID(id string) error
- func (a *Artifact) GroupPath() string
- func (a *Artifact) IsExcluded(a2 *Artifact) bool
- func (a *Artifact) MetadataPath() string
- func (a *Artifact) Path(suffix string) string
- func (a *Artifact) PomPath() string
- func (a *Artifact) SetVersion(ver string)
- func (a *Artifact) SourcePath() string
- func (a Artifact) String() string
- func (a *Artifact) UnmarshalFlag(value string) error
- type Fetch
- type MetadataXML
- type PomXML
- type Resolver
- type Version
- type VersionPart
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllDependencies ¶
func AllDependencies(f *Fetch, artifacts []Artifact, concurrency int, indent, buildRules bool) []string
AllDependencies returns all the dependencies of these artifacts in a short format that we consume later. The format is vaguely akin to a Maven id, although we consider it an internal detail - it must agree between this and the maven_jars build rule that consumes it, but we don't hold it stable between different Please versions. The format is: group_id:artifact_id:version:{src|no_src}[:licence|licence|...]
Alternatively if buildRules is true, it will return a series of maven_jar rules that could be pasted into a BUILD file.
Types ¶
type Artifact ¶
type Artifact struct { // Raw version as found in XML Version string `xml:"version"` // A full-blown Maven version spec. If the version is not parseable (which is allowed // to happen :( ) then we just use Version to interpret it as a string. ParsedVersion Version // Trailing specifier e.g. "@aar" Specifier string // A "soft version", for dependencies that don't have one specified and we want to // provide a hint about what to do in that case. SoftVersion string // somewhat awkward, we use this to pass through excluded artifacts from above. Exclusions []Artifact `xml:"exclusions>exclusion"` // contains filtered or unexported fields }
An Artifact is a model of a Maven artifact.
func (*Artifact) FromID ¶
FromID loads this artifact from a Maven id.
func (*Artifact) GroupPath ¶
GroupPath returns the group ID as a path.
func (*Artifact) IsExcluded ¶
IsExcluded returns true if the given artifact is in this one's list of exclusions.
func (*Artifact) MetadataPath ¶
MetadataPath returns the path to the metadata XML file for this artifact.
func (*Artifact) Path ¶
Path returns the path to an artifact that we'd download.
func (*Artifact) PomPath ¶
PomPath returns the path to the pom.xml for this artifact.
func (*Artifact) SetVersion ¶
SetVersion updates the version on this artifact.
func (*Artifact) SourcePath ¶
SourcePath returns the path to the sources jar for this artifact.
func (Artifact) String ¶
String prints this artifact as a Maven identifier (i.e. GroupID:ArtifactID:Version)
type Fetch ¶
type Fetch struct { // Version resolver. Resolver *Resolver // contains filtered or unexported fields }
A Fetch fetches files for us from Maven. It memoises requests internally so we don't re-request the same file.
func NewFetch ¶
NewFetch constructs & returns a new Fetch instance.
func (*Fetch) HasSources ¶
HasSources returns true if the given artifact has any sources available. Unfortunately there's no way of determining this other than making a request, and lots of servers don't seem to support HEAD requests to just find out if the artifact is there.
func (*Fetch) IsExcluded ¶
IsExcluded returns true if this artifact should be excluded from the download.
func (*Fetch) Metadata ¶
func (f *Fetch) Metadata(a *Artifact) *MetadataXML
Metadata returns the metadata XML for a package. This contains some information, typically the main useful thing is the latest available version of the package.
func (*Fetch) Pom ¶
Pom fetches the POM XML for a package. Note that this may invoke itself recursively to fetch parent artifacts and dependencies.
type MetadataXML ¶
type MetadataXML struct { Version string `xml:"version"` Versioning struct { Latest string `xml:"latest"` Release string `xml:"release"` Versions struct { Version []string `xml:"version"` } `xml:"versions"` } `xml:"versioning"` Group, Artifact string }
A MetadataXML models a Maven metadata.xml file and its contents.
func (*MetadataXML) HasVersion ¶
func (metadata *MetadataXML) HasVersion(version string) bool
HasVersion returns true if the given package has the specified version.
func (*MetadataXML) LatestVersion ¶
func (metadata *MetadataXML) LatestVersion() string
LatestVersion returns the latest available version of a package
func (*MetadataXML) Unmarshal ¶
func (metadata *MetadataXML) Unmarshal(content []byte)
Unmarshal reads a metadata object from raw XML. It dies on any error.
type PomXML ¶
type PomXML struct { Artifact sync.Mutex OriginalArtifact Artifact Dependencies pomDependencies `xml:"dependencies"` DependencyManagement struct { Dependencies pomDependencies `xml:"dependencies"` } `xml:"dependencyManagement"` Properties struct { Property []pomProperty `xml:",any"` } `xml:"properties"` Licences struct { Licence []struct { Name string `xml:"name"` } `xml:"license"` } `xml:"licenses"` Parent Artifact `xml:"parent"` PropertiesMap map[string]string Dependors []*PomXML HasSources bool }
A PomXML models a Maven pom.xml and its contents.
func (*PomXML) AddProperty ¶
func (pom *PomXML) AddProperty(property pomProperty)
AddProperty adds a property (typically from a parent or wherever), without overwriting.
func (*PomXML) AllDependencies ¶
AllDependencies returns all the dependencies for this package.
func (*PomXML) AllLicences ¶
AllLicences returns all the licences for this package.
type Resolver ¶
A Resolver resolves Maven artifacts into specific versions. Ultimately we should really be using a proper SAT solver here but we're not rushing it in favour of forcing manual disambiguation (and the majority of things going wrong are due to Maven madness anyway).
func NewResolver ¶
NewResolver constructs and returns a new Resolver instance.
func (*Resolver) CreatePom ¶
CreatePom returns a pom for an artifact. If a suitable match doesn't exist, a new one will be created. The second return value is true if a new one was created.
func (*Resolver) Mediate ¶
func (r *Resolver) Mediate()
Mediate performs recursive dependency version mediation for all artifacts. Note that this is only done within each artifact, i.e. technically solving this properly is a fairly hard problem, and we avoid that by just attempting to solve within each individual artifact.
func (*Resolver) Pom ¶
Pom returns a pom for an artifact. The version doesn't have to be specified exactly. If one doesn't currently exist it will return nil.
func (*Resolver) Run ¶
Run runs the given number of worker threads until everything is resolved.
type Version ¶
type Version struct {
Min, Max VersionPart
Raw, Path string
Parsed bool
}
A Version is a Maven version spec (see https://docs.oracle.com/middleware/1212/core/MAVEN/maven_version.htm), including range reference info (https://docs.oracle.com/middleware/1212/core/MAVEN/maven_version.htm) The above is pretty light on detail unfortunately (like how do you know the difference between a BuildNumber and a Qualifier) so we really are taking a bit of a guess here. If only semver had existed back then...
Note that we don't (yet?) support broken ranges like (,1.0],[1.2,).
func (*Version) Intersect ¶
Intersect reduces v to the intersection of itself and v2. It returns true if the resulting version is still conceptually satisfiable.
func (*Version) LessThan ¶
LessThan returns true if this version is less than the given version.
func (*Version) Matches ¶
Matches returns true if this version matches the spec given by ver. Note that this is not symmetric; if this version is 1.0 and ver is <= 2.0, this is true; conversely it is false if this is 2.0 and ver is <= 1.0. It further treats this version as exact using its Min attribute, since that's roughly how Maven does it.
type VersionPart ¶
A VersionPart forms part of a Version; it can be either an upper or lower bound.
func (VersionPart) Equals ¶
func (v1 VersionPart) Equals(v2 VersionPart) bool
Equals returns true if the two versions are equal.
func (VersionPart) GreaterThan ¶
func (v1 VersionPart) GreaterThan(v2 VersionPart) bool
GreaterThan returns true if v1 > v2 (or >= if v2.Inclusive)
func (VersionPart) LessThan ¶
func (v1 VersionPart) LessThan(v2 VersionPart) bool
LessThan returns true if v1 < v2 (or <= if v2.Inclusive)