maven.star¶
Bump dependency, plugin and property versions in Maven pom.xml files.
Edits are line-based, so comments and formatting stay as they were. Each
<groupId>, <artifactId> and <version> is expected on its own line, as
Maven and most editors write them.
| Function | What it does |
|---|---|
poms |
Lists the repo's pom.xml files. |
set_property |
Sets a <properties> entry, such as java.version, in every pom.xml that defines it. |
set_dependency |
Sets the version of a dependency or plugin wherever a pom.xml declares one. |
poms¶
Lists the repo's pom.xml files.
Arguments
| Name | Description |
|---|---|
repo |
The repo passed to change(repo). |
Returns: The sorted paths of every pom.xml outside target directories.
Example
set_property¶
Sets a <properties> entry, such as java.version, in every pom.xml that defines it.
Arguments
| Name | Description |
|---|---|
repo |
The repo passed to change(repo). |
name |
The property name. |
value |
The new value. |
Returns: The list of paths that changed.
Example
set_dependency¶
Sets the version of a dependency or plugin wherever a pom.xml declares one.
A newer version already there is kept, so a campaign never lowers one.
Covers <dependency> and <plugin> entries, including those under
<dependencyManagement> and <pluginManagement>. When the version is
a property reference such as ${jackson.version}, the property is set
instead. A plugin without a <groupId> matches the group
org.apache.maven.plugins, as Maven assumes. Entries without a
<version> are left alone.
Arguments
| Name | Description |
|---|---|
repo |
The repo passed to change(repo). |
group |
The groupId. |
artifact |
The artifactId. |
version |
The new version. |
Returns: The list of paths that changed.
Example
set_dependency(repo, "com.fasterxml.jackson.core", "jackson-databind", "2.17.2")
set_dependency(repo, "org.slf4j", "slf4j-api", "2.0.16")
# returns ["pom.xml"]
pom.xml
<project>
<properties>
<jackson.version>2.15.2</jackson.version>
</properties>
<dependencies>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.7</version>
</dependency>
</dependencies>
</project>
pom.xml
<project>
<properties>
<jackson.version>2.17.2</jackson.version>
</properties>
<dependencies>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.16</version>
</dependency>
</dependencies>
</project>
Used in: jvm-dependency-bump