Fix deprecated Maven testing API compatibility
Restored Maven 4 compatibility for deprecated plugin-testing APIs by honoring the legacy `@Basedir` annotation and restoring the five-argument `ProducedArtifactStub` constructor.
apache/maven · #12683
Compatibility safeguard
Deprecated Maven plugin tests now honor their intended base directory instead of silently running against the wrong model while legacy APIs remain supported.
Problem
After Maven's testing APIs moved packages in 4.0.0-rc-6, deprecated annotations still compiled but `MojoExtension` ignored the legacy `@Basedir`. Downstream plugin tests could silently run against Maven's default model, while callers of the deprecated `ProducedArtifactStub` constructor failed to compile because constructors are not inherited.
Approach
Added replacement-first lookup with fallback to the deprecated `@Basedir`, restored the legacy five-argument constructor by delegating to the replacement stub, and added focused tests for deprecated annotation behavior and constructor source compatibility.
Impact and scope
- Prevents false-positive Maven plugin tests that compile successfully but execute against the wrong project model.
- Preserves source compatibility for downstream plugins during the Maven 4 testing API migration window.
- Keeps the replacement annotation authoritative while making the documented deprecated compatibility layer functional for its remaining lifetime.
Validation
- Added regression coverage that verifies deprecated annotation injection uses the configured test base directory and mojo parameters.
- Added a constructor compatibility test covering group, artifact, classifier, version, and extension values.
- PR evidence reports full Maven verification, focused `maven-testing` verification, maintainer approval, and upstream merge.