maven

package
v1.365.0 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2024 License: Apache-2.0 Imports: 12 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateNewProjectSettingsXML added in v1.146.0

func CreateNewProjectSettingsXML(altDeploymentRepositoryID string, altDeploymentRepositoryUser string, altDeploymentRepositoryPassword string, utils SettingsDownloadUtils) (string, error)

func DownloadAndCopySettingsFiles added in v1.62.0

func DownloadAndCopySettingsFiles(globalSettingsFile string, projectSettingsFile string, utils SettingsDownloadUtils) error

DownloadAndCopySettingsFiles downloads the global or project settings file if the strings contain URLs. It copies the given files to either the locations specified in the environment variables M2_HOME and HOME or the default locations where maven expects them.

func DownloadAndGetMavenParameters added in v1.62.0

func DownloadAndGetMavenParameters(globalSettingsFile string, projectSettingsFile string, utils SettingsDownloadUtils) ([]string, error)

DownloadAndGetMavenParameters downloads the global or project settings file if the strings contain URLs. It then constructs the arguments that need to be passed to maven in order to point to use these settings files.

func Evaluate added in v1.17.0

func Evaluate(options *EvaluateOptions, expression string, utils Utils) (string, error)

Evaluate constructs ExecuteOptions for using the maven-help-plugin's 'evaluate' goal to evaluate a given expression from a pom file. This allows to retrieve the value of - for example - 'project.version' from a pom file exactly as Maven itself evaluates it.

func Execute

func Execute(options *ExecuteOptions, utils Utils) (string, error)

Execute constructs a mvn command line from the given options, and uses the provided mavenExecRunner to execute it.

func GetTestModulesExcludes added in v1.16.0

func GetTestModulesExcludes(utils Utils) []string

GetTestModulesExcludes return testing modules that you be excluded from reactor

func InstallFile added in v1.44.0

func InstallFile(file, pomFile string, options *EvaluateOptions, utils Utils) error

InstallFile installs a maven artifact and its pom into the local maven repository. If "file" is empty, only the pom is installed. "pomFile" must not be empty.

func InstallMavenArtifacts added in v1.44.0

func InstallMavenArtifacts(options *EvaluateOptions, utils Utils) error

InstallMavenArtifacts finds maven modules (identified by pom.xml files) and installs the artifacts into the local maven repository.

func UpdateActiveProfileInSettingsXML added in v1.168.0

func UpdateActiveProfileInSettingsXML(newActiveProfiles []string, utils SettingsDownloadUtils) error

func UpdateProjectSettingsXML added in v1.146.0

func UpdateProjectSettingsXML(projectSettingsFile string, altDeploymentRepositoryID string, altDeploymentRepositoryUser string, altDeploymentRepositoryPassword string, utils SettingsDownloadUtils) (string, error)

func VisitAllMavenModules added in v1.87.0

func VisitAllMavenModules(path string, utils visitUtils, excludes []string, callback func(info ModuleInfo) error) error

VisitAllMavenModules ...

Types

type ActiveProfilesType added in v1.168.0

type ActiveProfilesType struct {
	XMLName       xml.Name `xml:"activeProfiles"`
	Text          string   `xml:",chardata"`
	ActiveProfile []string `xml:"activeProfile"`
}

type Dependency added in v1.87.0

type Dependency struct {
	XMLName    xml.Name    `xml:"dependency"`
	GroupID    string      `xml:"groupId"`
	ArtifactID string      `xml:"artifactId"`
	Version    string      `xml:"version"`
	Classifier string      `xml:"classifier"`
	Type       string      `xml:"type"`
	Scope      string      `xml:"scope"`
	Exclusions []Exclusion `xml:"exclusions>exclusion"`
}

Dependency describes a dependency of the module.

type EvaluateOptions added in v1.43.0

type EvaluateOptions struct {
	PomPath             string   `json:"pomPath,omitempty"`
	ProjectSettingsFile string   `json:"projectSettingsFile,omitempty"`
	GlobalSettingsFile  string   `json:"globalSettingsFile,omitempty"`
	M2Path              string   `json:"m2Path,omitempty"`
	Defines             []string `json:"defines,omitempty"`
}

EvaluateOptions are used by Evaluate() to construct the Maven command line. In contrast to ExecuteOptions, fewer settings are required for Evaluate and thus a separate type is needed.

type Exclusion added in v1.87.0

type Exclusion struct {
	XMLName    xml.Name `xml:"exclusion"`
	GroupID    string   `xml:"groupId"`
	ArtifactID string   `xml:"artifactId"`
}

