Skip to content

Commit cd90686

Browse files
authored
Merge branch 'main' into dependabot/maven/com.fasterxml.jackson.dataformat-jackson-dataformat-yaml-2.21.0
2 parents 4e3e578 + d21d97b commit cd90686

155 files changed

Lines changed: 4003 additions & 271 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"changesets": minor
3+
---
4+
5+
Add support for the `independent` version strategy, allowing sub-modules in a multi-module Maven project to be versioned independently of each other.
6+
7+
The prepare→release handoff has moved from the single-line `.changeset/VERSION` file to a per-artifactId map in `.changeset/VERSIONS` (plural). The current version is now read directly from each module's `pom.xml` rather than from the version file. Any pre-existing `.changeset/VERSION` file is no longer consulted and can be safely deleted.

README.md

Lines changed: 128 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,96 @@ users recognize the ways of working and feel at home.
88

99
This is it, at the moment. Stay tuned for more docs later on, thanks!
1010

11+
## Versioning strategies
12+
13+
By default every module in the Maven reactor shares one version (the **fixed** strategy) — any changeset bumps every module
14+
to the same new version. This matches the typical Maven convention where child modules inherit `<version>` from the parent.
15+
16+
To opt into per-module versioning, drop a `.changeset/config.json` at the reactor root:
17+
18+
```json
19+
{
20+
"versioning": "independent",
21+
"linked": [["module-a", "module-b"]],
22+
"fixed": [["module-c", "module-d"]]
23+
}
24+
```
25+
26+
- **`fixed` (default)** — entire reactor bumps as one.
27+
- **`independent`** — each Maven module tracks its own version. Optional `linked` and `fixed` arrays group some modules:
28+
- **`linked` group**: members that have changesets bump together to the same new version; members without changesets stay where they are. The new version is the *highest current version in the group* bumped by the *highest level among changesets touching the group*.
29+
- **`fixed` group**: every member of the group bumps together, even members without their own changesets.
30+
31+
A changeset's frontmatter lists modules by `artifactId`:
32+
33+
```
34+
---
35+
"module-a": minor
36+
"module-b": patch
37+
---
38+
39+
Description of the change.
40+
```
41+
42+
The same `artifactId` cannot appear in more than one group; that is a config validation error.
43+
44+
### Independent versioning and `<version>` declarations
45+
46+
For `independent` (or `linked` / `fixed` sub-groups) to actually update individual submodule versions, each Maven submodule
47+
must declare its own `<version>` in its `pom.xml`. Submodules that inherit `<version>` from the parent only bump together
48+
with the parent.
49+
50+
## BOM (Bill of Materials) support
51+
52+
If your reactor contains a BOM — a `pom`-packaged module whose `<dependencyManagement>` pins sibling modules' versions via
53+
`<properties>` (the Spring Boot convention) — opt in via `.changeset/config.json`:
54+
55+
```json
56+
{
57+
"versioning": "independent",
58+
"bom": {
59+
"module": "fortnox-spring-boot-dependencies",
60+
"consumerParent": "fortnox-spring-boot-starter-parent"
61+
}
62+
}
63+
```
64+
65+
Behavior:
66+
67+
- **The BOM auto-bumps** at the max level of any tracked module's bump (any reactor module that pins through the BOM's
68+
`<dependencyManagement>`). Explicit changesets targeting the BOM still work — they combine with the synthesized level.
69+
- **The BOM's `<properties>`** that pin sibling versions are rewritten on `prepare` (to the next `-SNAPSHOT`) and on
70+
`release` (to the release version). The mapping is discovered by walking the BOM's `<dependencyManagement>`; you don't
71+
have to name properties by any convention.
72+
- **`consumerParent`** (optional) is the module a consumer sets as their `<parent>`. It typically has no `<version>` of its
73+
own and inherits from the BOM via Maven parent inheritance. When set, it is *excluded* from the plan (no own bump) and is
74+
used as the changelog header so consumers see entries named after the artifact they actually pin. Its `<parent>`
75+
reference is updated when the BOM bumps. Validation: the artifactId must exist in the reactor, and if it declares its own
76+
`<version>` it must match the BOM's.
77+
- **Changelog rendering** in BOM mode collapses to a single top-level release header, with one sub-section per bumped
78+
module (including the BOM, which gets a synthesized `Pinned version updates` block listing the new sibling versions).
79+
80+
### Releasing a starter without cutting a BOM release
81+
82+
Pass `-DskipBom=true` to `changesets:prepare` to bypass BOM behavior for that invocation. The starters bump as in plain
83+
independent mode, the BOM's pom is left untouched (version *and* pinned properties), and the changelog falls back to the
84+
standard per-module sections. The `bom` block in `.changeset/config.json` stays in place — `skipBom` is a per-run override,
85+
not a config change. Use it when you want to ship a quick starter patch between full BOM releases.
86+
87+
## How `prepare` and `release` interact
88+
89+
`changesets:prepare` (aggregator goal, runs once at the reactor root) reads all changesets in `.changeset/`, computes a new
90+
version per affected module, writes the new release versions to `.changeset/VERSIONS` (a properties file keyed by
91+
artifactId), updates each affected submodule's pom to the next `*-SNAPSHOT`, and prepends a release block to the root
92+
`CHANGELOG.md`.
93+
94+
`changesets:release` reads `.changeset/VERSIONS` and writes each module's pom to its release version. The `.changeset/VERSIONS`
95+
file is the handoff between the two goals.
96+
97+
> **Upgrading from an earlier version:** the previous single-file `.changeset/VERSION` (uppercase, no `S`) is no longer read
98+
> or written. The current version is now taken from each module's `pom.xml` directly, and the prepare→release handoff lives
99+
> in `.changeset/VERSIONS`. If you have a leftover `.changeset/VERSION` file, it is unused and safe to delete.
100+
11101
## Dependency updates
12102
Due to the way automated dependency update bots like Dependabot and Renovate work, there is often a large influx of automated changesets that are not easy to merge into the normal changelog. They can also be the source of an unwanted amount of noise in the changelog.
13103

