You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "slachiewicz (via GitHub)" <gi...@apache.org> on 2026/08/04 12:09:09 UTC

[I] maven-testing: deprecated org.apache.maven.api.plugin.testing annotations compile but are silently ignored [maven]

slachiewicz opened a new issue, #12678:
URL: https://github.com/apache/maven/issues/12678

   The `org.apache.maven.api.plugin.testing` package was relocated to `org.apache.maven.testing.plugin` in 4.0.0-rc-6 (`8857e0eb18`, "Deprecate testing classes in org.apache.maven.api, add new ones in org.apache.maven.testing"). Deprecated classes remain under the old names, so plugins keep compiling — but `MojoExtension` only recognises the **new** annotation types, so a plugin that has not moved its imports silently stops working.
   
   `findInjectMojoAttrs` returns null for the deprecated `@InjectMojo`, so the `@Basedir` pom is never read and the mojo is handed `MojoExtension`'s built-in `defaultModel` instead of the test project. Nothing warns; the test simply runs against the wrong model.
   
   In maven-jar-plugin this surfaced as:
   
   ```
   JarMojoTest.jarTestEnvironment:48 expected: <foo> but was: <myGroupId>
   ```
   
   `foo` is the groupId in the `@Basedir` test pom; `myGroupId` is `MojoExtension`'s default. Bisected: passes on 4.0.0-rc-4 and 4.0.0-rc-5, fails on rc-6. Pointing the imports at `org.apache.maven.testing.plugin` fixes it (apache/maven-jar-plugin#573).
   
   In maven-source-plugin the same cause made `@Basedir` and `@MojoParameter` be ignored, producing `target/null-sources.jar` while the tests still reported green.
   
   There is a second, related break in the same relocation. The shim left behind for `ProducedArtifactStub`:
   
   ```java
   @Deprecated(since = "4.0.0-rc-6", forRemoval = true)
   public class ProducedArtifactStub extends org.apache.maven.testing.plugin.stubs.ProducedArtifactStub {
       public ProducedArtifactStub();
   }
   ```
   
   is a bare no-arg subclass. Constructors are not inherited, so the five-argument constructor the old class had is gone, and code using it no longer compiles:
   
   ```
   CompilerMojoTestCase.java:[436,21] constructor ProducedArtifactStub ... cannot be applied to given types
     required: no arguments   found: String,String,<nulltype>,String,String
   ```
   
   That one at least fails loudly (apache/maven-compiler-plugin#1104).
   
   Suggestions, in rough order of value:
   
   1. Make the deprecated annotations work, or fail loudly. If `MojoExtension` accepted both annotation types the relocation would be transparent; if that is not wanted, detecting a deprecated `@InjectMojo`/`@Basedir` and failing with a message naming the new package would at least turn a silent wrong-model run into an actionable error.
   2. Give the `ProducedArtifactStub` shim the same five-argument constructor, so the deprecated class is source-compatible for its remaining life.
   3. Mention both in the release notes: "deprecated but still compiles, and no longer functions" is a combination that costs downstream projects a debugging session each.
   
   Found while moving the plugins to rc-6 (apache/maven#12676).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] maven-testing: deprecated org.apache.maven.api.plugin.testing annotations compile but are silently ignored [maven]

Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet closed issue #12678: maven-testing: deprecated org.apache.maven.api.plugin.testing annotations compile but are silently ignored
URL: https://github.com/apache/maven/issues/12678


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] maven-testing: deprecated org.apache.maven.api.plugin.testing annotations compile but are silently ignored [maven]

Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet commented on issue #12678:
URL: https://github.com/apache/maven/issues/12678#issuecomment-5443332657

   This is already fixed by #12683 on the `maven-4.0.x` branch.
   
   A forward-port to `master` is not needed because `master` (via #12276) removed the deprecated `org.apache.maven.api.plugin.testing` package entirely — there are no deprecated shims to be silently ignored. The bug only affected `maven-4.0.x` where the deprecated shims were kept but not recognized by `MojoExtension`.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] maven-testing: deprecated org.apache.maven.api.plugin.testing annotations compile but are silently ignored [maven]

Posted by "goutamadwant (via GitHub)" <gi...@apache.org>.
goutamadwant commented on issue #12678:
URL: https://github.com/apache/maven/issues/12678#issuecomment-5199904056

   @ascheman @slachiewicz  I reproduced this and opened #12683 with a fix. It runs `SchemaPruning` after `PushVariantIntoScan` so the `Once` batch reaches a stable plan on its first application. Let me know if this looks good or any suggestions. thanks! 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org