Exclusion describes an exclusion within a dependency.

type ExecuteOptions

type ExecuteOptions struct {
	PomPath                     string   `json:"pomPath,omitempty"`
	ProjectSettingsFile         string   `json:"projectSettingsFile,omitempty"`
	GlobalSettingsFile          string   `json:"globalSettingsFile,omitempty"`
	M2Path                      string   `json:"m2Path,omitempty"`
	Goals                       []string `json:"goals,omitempty"`
	Defines                     []string `json:"defines,omitempty"`
	Flags                       []string `json:"flags,omitempty"`
	LogSuccessfulMavenTransfers bool     `json:"logSuccessfulMavenTransfers,omitempty"`
	ReturnStdout                bool     `json:"returnStdout,omitempty"`
}

ExecuteOptions are used by Execute() to construct the Maven command line.

type ModuleInfo added in v1.87.0

type ModuleInfo struct {
	PomXMLPath string
	Project    *Project
}

ModuleInfo describes a location and Project of a maven module.

type Parent added in v1.87.0

type Parent struct {
	XMLName    xml.Name `xml:"parent"`
	GroupID    string   `xml:"groupId"`
	ArtifactID string   `xml:"artifactId"`
	Version    string   `xml:"version"`
}

Parent describes the coordinates a module's parent POM.

type Project added in v1.87.0

type Project struct {
	XMLName      xml.Name     `xml:"project"`
	Parent       Parent       `xml:"parent"`
	GroupID      string       `xml:"groupId"`
	ArtifactID   string       `xml:"artifactId"`
	Version      string       `xml:"version"`
	Packaging    string       `xml:"packaging"`
	Name         string       `xml:"name"`
	Dependencies []Dependency `xml:"dependencies>dependency"`
	Modules      []string     `xml:"modules>module"`
}

Project describes the Maven object model.

func ParsePOM added in v1.87.0

func ParsePOM(xmlData []byte) (*Project, error)

ParsePOM parses the provided XML raw data into a Project.

type Server added in v1.146.0

type Server struct {
	ID                   string `xml:"id,omitempty"`
	Username             string `xml:"username,omitempty"`
	Password             string `xml:"password,omitempty"`
	PrivateKey           string `xml:"privateKey,omitempty"`
	Passphrase           string `xml:"passphrase,omitempty"`
	FilePermissions      string `xml:"filePermissions,omitempty"`
	DirectoryPermissions string `xml:"directoryPermissions,omitempty"`
	Configuration        string `xml:"configuration,omitempty"`
}

type ServersType added in v1.146.0

type ServersType struct {
	ServerType []Server `xml:"server,omitempty"`
}

type Settings added in v1.146.0