@@ -26,17 +116,32 @@ Dependencies that have been updated to new versions multiple times between relea
26116

27117
## Release Maven Plugin Integration
28118

29-
To delegate versioning to the Release Maven Plugin, you can use the `ChangesetsVersionPolicy` together with the `useReleasePluginIntegration` flag:
119+
You can hand versioning off to the maven-release-plugin by wiring in `ChangesetsVersionPolicy`.
30120

31-
```
121+
### When to use it
122+
123+
**Recommended:** fixed versioning (the default) — single-module or multi-module. Every module bumps together to one
124+
version, one tag, one release commit.
125+
126+
**Not recommended:** independent versioning. Maven-release-plugin's model is *release the whole reactor atomically*
127+
every reactor module gets a release version, a tag, and a next-dev bump, whether it was targeted by a changeset or not.
128+
That fights the point of `independent`, where you only want to release modules that actually changed. For independent
129+
versioning, use plain `changesets:prepare` + `changesets:release` (see [How `prepare` and `release` interact](#how-prepare-and-release-interact))
130+
and release-plugin is not recommended.
131+
132+
### Setup
133+
134+
Configure both plugins in the reactor POM:
135+
136+
```xml
32137
<build>
33138
<plugins>
34139
<plugin>
35140
<groupId>se.fortnox.changesets</groupId>
36141
<artifactId>changesets-maven-plugin</artifactId>
37142
<version>${changesets.plugin.version}</version>
38143
<configuration>
39-
<useReleasePluginIntegration>true</useReleasePluginIntegration> <!-- Disables version updates in prepare goal -->
144+
<useReleasePluginIntegration>true</useReleasePluginIntegration>
40145
</configuration>
41146
</plugin>
42147
<plugin>
@@ -45,6 +150,7 @@ To delegate versioning to the Release Maven Plugin, you can use the `ChangesetsV
45150
<configuration>
46151
<projectVersionPolicyId>changesets</projectVersionPolicyId>
47152
<tagNameFormat>v@{project.version}</tagNameFormat>
153+
<interactive>false</interactive>
48154
</configuration>
49155
<dependencies>
50156
<dependency>
@@ -55,6 +161,24 @@ To delegate versioning to the Release Maven Plugin, you can use the `ChangesetsV
55161
</dependencies>
56162
</plugin>
57163
</plugins>
164+
</build>
165+
```
166+
167+
### Flow
168+
169+
```
170+
mvn changesets:prepare
171+
git add . && git commit -m "chore: prepare release"
172+
mvn release:prepare release:perform
58173
```
59174

60-
Goals should then be invoked as `changesets:prepare release:prepare release:perform`. `changesets:release` should *not* be used.
175+
With `useReleasePluginIntegration=true`, `changesets:prepare` writes `.changeset/VERSIONS` and `CHANGELOG.md` but
176+
does not touch any poms. `ChangesetsVersionPolicy` then reads `VERSIONS` and tells release-plugin the release +
177+
next-dev version per module. All pom rewrites happen in release-plugin's own commit — one clean "release X" commit
178+
in history instead of two.
179+
180+
`changesets:release` is *not* used in this flow.
181+
182+
If you'd rather have `changesets:prepare` update the poms itself (e.g. to inspect them before triggering the
183+
release-plugin), omit `useReleasePluginIntegration`. The trade-off is an extra "chore: prepare release" commit
184+
before `release:prepare` runs.

0 commit comments

Comments
 (0)