Skip to content

Commit ace68d3

Browse files
authored
feat(maven-workspace): update all discovered pom.xml within the components (#1667)
* feat(maven-workspace): can update any discovered pom.xml within the repository * fix: load new plugin option from manifest * docs: add comments for new helper methods * fix: fetch pom.xml content * fix: snapshot versioning bumps * build: restore c8 test coverage * fix merge conflict and tests * docs: add a description of what FAKE_COMMIT is used for * fix: default considerAllArtifacts to true * docs: update docs for new default value
1 parent 21c1e1d commit ace68d3

23 files changed

Lines changed: 781 additions & 101 deletions

File tree

__snapshots__/maven-workspace.js

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,70 @@ Release notes for path: maven3, releaseType: maven
4444
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
4545
`
4646

47+
exports['MavenWorkspace plugin run can consider all artifacts 1'] = `
48+
:robot: I have created a release *beep* *boop*
49+
---
50+
51+
52+
<details><summary>multi1: 1.1.2</summary>
53+
54+
Release notes for path: multi1, releaseType: java-yoshi
55+
</details>
56+
57+
<details><summary>com.google.example:my-bom: 1.2.4</summary>
58+
59+
### Dependencies
60+
61+
* The following workspace dependencies were updated
62+
* com.google.example:multi1-bom bumped to 1.1.2,
63+
* com.google.example:multi1-sub1 bumped to 2.2.3,
64+
* com.google.example:multi1-sub2 bumped to 3.3.4
65+
</details>
66+
67+
---
68+
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
69+
`
70+
71+
exports['MavenWorkspace plugin run can consider all artifacts 2'] = `
72+
<?xml version="1.0" encoding="UTF-8"?>
73+
<project>
74+
<groupId>com.google.example</groupId>
75+
<artifactId>my-bom</artifactId>
76+
<version>1.2.4</version>
77+
<dependencyManagement>
78+
<dependencies>
79+
<dependency>
80+
<groupId>com.google.example</groupId>
81+
<artifactId>multi1-bom</artifactId>
82+
<version>1.1.2</version>
83+
<type>pom</type>
84+
<scope>import</scope>
85+
</dependency>
86+
<dependency>
87+
<groupId>com.google.example</groupId>
88+
<artifactId>multi1-sub1</artifactId>
89+
<version>2.2.3</version>
90+
</dependency>
91+
<dependency>
92+
<groupId>com.google.example</groupId>
93+
<artifactId>multi1-sub2</artifactId>
94+
<version>3.3.4</version>
95+
</dependency>
96+
<dependency>
97+
<groupId>com.google.example</groupId>
98+
<artifactId>multi2-sub1</artifactId>
99+
<version>5.5.5</version>
100+
</dependency>
101+
<dependency>
102+
<groupId>com.google.example</groupId>
103+
<artifactId>multi2-sub2</artifactId>
104+
<version>6.6.6</version>
105+
</dependency>
106+
</dependencies>
107+
</dependencyManagement>
108+
</project>
109+
`
110+
47111
exports['MavenWorkspace plugin run handles a single maven package 1'] = `
48112
:robot: I have created a release *beep* *boop*
49113
---

docs/manifest-releaser.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,8 +478,13 @@ way of managing a Rust monorepo with release-please.
478478

479479
The `maven-workspace` plugin operates similarly to the `node-workspace` plugin,
480480
but on a multi-artifact Maven workspace. It builds a dependency graph of all
481-
discovered `pom.xml` files that are configured in the manifest config and updates
482-
any packages that were directly bumped by release-please.
481+
discovered `pom.xml` files and updates any packages that were directly bumped
482+
by release-please.
483+
484+
If you have additional `pom.xml` files that are not directly configured in your
485+
manifest and you want to skip updating them, then you can set the
486+
`considerAllArtifacts` option to `false`. If you do so, the plugin will only
487+
look at the `pom.xml` files configured in the manifest.
483488

484489
### linked-versions
485490

schemas/config.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,10 @@
292292
"merge": {
293293
"description": "Whether to merge in-scope pull requests into a combined release pull request. Defaults to `true`.",
294294
"type": "boolean"
295+
},
296+
"considerAllArtifacts": {
297+
"description": "Whether to analyze all packages in the workspace for cross-component version bumping. This currently only works for the maven-workspace plugin. Defaults to `true`.",
298+
"type": "boolean"
295299
}
296300
}
297301
},

src/factories/plugin-factory.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ import {MavenWorkspace} from '../plugins/maven-workspace';
2929
import {ConfigurationError} from '../errors';
3030
import {SentenceCase} from '../plugins/sentence-case';
3131
import {GroupPriority} from '../plugins/group-priority';
32+
import {Logger} from '../util/logger';
33+
import {WorkspacePluginOptions} from '../plugins/workspace';
3234

3335
export interface PluginFactoryOptions {
3436
type: PluginType;
@@ -42,6 +44,9 @@ export interface PluginFactoryOptions {
4244

4345
// workspace options
4446
updateAllPackages?: boolean;
47+
considerAllArtifacts?: boolean;
48+
49+
logger?: Logger;
4550
}
4651

4752
export type PluginBuilder = (options: PluginFactoryOptions) => ManifestPlugin;
@@ -60,21 +65,30 @@ const pluginFactories: Record<string, PluginBuilder> = {
6065
options.github,
6166
options.targetBranch,
6267
options.repositoryConfig,
63-
options
68+
{
69+
...options,
70+
...(options.type as WorkspacePluginOptions),
71+
}
6472
),
6573
'node-workspace': options =>
6674
new NodeWorkspace(
6775
options.github,
6876
options.targetBranch,
6977
options.repositoryConfig,
70-
options
78+
{
79+
...options,
80+
...(options.type as WorkspacePluginOptions),
81+
}
7182
),
7283
'maven-workspace': options =>
7384
new MavenWorkspace(
7485
options.github,
7586
options.targetBranch,
7687
options.repositoryConfig,
77-
options
88+
{
89+
...options,
90+
...(options.type as WorkspacePluginOptions),
91+
}
7892
),
7993
'sentence-case': options =>
8094
new SentenceCase(

src/manifest.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ export interface SentenceCasePluginConfig extends ConfigurablePluginType {
202202
}
203203
export interface WorkspacePluginConfig extends ConfigurablePluginType {
204204
merge?: boolean;
205+
considerAllArtifacts?: boolean;
205206
}
206207
export interface GroupPriorityPluginConfig extends ConfigurablePluginType {
207208
groups: string[];

0 commit comments

Comments
 (0)