type Settings struct {
	XMLName xml.Name `xml:"http://maven.apache.org/SETTINGS/1.0.0 settings"`
	Text    string   `xml:",chardata"`
	// Xmlns           xml.Attr `xml:"xmlns,attr"`
	//Xmlns           string `xml:"xmlns,attr"`
	Xsi             string `xml:"xmlns:xsi,attr"`
	SchemaLocation  string `xml:"xsi:schemaLocation,attr"`
	LocalRepository string `xml:"localRepository,omitempty"`
	InteractiveMode string `xml:"interactiveMode,omitempty"`
	Offline         string `xml:"offline,omitempty"`
	PluginGroups    struct {
		Text        string `xml:",chardata"`
		PluginGroup string `xml:"pluginGroup,omitempty"`
	} `xml:"pluginGroups,omitempty"`
	Servers ServersType `xml:"servers,omitempty"`
	Mirrors struct {
		Text   string `xml:",chardata"`
		Mirror []struct {
			Text     string `xml:",chardata"`
			ID       string `xml:"id,omitempty"`
			Name     string `xml:"name,omitempty"`
			URL      string `xml:"url,omitempty"`
			MirrorOf string `xml:"mirrorOf,omitempty"`
		} `xml:"mirror,omitempty"`
	} `xml:"mirrors,omitempty"`
	Proxies struct {
		Text  string `xml:",chardata"`
		Proxy []struct {
			Text          string `xml:",chardata"`
			ID            string `xml:"id,omitempty"`
			Active        string `xml:"active,omitempty"`
			Protocol      string `xml:"protocol,omitempty"`
			Host          string `xml:"host,omitempty"`
			Port          string `xml:"port,omitempty"`
			Username      string `xml:"username,omitempty"`
			Password      string `xml:"password,omitempty"`
			NonProxyHosts string `xml:"nonProxyHosts,omitempty"`
		} `xml:"proxy,omitempty"`
	} `xml:"proxies,omitempty"`
	Profiles struct {
		Text    string `xml:",chardata"`
		Profile []struct {
			Text string `xml:",chardata"`
			ID   string `xml:"id,omitempty"`
			// Activation struct {
			// 	Text            string `xml:",chardata"`
			// 	ActiveByDefault string `xml:"activeByDefault,omitempty"`
			// 	Jdk             string `xml:"jdk,omitempty"`
			// 	Os              struct {
			// 		Text    string `xml:",chardata"`
			// 		Name    string `xml:"name,omitempty"`
			// 		Family  string `xml:"family,omitempty"`
			// 		Arch    string `xml:"arch,omitempty"`
			// 		Version string `xml:"version,omitempty"`
			// 	} `xml:"os,omitempty"`
			// 	Property struct {
			// 		Text  string `xml:",chardata"`
			// 		Name  string `xml:"name,omitempty"`
			// 		Value string `xml:"value,omitempty"`
			// 	} `xml:"property,omitempty"`
			// 	File struct {
			// 		Text    string `xml:",chardata"`
			// 		Exists  string `xml:"exists,omitempty"`
			// 		Missing string `xml:"missing,omitempty"`
			// 	} `xml:"file,omitempty"`
			// } `xml:"activation,omitempty"`
			Repositories struct {
				Text       string `xml:",chardata"`
				Repository []struct {
					Text     string `xml:",chardata"`
					ID       string `xml:"id,omitempty"`
					Name     string `xml:"name,omitempty"`
					Releases struct {
						Text           string `xml:",chardata"`
						Enabled        string `xml:"enabled,omitempty"`
						UpdatePolicy   string `xml:"updatePolicy,omitempty"`
						ChecksumPolicy string `xml:"checksumPolicy,omitempty"`
					} `xml:"releases,omitempty"`
					Snapshots struct {
						Text           string `xml:",chardata"`
						Enabled        string `xml:"enabled,omitempty"`
						UpdatePolicy   string `xml:"updatePolicy,omitempty"`
						ChecksumPolicy string `xml:"checksumPolicy,omitempty"`
					} `xml:"snapshots,omitempty"`
					URL    string `xml:"url,omitempty"`
					Layout string `xml:"layout,omitempty"`
				} `xml:"repository,omitempty"`
			} `xml:"repositories,omitempty"`
			PluginRepositories struct {
				Text             string `xml:",chardata"`
				PluginRepository []struct {
					Text     string `xml:",chardata"`
					ID       string `xml:"id,omitempty"`
					Name     string `xml:"name,omitempty"`
					Releases struct {
						Text    string `xml:",chardata"`
						Enabled string `xml:"enabled,omitempty"`
					} `xml:"releases,omitempty"`
					Snapshots struct {
						Text    string `xml:",chardata"`
						Enabled string `xml:"enabled,omitempty"`
					} `xml:"snapshots,omitempty"`
					URL string `xml:"url,omitempty"`
				} `xml:"pluginRepository,omitempty"`
			} `xml:"pluginRepositories,omitempty"`
		} `xml:"profile,omitempty"`
	} `xml:"profiles,omitempty"`
	ActiveProfiles ActiveProfilesType `xml:"activeProfiles,omitempty"`
}

type SettingsDownloadUtils added in v1.62.0

type SettingsDownloadUtils interface {
	DownloadFile(url, filename string, header http.Header, cookies []*http.Cookie) error
	FileExists(filename string) (bool, error)
	Copy(src, dest string) (int64, error)
	MkdirAll(path string, perm os.FileMode) error
	FileWrite(path string, content []byte, perm os.FileMode) error
	FileRead(path string) ([]byte, error)
}

SettingsDownloadUtils defines an interface for downloading and storing maven settings files.

type Utils added in v1.107.0

type Utils interface {
	Stdout(out io.Writer)
	Stderr(err io.Writer)
	RunExecutable(e string, p ...string) error

	DownloadFile(url, filename string, header http.Header, cookies []*http.Cookie) error
	Glob(pattern string) (matches []string, err error)
	FileExists(filename string) (bool, error)
	Copy(src, dest string) (int64, error)
	MkdirAll(path string, perm os.FileMode) error
	FileWrite(path string, content []byte, perm os.FileMode) error
	FileRead(path string) ([]byte, error)
}

func NewUtilsBundle added in v1.107.0

func NewUtilsBundle() Utils

Jump to

Keyboard shortcuts

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