maven

package module
v0.0.0-...-69d9307 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 4 Imported by: 1

Documentation

Index

Constants

View Source
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"
)
View Source
const MaxImports = 300

MaxImports defines the maximum number of dependency management imports allowed

Variables

View Source
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 BoolString         `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 ActivationFile struct {
	Missing String `xml:"missing,omitempty"`
	Exists  String `xml:"exists,omitempty"`
}

type ActivationOS

type ActivationOS struct {
	Name    String `xml:"name,omitempty"`
	Family  String `xml:"family,omitempty"`
	Arch    String `xml:"arch,omitempty"`
	Version String `xml:"version,omitempty"`
}

type ActivationProperty

type ActivationProperty struct {
	Name  String `xml:"name,omitempty"`
	Value String `xml:"value,omitempty"`
}

type BoolString

type BoolString string

BoolString represents a string field that holds a boolean value. BoolString may contain placeholders which need to be interpolated.

func (*BoolString) UnmarshalXML

func (bs *BoolString) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

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   BoolString  `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

type DependencyKey struct {
	GroupID    String
	ArtifactID String
	Type       String
	Classifier String
}

DependencyKey uniquely identifies a Maven dependency.

type DependencyManagement

type DependencyManagement struct {
	Dependencies []Dependency `xml:"dependencies>dependency,omitempty"`
}

type Developer

type Developer struct {
	Name  String `xml:"name,omitempty"`
	Email String `xml:"email,omitempty"`
}

type DistributionManagement

type DistributionManagement struct {
	Relocation Relocation `xml:"relocation,omitempty"`
}

type Exclusion

type Exclusion struct {
	GroupID    String `xml:"groupId,omitempty"`
	ArtifactID String `xml:"artifactId,omitempty"`
}

type IssueManagement

type IssueManagement struct {
	System String `xml:"system,omitempty"`
	URL    String `xml:"url,omitempty"`
}

type License

type License struct {
	Name String `xml:"name,omitempty"`
}

type Metadata

type Metadata struct {
	GroupID    String     `xml:"groupId"`
	ArtifactID String     `xml:"artifactId"`
	Versioning Versioning `xml:"versioning"`
}

Metadata contains repository information of a package. https://maven.apache.org/ref/3.9.3/maven-repository-metadata/repository-metadata.html

type Parent

type Parent struct {
	ProjectKey
	RelativePath String `xml:"relativePath,omitempty"`
}

type Plugin

type Plugin struct {
	ProjectKey
	Inherited    BoolString   `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

func (p *Project) Interpolate() error

Interpolate resolves placeholders in Project if there exists. Metadata is only recorded if it is successfully resolved.

func (*Project) MergeParent

func (p *Project) MergeParent(parent Project)

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) error

MergeProfiles merge the data in activated profiles to the project. If there is no active profile, merge the data from default profiles. 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 (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 Property

type Property struct {
	Name  string
	Value string
}

type Relocation

type Relocation struct {
	GroupID    String `xml:"groupId,omitempty"`
	ArtifactID String `xml:"artifactId,omitempty"`
	Version    String `xml:"version,omitempty"`
}

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 String `xml:"enabled"`
}

type SCM

type SCM struct {
	Tag String `xml:"tag,omitempty"`
	URL String `xml:"url,omitempty"`
}

type String

type String string

func (*String) ContainsProperty

func (s *String) ContainsProperty() bool

func (*String) UnmarshalXML

func (s *String) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML trims the whitespaces when unmarshalling a string.

type Versioning

type Versioning struct {
	Latest   String   `xml:"latest"`
	Release  String   `xml:"release"`
	Versions []String `xml:"versions>version"`
}

Jump to

Keyboard shortcuts

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