slachiewicz opened a new issue, #13917: URL: https://github.com/apache/maven/issues/13917
Maven 3.10 added `org.apache.maven.message.MessageBuilder` and `MessageBuilderFactory` (#11874) as the replacement for maven-shared-utils' `MessageUtils`. Maven 4 has the same API as `org.apache.maven.api.services.MessageBuilder` and `MessageBuilderFactory`: the method sets are identical, including the default methods. They differ in the package, in where the style names live (a `Constants` class nested in the 3.10 `MessageBuilder`, `org.apache.maven.api.Constants` in Maven 4), and in Maven 4's factory extending `Service`. Maven 3.9 has neither. So a plugin that supports more than one line cannot use either: Maven 4 ships no `org.apache.maven.message`, and Maven 3.9 and 3.10 ship no `org.apache.maven.api.services`. Such plugins stay on maven-shared-utils' `MessageUtils`, which works only through the JAnsi compatibility classes (apache/maven-shared-utils#452, apache/maven-surefire#3574). Proposal: Maven 3.9 and 3.10 also ship the Maven 4 interfaces, so that one plugin binary injects `org.apache.maven.api.services.MessageBuilderFactory` on all three lines. - `maven-core` carries Java 8 copies of `org.apache.maven.api.services.MessageBuilder` and `MessageBuilderFactory`, `org.apache.maven.api.Service`, the `Nonnull`, `Experimental` and `ThreadSafe` annotations, and `org.apache.maven.api.Constants` reduced to the style names. A reduced `Constants` is safe: all its fields are `String` constants, which the compiler inlines into the calling code, so no plugin reads them from Maven's copy at run time. `maven-core` already exports `org.apache.maven.*`. - Maven 3.10 binds the API factory to an adapter over its existing `MessageBuilderFactory`, so colours and terminal detection stay as they are. - Maven 3.9 binds it to an implementation over maven-shared-utils' `MessageUtils` (colour and terminal width) with the style resolution Maven 3.10 uses, so the API's style names (`bold,f:cyan`, `maven.style.*`) behave the same on both lines. - Plugin authors compile against `org.apache.maven:maven-api-core` 4.x in `provided` scope. That jar is Java 17 bytecode, but javac on JDK 17 or later reads it while compiling a plugin for `--release 8`. Checked so far: a mojo built that way (JDK 21, `--release 8` against `maven-api-core` 4.0.0-rc-7) gets the factory injected on Maven 4.0.0-rc-7 and prints the expected styles with `--color=always`; on Maven 3.9.16 it fails with "A required class was missing", which is the gap above. The alternative, Maven 4 shipping `org.apache.maven.message` as adapters, would only cover 3.10 and 4 and would make the 3.10-only package permanent. -- 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]
