Maven
Description
The Maven crawler looks recursively for all pom.xml files from a specific root directory, and tries to update the dependencies declared in each one.
Two things are updated per POM:
every entry under
<dependencies>the
<parent>POM, when one is declared
This crawler is enabled by default, so it can be used either automatically by running updatecli diff from a directory containing the files to update, or by providing a manifest.
The automatic discovery behavior can be tuned by providing a YAML manifest with a maven crawler in top-level directive autodiscovery as explained in the "Autodiscovery" page.
Generated manifests
Repositories, mirrors, and credentials
The repository used to look up a dependency is taken from the <repositories> declared in the POM, falling back to Maven Central.
Updatecli also reads settings.xml, looked up in this order:
settings.xmlnext to the POM$HOME/.m2/settings.xml
From it, Updatecli applies:
mirrors - a repository whose
idor URL matches a<mirrorOf>rule is replaced by the mirror, including thecentralshorthand,server credentials - the
<username>and<password>of the<server>whoseidmatches the repository.
The MAVEN_MIRROR_URL environment variable is honoured, and ${env.VARIABLE} expressions inside settings.xml are interpolated.
Version filtering
Unlike most crawlers, the version filter defaults to kind latest, because Maven coordinates do not reliably follow semantic versioning. Set an explicit versionfilter to constrain updates.
More details on the "Version Filtering" page.
Limitations
A dependency whose
<version>is a property reference, such as${junit.version}, is skipped. Updatecli does not resolve the property to find the literal it should rewrite.Only files named exactly
pom.xmlare scanned.
Manifest
Parameters
| Name | Type | Description | Required |
|---|---|---|---|
| ignore | array | “ignore” defines rules to exclude matching Maven dependencies from the autodiscovery. remark:
| |
| artifactids | object | “artifactids” defines the Maven artifacts to match, keyed by artifact ID. remark:
| |
| groupids | array | “groupids” defines the Maven group IDs to match. remark:
| |
| path | string | “path” defines a pom.xml path pattern. remark:
| |
| only | array | “only” defines rules to restrict the autodiscovery to matching Maven dependencies. remark:
| |
| artifactids | object | “artifactids” defines the Maven artifacts to match, keyed by artifact ID. remark:
| |
| groupids | array | “groupids” defines the Maven group IDs to match. remark:
| |
| path | string | “path” defines a pom.xml path pattern. remark:
| |
| rootdir | string | “rootdir” defines the directory where the crawler starts searching for pom.xml files. default: the scm directory when “scmid” is set, otherwise the directory relative paths resolve from, by default the working directory. remark:
| |
| versionfilter | object | “versionfilter” defines the version filter used by the generated manifests. default: kind “latest”, the latest version. remark:
example: | |
| kind | string | “kind” defines the versioning scheme used to select a version. default: latest remark:
example:
| |
| pattern | string | “pattern” defines the version pattern, according to “kind”. default:
remark:
example:
| |
| regex | string | “regex” defines the regular expression extracting the version from each entry. remark:
example:
| |
| replaceall | object | “replaceall” applies a regular expression replacement to each version before filtering. remark:
example: turns “curl-8_15_0” into “curl-8.15.0”. | |
| pattern | string | “pattern” defines the regular expression matching the text to replace. example:
| |
| replacement | string | “replacement” defines the text replacing each match of “pattern”. remark:
example:
| |
| strict | boolean | “strict” enforces strict semantic versioning rules when parsing versions. default: false remark:
|
Example
# updatecli.d/default.yaml
name: "Maven autodiscovery using git scm"
scms:
default:
kind: git
spec:
url: https://github.com/olblak/jenkins-datadog-plugin.git
branch: master
autodiscovery:
# scmid is applied to all crawlers
scmid: default
crawlers:
maven:
# To ignore specific path
#ignore:
# - path: <filepath relative to scm repository>
#only:
# - path: <filepath relative to scm repository>