craft_parts.utils.maven.common module

Utilities for Maven projects and settings.

class craft_parts.utils.maven.common.MavenArtifact(group_id, artifact_id, version, field_name='Dependency')[source]

Bases: object

A dataclass for Maven artifacts.

Parameters:
  • group_id (str)

  • artifact_id (str)

  • version (str)

  • field_name (str)

artifact_id: str
field_name: str = 'Dependency'
classmethod from_element(element, namespaces)[source]

Create a MavenArtifact from an XML artifact element.

Parameters:
  • element (Element)

  • namespaces (dict[str, str])

Return type:

Self

classmethod from_pom(pom)[source]

Create a MavenArtifact from a pom file.

Parameters:

pom (Path)

Return type:

Self

group_id: str
classmethod update_versions(project, namespaces, existing)[source]

Update all of the versions for this project as necessary.

Parameters:
  • project (Element)

  • namespaces (dict[str, str])

  • existing (dict[str, dict[str, set[str]]])

Return type:

None

version: str
class craft_parts.utils.maven.common.MavenPlugin(group_id, artifact_id, version, field_name='Plugin')[source]

Bases: MavenArtifact

A dataclass for Maven plugins.

These are different because plugins have a default groupId.

Parameters:
  • group_id (str)

  • artifact_id (str)

  • version (str)

  • field_name (str)

field_name: str = 'Plugin'
classmethod from_element(element, namespaces)[source]

Create a MavenPlugin from an XML plugin element.

If no groupId is found, ‘org.apache.maven.plugins’ will be used.

For more information on the default plugin group, see: https://maven.apache.org/guides/mini/guide-configuring-plugins.html

Parameters:
  • element (Element)

  • namespaces (dict[str, str])

Return type:

Self

exception craft_parts.utils.maven.common.MavenXMLError(message)[source]

Bases: BaseException

An error encountered while parsing XML for Maven projects.

Parameters:

message (str)

message: str
craft_parts.utils.maven.common.create_maven_settings(*, part_info, set_mirror)[source]

Create a Maven configuration file.

The settings file contains additional configuration for Maven, such as proxy parameters.

If it detects that no configuration is necessary, it will return None and do nothing.

Parameters:
  • part_info (PartInfo) – The part info for the part invoking Maven.

  • set_mirror (bool) – Whether to configure for a local build.

Return type:

Path | None

Returns:

Returns a Path object to the settings file if one is created, otherwise None.

craft_parts.utils.maven.common.update_pom(*, part_info, add_distribution, self_contained)[source]

Update the POM file of a Maven project.

Parameters:
  • part_info (PartInfo) – Information about the invoking part.

  • add_distribution (bool) – Whether or not to configure the mvn deploy location.

  • self_contained (bool) – Whether or not to patch version numbers with what is actually available.

Return type:

None