[#11449] Fix Mockito agent: use late binding @{} interpolation (backport to 4.0.x)#12415
Merged
gnodet merged 1 commit intoJul 3, 2026
Merged
Conversation
…and extend to failsafe plugin (apache#12369) * [MNG-11449] Fix Mockito agent: use late binding @{} interpolation and extend to failsafe plugin The mockito profile activated by dependency:properties used Maven property interpolation (\) which resolves at POM parse time - before the dependency:properties goal runs and sets the org.mockito:mockito-core:jar property. This caused the javaagent path to remain unresolved. Fix: use Surefire/Failsafe late-binding property interpolation (@{...}) which resolves the property at test execution time, after dependency:properties has already set it. Also: - Restore @{jacocoArgLine} placeholder (was dropped in previous attempt) - Extend the profile to cover maven-failsafe-plugin as well Fixes: https://issues.apache.org/jira/browse/MNG-11449 * [MNG-11449] Fix Mockito agent profile collision with JaCoCo profile When both jacoco and mockito profiles were active, the jacoco profile's surefire configuration overrode the mockito profile's surefire pluginManagement configuration. This caused the mockito javaagent to be silently dropped for unit tests. Fix: Refactor the surefire and failsafe argLine to be composed dynamically via properties: - Define argLine.xmx (default: -Xmx256m) and argLine.mockito (default: empty) in the root POM properties. - Update default pluginManagement configuration for surefire/failsafe to: \ @{jacocoArgLine} \ - Modify the mockito profile to only set argLine.mockito property to the mockito javaagent. - Modify the jacoco profile to only override argLine.xmx property to -Xmx1G and remove the direct surefire argLine override. This ensures both profiles can be active simultaneously without overriding each other's configurations.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #12369 to
maven-4.0.x.The mockito profile used Maven property interpolation (
${...}) which resolves at POM parse time — before thedependency:propertiesgoal runs and sets theorg.mockito:mockito-core:jarproperty. This caused the javaagent path to remain unresolved.Fix: use Surefire/Failsafe late-binding property interpolation (
@{...}) which resolves the property at test execution time, afterdependency:propertieshas already set it.Also:
@{jacocoArgLine}placeholdermaven-failsafe-pluginas wellCherry-picked from 6f46443 (master).
Fixes: #11449