Skip to content

Commit 79458ae

Browse files
Make the sample-pom sync actually reach the release commit
Rehearsing release:prepare on a throwaway clone showed the sync was writing the right values and losing them: maven-release-plugin transforms only reactor poms, so the rewrite stayed an unstaged working-tree change and the tag shipped 2.0.2-SNAPSHOT. The target now stages the poms itself, and the commit phase takes what is staged. completionGoals is gone as well -- it ran after the bump to the next SNAPSHOT and needed artifacts that do not exist yet, aborting the release after tagging. Samples therefore keep the released version between releases, which beats pointing at a SNAPSHOT. Verified end to end: exit 0, tag carries 2.0.2 in all three, development commit lands. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent f2f3ebf commit 79458ae

2 files changed

Lines changed: 39 additions & 7 deletions

File tree

‎pom.xml‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1008,7 +1008,12 @@
10081008
here means the rewrite lands in the release commit and the tag,
10091009
next to the versions release:prepare rewrites itself. -->
10101010
<preparationGoals>clean verify antrun:run@sync-userguide-sample-versions</preparationGoals>
1011-
<completionGoals>antrun:run@sync-userguide-sample-versions</completionGoals>
1011+
<!-- No completionGoals. It would run after the poms are bumped to the
1012+
next SNAPSHOT, and invoking any goal across the reactor then needs
1013+
that SNAPSHOT's artifacts, which do not exist yet, so the release
1014+
aborts after tagging. So the samples keep the released version
1015+
after a release, which is what you want anyway: master's samples
1016+
point at a real artifact instead of a SNAPSHOT. -->
10121017
</configuration>
10131018
</plugin>
10141019
<plugin>
@@ -1399,6 +1404,18 @@
13991404
<contains text="&lt;axis2.version&gt;${project.version}&lt;/axis2.version&gt;"/>
14001405
</fileset>
14011406
</resourcecount>
1407+
<!-- Stage them. maven-release-plugin only transforms reactor
1408+
poms, so without this the rewrite stays an unstaged working-tree
1409+
change and the release commit and tag ship the old version;
1410+
verified by rehearsing release:prepare on a throwaway clone.
1411+
The commit phase takes whatever is staged, so this is enough.
1412+
failonerror is deliberate: a release that cannot stage these
1413+
must stop rather than tag the wrong versions. -->
1414+
<exec executable="git" dir="${basedir}" failonerror="true">
1415+
<arg value="add"/>
1416+
<arg value="--"/>
1417+
<arg value="modules/samples/userguide/src/userguide"/>
1418+
</exec>
14021419
<fail message="axis2.version sync found no userguide sample poms under modules/samples/userguide/src/userguide - the samples moved or were renamed, and the sync is now doing nothing">
14031420
<condition>
14041421
<equals arg1="${userguide.pom.count}" arg2="0"/>

‎src/site/markdown/release-process.md‎

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,27 @@ You may also execute a dry run of the release process: mvn release:prepare -Ddry
135135
rewrite, and run the goal by hand if you are cutting a release any other way.
136136
Left unsynced, the shipped samples point at a SNAPSHOT that does not exist.
137137

138-
Two things to know about it. The execution is marked `<inherited>false</inherited>`
139-
because `preparationGoals` runs across the whole reactor, and an inherited copy
140-
resolves `${basedir}` to each child module. And a `-DdryRun=true` run does **not**
141-
exercise the rewrite: a dry run never replaces `pom.xml`, so the goal sees the
142-
SNAPSHOT version and writes that back. Only a real `release:prepare` transforms
143-
the poms first, which is why the check above is on the release commit.
138+
Three things to know about it, all found by rehearsing `release:prepare` against a
139+
throwaway clone:
140+
141+
- The execution is `<inherited>false</inherited>`, because `preparationGoals` runs
142+
across the whole reactor and an inherited copy resolves `${basedir}` to each
143+
child module.
144+
- The target stages the rewritten poms with `git add` itself. The release plugin
145+
only transforms *reactor* poms, so without that the rewrite stays an unstaged
146+
working-tree change and the release commit and tag ship the old version. The
147+
commit phase takes whatever is staged, which is why staging is sufficient.
148+
- There is no `completionGoals`. Anything invoked there runs after the poms are
149+
bumped to the next SNAPSHOT and needs that SNAPSHOT's artifacts, which do not
150+
exist yet -- the release aborts after tagging. So after a release the sample poms
151+
keep the released version rather than moving to the next SNAPSHOT. That is
152+
deliberate: master's samples then point at a real published artifact, and the
153+
next release rewrites them again.
154+
155+
A `-DdryRun=true` run does **not** exercise any of this. A dry run never replaces
156+
`pom.xml`, so the goal sees the SNAPSHOT version and writes it straight back, and no
157+
commit happens at all. Only a real `release:prepare` transforms the poms first,
158+
which is why the check above is on the release commit.
144159

145160
The same class of problem bites any sample kept out of the reactor:
146161
`swagger-server` sat at `2.0.1-SNAPSHOT` through the whole 2.0.1 cycle because

0 commit comments

Comments
 (0)