Skip to content

Let the excludes IT see the POM pair Maven 4 installs - #332

Merged
slachiewicz merged 1 commit into
apache:masterfrom
slachiewicz:it-maven4-build-pom
Aug 8, 2026
Merged

Let the excludes IT see the POM pair Maven 4 installs#332
slachiewicz merged 1 commit into
apache:masterfrom
slachiewicz:it-maven4-build-pom

Conversation

@slachiewicz

Copy link
Copy Markdown
Member

sign-release-with-excludes fails under Maven 4 with:

java.lang.Exception: Unexpected file .../org/apache/maven/its/gpg/srwe/test/1.0/test-1.0-build.pom.asc

Maven 4 installs a build POM alongside the consumer POM, and gpg:sign signs both, so four POM files reach the local repository where Maven 3 puts two:

maven 3                    maven 4
_remote.repositories       _remote.repositories
                           test-1.0-build.pom        <- new
                           test-1.0-build.pom.asc    <- new
test-1.0.jar               test-1.0.jar
test-1.0.jar.asc           test-1.0.jar.asc
test-1.0.pom               test-1.0.pom
test-1.0.pom.asc           test-1.0.pom.asc

Those two are the only new files; the rest of the directory is unchanged.

Why this IT and not the others

Ten of the ITs that keep an expectedFiles list iterate the list and assert each file exists, so extra files never bother them. This one iterates artifactDir.listFiles() and rejects anything not on the list. That inversion is deliberate: the project runs gpg:sign twice, and the point is to prove the second run does not sign the first run's signatures. A presence check cannot show the absence of a .asc.asc.

So the fix adds the two names to expectedFiles rather than adding a second continue. Every skip is a hole in the one check whose value is that it is exhaustive. The names cost nothing on Maven 3, which installs neither.

The removed clause

//maven4: skip consumer POM
if (fileName.endsWith("consumer.pom") || fileName.endsWith("consumer.pom.asc")) {

This has stopped matching anything. It arrived with 0771b61 ([MGPG-110], March 2024), when Maven 4 installed the consumer POM as *-consumer.pom. Maven 4 now installs the consumer POM under the plain test-1.0.pom name, and it is the build POM that carries a suffix — so the guard silently stopped guarding. Dropping it leaves one mechanism instead of two.

If a Maven 4 version that still installs *-consumer.pom is ever added to the matrix this would need revisiting, but the matrix is 4.0.0-rc-6 and 3.10.0-rc-1 today.

Verification

Ran the IT locally against both, cleaning target between runs:

Maven 3.9.16 Maven 4
before passes failsUnexpected file …test-1.0-build.pom.asc
after passes passes

Both invoker executions (the gpg signer and the bc signer) pass in each green run.

Follow-up, not in this PR

Unlike its ten siblings, this IT never asserts that the expected files are present — it only rejects extras, so it would pass if gpg signed nothing at all. Worth adding, but it is a change to what the test proves rather than a Maven 4 fix.

This unblocks #330, which turns the Maven 4 matrix leg on and is currently red for exactly this reason.

Maven 4 installs a build POM next to the consumer POM, and gpg signs
both, so four POM files land in the local repository instead of two.
sign-release-with-excludes is the only IT that walks the installed
directory and rejects anything not on its list -- it has to, because it
signs twice and its job is to prove the second run creates no .asc.asc
-- so the two extra names made it fail under Maven 4.

Add them to the list rather than skipping them, to keep the check
exhaustive. The names are inert on Maven 3, which installs neither.

The clause that skipped *consumer.pom had stopped matching anything:
Maven 4 installs the consumer POM under the plain artifact name these
days, and it is the build POM that carries the suffix.
@slachiewicz slachiewicz added the bug Something isn't working label Aug 8, 2026
@slachiewicz
slachiewicz merged commit 17f4de8 into apache:master Aug 8, 2026
11 checks passed
@github-actions github-actions Bot added this to the 3.2.9 milestone Aug 8, 2026
@slachiewicz
slachiewicz deleted the it-maven4-build-pom branch August 8, 2026 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant