gnodet opened a new pull request, #13613: URL: https://github.com/apache/maven/pull/13613
Rebased and updated version of #1732 by @cstamas. ## What this PR does Introduces infrastructure for symmetric dialect translation between Maven model formats, enabling tools like [maveniverse/mason](https://github.com/maveniverse/mason) to implement POM format conversion (e.g. XML ↔ YAML) — see https://github.com/maveniverse/mason/issues/45. ### New types | Type | Module | Description | |---|---|---| | `Dialect` | maven-api-core | Extensible enum (like `Language`) with built-in `XML` value | | `DialectRegistry` | maven-api-core | `ExtensibleEnumRegistry` for `Dialect` values | | `ModelDialectManager` | maven-api-core | Service: read/write models across dialects | | `DialectProvider` | maven-api-spi | SPI to extend the `Dialect` enum | | `ModelWriter` | maven-api-spi | Symmetric counterpart to `ModelParser` | | `ModelWriterException` | maven-api-spi | Checked exception for write failures | | `ModelDialectProvider` | maven-api-spi | SPI composing a (ModelParser, ModelWriter) pair for a Dialect | | `DefaultModelDialectManager` | maven-impl | Implementation wiring the built-in XML dialect via `ModelXmlFactory` | | `DefaultDialectRegistry` | maven-impl | DI-wired registry in `ExtensibleEnumRegistries` | ### Design - The built-in **XML dialect** is always available (via `ModelXmlFactory`). - External extensions register additional dialects by providing a `ModelDialectProvider` via DI. - `DialectProvider` allows extending the `Dialect` enum itself (same pattern as `LanguageProvider`). - `DefaultDialectRegistry` is `@SessionScoped` (consistent with `PathScopeRegistry`/`ProjectScopeRegistry`) so per-session extension loading is supported. ### Differences from #1732 - Module path corrected: `maven-api-impl/` → `impl/maven-impl/`, package `org.apache.maven.internal.impl` → `org.apache.maven.impl` - `ModelWriter` extends `SpiService` (consistent with `ModelParser`) - `Source.fromPath()` → `Sources.fromPath()` (correct API in current master) - `DefaultDialectRegistry` added to `ExtensibleEnumRegistries` (missing from #1732) - Exception handling in XML dialect wrappers (catches `XmlReaderException`/`XmlWriterException` and rethrows as SPI exceptions) - `@since` updated to `4.1.0` Closes #9976 -- 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]
