Repository navigation
fix: decouple test-jar skip from maven.test.skip [MJAR-138] - #612
Conversation
gnodet-bot
left a comment
There was a problem hiding this comment.
Re-reviewed after 7dee44e. Previous finding (incorrect @since 2.2 β @since 4.0.0-beta-2) is addressed.
No new issues. The property rebinding (maven.test.skip β maven.test.jar.skip) is clean, the Javadoc accurately describes the new behavior, and the IT covers the core scenario.
Metadata: no milestone set β suggest 4.0.0-beta-2.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
gnodet-bot
left a comment
There was a problem hiding this comment.
Re-reviewed after ec583d2. desruisseaux's assert style suggestion is addressed β verify.groovy now uses idiomatic Groovy assertions instead of the if/return false pattern, consistent with newer ITs. All previous findings resolved, no new issues.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
ascheman
left a comment
There was a problem hiding this comment.
Thanks β the direction is good: a dedicated maven.test.jar.skip property instead of overloading maven.test.skip, plus the clearer Javadoc. I'm fine with the code change itself.
I do want to push back fairly hard on the integration test, though, because as written it does not cover the fix at all.
src/it/mjar-138 runs clean package -DskipTests. But -DskipTests sets neither the old maven.test.skip binding nor the new maven.test.jar.skip one β so skip is false either way, the model test-jar is built and client compiles with and without this change. Revert the one-line property change on TestJarMojo.skip and re-run the IT: it stays green. So the test exercises a path that was never broken by MJAR-138 and does not distinguish the fixed plugin from the unfixed one β a green-by-design IT that quietly stops guarding the behavior it is named after.
The honest difficulty here is worth confronting in the test rather than side-stepping:
-Dmaven.test.skip=trueis what actually triggered MJAR-138, but it also skips test-compilation, somodel's test-jar would be empty andclientcould not resolveTestComponentβ the build would fail even with the fix.- On master
skipIfEmptydefaults tofalse, so after this change-Dmaven.test.skip=truenow produces an empty test-jar where before it produced none. The description saysskipIfEmptyalready handles the empty-test-jar case; with the default that is not so.
Could we please get an IT that actually fails on the unpatched plugin before this lands β e.g. assert that -Dmaven.test.jar.skip=true suppresses the test-jar while a normal build (or -DskipTests) still produces it β and have both the test and the PR description pin down the maven.test.skip + empty-test-jar contract explicitly?
Happy to write that IT myself and hand it to you (patch against this branch, or a follow-up) if that helps move it along β just say the word. The property and doc change are fine; I'd just really prefer not to merge it with a test that proves nothing about the change.
ec583d2 to
1db81ba
Compare
The test-jar goal's skip parameter was incorrectly bound to maven.test.skip, causing jar:test-jar to be skipped when -Dmaven.test.skip=true was passed. This breaks multi-module builds where a downstream module depends on the test-jar artifact (the reactor cannot resolve it). - Rebinds skip to maven.test.jar.skip (default false), decoupling it from maven.test.skip which also suppresses test compilation - Users who relied on -Dmaven.test.skip=true to suppress test-jar packaging should switch to -Dmaven.test.jar.skip=true - Adds IT mjar-138 verifying a multi-module build with -DskipTests still produces the test-jar and allows the client module to compile against it - Fixes @SInCE tag on the skip parameter Fixes: apache#308
1db81ba to
64b7056
Compare
Problem
Fixes #308 / MJAR-138.
The
test-jargoal'sskipparameter was bound to${maven.test.skip}. This meant passing-Dmaven.test.skip=trueβ which also skips test compilation β silently prevented the test-jar from being built. In multi-module projects where a downstream module has atest-jardependency, this broke the build.This is a long-standing (2010) tension between two intentional decisions:
maven.test.skip=trueto avoid producing an empty test-jar (tests weren't compiled)Solution
Rebind
skipfrom${maven.test.skip}to${maven.test.jar.skip}(defaultfalse).The MJAR-90 concern (empty test-jar) is already handled by
skipIfEmptyin modern versions. There is no longer a reason to couple test-jar packaging tomaven.test.skip.Users who want to skip test-jar packaging should now use
-Dmaven.test.jar.skip=true(or<skip>true</skip>in POM config β unchanged).Users who want to skip test execution without breaking downstream modules should use:
-DskipTests(Maven 3+)--skip-tests(Maven 4.1+, see #13233)Changes
TestJarMojo: rebindskipproperty frommaven.test.skipβmaven.test.jar.skipmjar-138: multi-module build with-DskipTestsβ verifies model test-jar is built and client can compile against it via the reactor