[#11449] Fix Mockito agent: use late binding @{} interpolation and extend to failsafe plugin (#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.
1 file changed
tree: 5f5afcdbbc59461e14252990be8350bd80c90afa
  1. .github/
  2. .idea/
  3. .mvn/
  4. apache-maven/
  5. api/
  6. compat/
  7. impl/
  8. its/
  9. src/
  10. .asf.yaml
  11. .git-blame-ignore-revs
  12. .gitattributes
  13. .gitignore
  14. CONTRIBUTING.md
  15. deploySite.sh
  16. doap_Maven.rdf
  17. Jenkinsfile
  18. LICENSE
  19. NOTICE
  20. pom.xml
  21. README.md
README.md

Apache Maven

Apache License, Version 2.0, January 2004 Reproducible Builds

Apache Maven is a software project management and comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project's build, reporting and documentation from a central piece of information.

If you think you have found a bug, please file an issue in the Maven Issue Tracker.

Documentation

More information can be found on Apache Maven Homepage. Questions related to the usage of Maven should be posted on the Maven User List.

Where can I get the latest release?

You can download the release source from our download page.

Contributing

If you are interested in the development of Maven, please consult the documentation first and afterward you are welcome to join the developers mailing list to ask questions or discuss new ideas/features/bugs etc.

Take a look into the contribution guidelines.

License

This code is under the Apache License, Version 2.0, January 2004.

See the NOTICE file for required notices and attributions.

Donations

Do you like Apache Maven? Then donate back to the ASF to support the development.

Quick Build

If you want to bootstrap Maven, you'll need:

  • Java 17+
  • Maven 3.9.0 or later
  • Run Maven, specifying a location into which the completed Maven distro should be installed:
    mvn -DdistributionTargetDir="$HOME/app/maven/apache-maven-4.1.x-SNAPSHOT" clean package