Documentation
¶
Index ¶
- Constants
- Variables
- type Activation
- type ActivationFile
- type ActivationOS
- type ActivationProperty
- type Build
- type Dependency
- type DependencyKey
- type DependencyManagement
- type Developer
- type DistributionManagement
- type Exclusion
- type FalsyBool
- type IssueManagement
- type License
- type Metadata
- type MetadataPlugin
- type Parent
- type Plugin
- type PluginManagement
- type Profile
- type Project
- type ProjectKey
- type Properties
- type Property
- type Relocation
- type Repository
- type RepositoryPolicy
- type SCM
- type Snapshot
- type SnapshotVersion
- type String
- type TruthyBool
- type Versioning
Constants ¶
const ( // JDKProfileActivation holds the JDK version used for profile activation. // This is arbitrary for now. // TODO: this should be abstracted and set as an option. JDKProfileActivation = "11.0.8" )
const MaxImports = 300
MaxImports defines the maximum number of dependency management imports allowed
Variables ¶
var ( // OSProfileActivation holds the OS settings used for profile // activation. This is arbitrary, it was obtained by running `mvn // enforcer:display-info` in an amd64 Google Compute Engine VM, running // Debian 11 and Maven 3.6.3. // TODO: this should be abstracted and set as an option. OSProfileActivation = ActivationOS{ Name: "linux", Family: "unix", Arch: "amd64", Version: "5.10.0-26-cloud-amd64", } )
Functions ¶
This section is empty.
Types ¶
type Activation ¶
type Activation struct { ActiveByDefault FalsyBool `xml:"activeByDefault,omitempty"` JDK String `xml:"jdk,omitempty"` OS ActivationOS `xml:"os,omitempty"` Property ActivationProperty `xml:"property,omitempty"` File ActivationFile `xml:"file,omitempty"` }
Activation contains information to decide if a build profile is activated or not. https://maven.apache.org/guides/introduction/introduction-to-profiles.html#details-on-profile-activation=
type ActivationFile ¶
type ActivationOS ¶
type ActivationProperty ¶
type Build ¶
type Build struct {
PluginManagement PluginManagement `xml:"pluginManagement,omitempty"`
}
type Dependency ¶
type Dependency struct { GroupID String `xml:"groupId,omitempty"` ArtifactID String `xml:"artifactId,omitempty"` Version String `xml:"version,omitempty"` Type String `xml:"type,omitempty"` Classifier String `xml:"classifier,omitempty"` Scope String `xml:"scope,omitempty"` Exclusions []Exclusion `xml:"exclusions>exclusion,omitempty"` Optional FalsyBool `xml:"optional,omitempty"` }
Dependency contains relevant information about a Maven dependency. https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html
func (*Dependency) ExclusionsString ¶
func (d *Dependency) ExclusionsString() string
func (*Dependency) Key ¶
func (d *Dependency) Key() DependencyKey
func (*Dependency) Name ¶
func (d *Dependency) Name() string
type DependencyKey ¶
DependencyKey uniquely identifies a Maven dependency.
type DependencyManagement ¶
type DependencyManagement struct {
Dependencies []Dependency `xml:"dependencies>dependency,omitempty"`
}
type DistributionManagement ¶
type DistributionManagement struct {
Relocation Relocation `xml:"relocation,omitempty"`
}
type FalsyBool ¶
type FalsyBool String
FalsyBool represents a string field that holds a boolean value, and the default value is false. FalsyBool may contain placeholders which need to be interpolated.
func (*FalsyBool) UnmarshalXML ¶
type IssueManagement ¶
type Metadata ¶
type Metadata struct { ModelVersion String `xml:"modelVersion"` GroupID String `xml:"groupId"` ArtifactID String `xml:"artifactId"` Versioning Versioning `xml:"versioning"` Version String `xml:"version"` Plugins []MetadataPlugin `xml:"plugins>plugin"` }
Metadata contains repository information of a package. https://maven.apache.org/ref/3.9.3/maven-repository-metadata/repository-metadata.html
type MetadataPlugin ¶
type Parent ¶
type Parent struct { ProjectKey RelativePath String `xml:"relativePath,omitempty"` }
type Plugin ¶
type Plugin struct { ProjectKey Inherited TruthyBool `xml:"inherited,omitempty"` Dependencies []Dependency `xml:"dependencies>dependency,omitempty"` }
type PluginManagement ¶
type PluginManagement struct {
Plugins []Plugin `xml:"plugins>plugin,omitempty"`
}
type Profile ¶
type Profile struct { ID String `xml:"id,omitempty"` Activation Activation `xml:"activation,omitempty"` Properties Properties `xml:"properties,omitempty"` DependencyManagement DependencyManagement `xml:"dependencyManagement,omitempty"` Dependencies []Dependency `xml:"dependencies>dependency,omitempty"` Repositories []Repository `xml:"repositories>repository,omitempty"` }
Profile contains information of a build profile. https://maven.apache.org/guides/introduction/introduction-to-profiles.html
type Project ¶
type Project struct { ProjectKey Parent Parent `xml:"parent,omitempty"` Packaging String `xml:"packaging,omitempty"` Name String `xml:"name,omitempty"` Description String `xml:"description,omitempty"` URL String `xml:"url,omitempty"` Properties Properties `xml:"properties,omitempty"` Licenses []License `xml:"licenses>license,omitempty"` Developers []Developer `xml:"developers>developer,omitempty"` SCM SCM `xml:"scm,omitempty"` IssueManagement IssueManagement `xml:"issueManagement,omitempty"` DistributionManagement DistributionManagement `xml:"distributionManagement,omitempty"` DependencyManagement DependencyManagement `xml:"dependencyManagement,omitempty"` Dependencies []Dependency `xml:"dependencies>dependency,omitempty"` Repositories []Repository `xml:"repositories>repository,omitempty"` Profiles []Profile `xml:"profiles>profile,omitempty"` Build Build `xml:"build,omitempty"` }
Project contains information of a package version. https://maven.apache.org/ref/3.9.3/maven-model/maven.html
func (*Project) Interpolate ¶
Interpolate resolves placeholders in Project if there exists. Metadata is only recorded if it is successfully resolved.
func (*Project) MergeParent ¶
MergeParent merges data from the parent project. https://maven.apache.org/guides/introduction/introduction-to-the-pom.html#Project_Inheritance
func (*Project) MergeProfiles ¶
func (p *Project) MergeProfiles(jdk string, os ActivationOS) (err error)
MergeProfiles merge the data in activated profiles to the project. If there is no active profile, merge the data from default profiles. If no JDK or OS information is provided, default profiles are merged. The activation is based on the constants specified above.
func (*Project) ProcessDependencies ¶
func (p *Project) ProcessDependencies(getDependencyManagement func(String, String, String) (DependencyManagement, error))
ProcessDependencies takes the following actions for Maven dependencies:
- dedupe dependencies and dependency management
- import dependency management
- fill in missing dependency version requirement
A function to get dependency management from another project is needed since dependency management is imported transitively.
type ProjectKey ¶
type ProjectKey struct { GroupID String `xml:"groupId,omitempty"` ArtifactID String `xml:"artifactId,omitempty"` Version String `xml:"version,omitempty"` }
func MakeProjectKey ¶
func MakeProjectKey(name, version string) (ProjectKey, error)
func (ProjectKey) Name ¶
func (pk ProjectKey) Name() string
type Properties ¶
type Properties struct {
Properties []Property
}
Properties hold property pairs defined in a pom.xml.
func (*Properties) UnmarshalXML ¶
func (p *Properties) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
UnmarshalXML unmarshals properties defined in pom.xml and stores them in a slice of Property.
The properties section should be follow the format below:
<properties>
<name1>value1</name1> <name2>value2</name2> ...
</properties>
type Relocation ¶
type Repository ¶
type Repository struct { ID String `xml:"id,omitempty"` URL String `xml:"url,omitempty"` Layout String `xml:"layout,omitempty"` Releases RepositoryPolicy `xml:"releases,omitempty"` Snapshots RepositoryPolicy `xml:"snapshots,omitempty"` }
Repository contains the information about a remote repository. https://maven.apache.org/ref/3.9.3/maven-model/maven.html#repository-1
type RepositoryPolicy ¶
type RepositoryPolicy struct {
Enabled TruthyBool `xml:"enabled"`
}
type SnapshotVersion ¶
type String ¶
type String string
func (*String) ContainsProperty ¶
func (*String) UnmarshalXML ¶
UnmarshalXML trims the whitespaces when unmarshalling a string.
type TruthyBool ¶
type TruthyBool String
TruthyBool represents a string field that holds a boolean value, and the default value is true. TruthyBool may contain placeholders which need to be interpolated.
func (*TruthyBool) Boolean ¶
func (tb *TruthyBool) Boolean() bool
func (*TruthyBool) UnmarshalXML ¶
func (tb *TruthyBool) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error