gnodet opened a new issue, #13379:
URL: https://github.com/apache/maven/issues/13379
## Summary
Several utility classes with no external dependencies exist in multiple
copies across the Maven codebase. A new zero-dependency `impl/maven-utils`
module would eliminate this duplication and serve as a clean home for pure-JDK
helpers reused across `impl/`, `compat/`, and now `impl/maven-classworlds`.
## Motivation
While working on #11029 (internalize plexus-classworlds), it became
necessary to copy the `DefaultInterpolator` algorithm into `maven-classworlds`
because `maven-classworlds` cannot depend on `maven-impl` (layering violation).
This is not a one-off: the same pattern appears repeatedly throughout the
codebase.
## Identified duplicates
### `MavenProperties` + `MavenPropertiesLoader` — **pure JDK**
- `impl/maven-cli`: `org.apache.maven.cling.props.MavenProperties` (1160
lines)
- `compat/maven-embedder`: `org.apache.maven.cli.props.MavenProperties`
(1160 lines, identical logic, adds `@Deprecated`)
- Same for `MavenPropertiesLoader`
### `CleanArgument` — **pure JDK**
- `impl/maven-cli`: `org.apache.maven.cling.invoker.CleanArgument`
- `compat/maven-embedder`: `org.apache.maven.cli.CleanArgument` (identical,
adds `@Deprecated`)
### `Os` — **pure JDK**
- `impl/maven-impl`: `org.apache.maven.impl.util.Os`
- `compat/maven-model-builder`: `org.apache.maven.utils.Os` (adds
`@Deprecated`, minor divergence)
- Referenced from `maven-core`, `maven-compat`, `maven-cli`, and
`compat/maven-embedder`
### `ReflectionValueExtractor` + `MethodMap` — **JDK +
`maven-api-annotations`**
- `impl/maven-impl`: `org.apache.maven.impl.model.reflection.*`
- `compat/maven-model-builder`:
`org.apache.maven.model.interpolation.reflection.*`
- Also used from `maven-core` (`PluginParameterExpressionEvaluator{,V4}`)
### String interpolation algorithm — **pure JDK**
- `impl/maven-impl`: `DefaultInterpolator` (registered DI service, can't be
moved wholesale)
- `impl/maven-classworlds`: `Interpolator` (just added as part of #11029 —
forced copy)
## Proposal: `impl/maven-utils`
A new Maven module with:
- **Zero external dependencies** (optionally `maven-api-annotations` for
`@Nonnull`/`@Nullable`)
- Package: `org.apache.maven.utils`
- Contents initially:
- `MavenProperties` + `MavenPropertiesLoader`
- `CleanArgument`
- `Os`
- `ReflectionValueExtractor` + `MethodMap`
- `StringInterpolator` (pure-algorithm extract from `DefaultInterpolator`,
usable from classworlds and maven-impl alike)
The compat and impl copies become `@Deprecated` thin wrappers delegating to
the canonical location, preserving binary compatibility.
## Benefits
- Eliminates ~3000 lines of copy-paste maintenance burden
- Unblocks `maven-classworlds` from carrying its own `Interpolator` copy
long-term
- Provides a principled home for future pure-JDK helpers (e.g. `Os`, path
utilities)
- Respects layering: `maven-utils` sits below `maven-impl`, `maven-cli`,
`compat/maven-embedder`
--
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]