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

   ### Affected version
   
   `master` (4.2.0-SNAPSHOT, 6145dae0de) compared with `maven-4.0.x` 
(35b8736f85) and 4.0.0-rc-7.
   
   ### Bug description
   
   `org.apache.maven.api.MojoExecution` has two disjoint sets of accessors on 
the two lines:
   
   | `maven-4.0.x`, 4.0.0-rc-7 | `master` |
   |---|---|
   | `getPlugin()` | `plugin()` |
   | `getModel()` | `model()` |
   | `getDescriptor()` | `descriptor()` |
   | `getExecutionId()` | `executionId()` |
   | `getGoal()` | `goal()` |
   | `getLifecyclePhase()` | `lifecyclePhase()` |
   | `getConfiguration()` | `configuration()` |
   
   Neither line has the other's names, so no source compiles against both, and 
a plugin compiled against 4.0 that calls one of these methods fails at run time 
on 4.2.
   
   #13366 introduced the noun-style names with the `get` names kept as 
deprecated default methods, and then dropped the `get` names during review on 
the grounds that 4.0.0 is not released yet, so compatibility could still be 
broken. That holds only if 4.0.0 ships the new names too. #13366 was merged to 
`master` alone: there is no backport, and `maven-4.0.x` still has only the 
`get` names. As things stand, 4.0.0 will be released with accessors that 4.2 
does not have.
   
   The other value types were handled differently and do not have this problem 
for callers: on `master`, `Project`, `Artifact`, `Dependency` and `Node` keep 
`getXxx()` as deprecated default methods that delegate to the new names 
(#13036, #13830).
   
   ### Reproducer
   
   A class compiled against `maven-api-core` 4.0.0-rc-7:
   
   ```java
   MojoExecution execution = (MojoExecution) Proxy.newProxyInstance(
           Caller.class.getClassLoader(), new Class<?>[] {MojoExecution.class}, 
(p, m, a) -> "compile");
   System.out.println("goal = " + execution.getGoal());
   ```
   
   - Run with the 4.0.0-rc-7 API jars on the class path: `goal = compile`.
   - Run with the 4.2.0-SNAPSHOT API jars: `java.lang.NoSuchMethodError: 
'java.lang.String org.apache.maven.api.MojoExecution.getGoal()'`.
   
   In real code the same calls are made by Maven 4 API mojos that read their 
own execution: in a set of plugin ports built against rc-7, five fail to 
compile against the 4.2.0-SNAPSHOT API for this reason alone (the ports of 
maven-antrun-plugin, maven-checkstyle-plugin, maven-ear-plugin, maven-enforcer 
and maven-reporting-impl, which call `getPlugin()`, `getConfiguration()` or 
`getGoal()`).
   
   ### Options
   
   1. Restore the `get` names on `master` as `@Deprecated(forRemoval = true)` 
default methods, as #13366 first had them and as `Project` and `Artifact` have 
them. A plugin built for 4.0 then keeps working on 4.2.
   2. Add the noun-style names to `maven-4.0.x` before 4.0.0 is released, as 
default methods delegating to the `get` names. Code written against the new 
names then compiles on both lines, and the `get` names can be removed later 
with a release of warning.
   
   Doing both gives one source that compiles on 4.0 and 4.2 and one binary that 
runs on both.
   
   ### Related, lower severity
   
   The same comparison shows three more changes on `master` that break code 
built for 4.0. They affect implementers and test code, not ordinary callers:
   
   - `Artifact.snapshot()`, `Dependency.scope()` and 
`Project.effectiveActiveProfiles()` (and the other noun-style names) are 
abstract on `master`, with the `get`/`is` names as defaults. Every 
implementation of these interfaces outside Maven stops compiling, which in 
practice means test stubs.
   - `org.apache.maven.api.services.model.PathTranslator` no longer exists in 
`maven-api-spi` on `master` (`ModelPathTranslator` exists on both lines). 
maven-plugin-testing-harness 4.0.0-beta-4 references it and fails with 
`NoClassDefFoundError` when run against the 4.2.0-SNAPSHOT API.
   - `org.apache.maven.api.di.testing.MavenDITest` and the 
`org.apache.maven.api.plugin.testing` package are gone from `maven-testing` on 
`master`; rc-7 ships both those and `org.apache.maven.testing.*`.
   
   These can be split into their own issues if that is easier to track.
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to