gnodet-bot commented on code in PR #13722:
URL: https://github.com/apache/maven/pull/13722#discussion_r4390405786
##########
impl/maven-impl/src/main/java/org/apache/maven/impl/DefaultSuperPomProvider.java:
##########
@@ -29,9 +27,12 @@
import org.apache.maven.api.di.Named;
import org.apache.maven.api.di.Singleton;
import org.apache.maven.api.model.Model;
+import org.apache.maven.api.services.ModelSource;
import org.apache.maven.api.services.SuperPomProvider;
import org.apache.maven.api.services.model.ModelProcessor;
-import org.apache.maven.api.services.xml.XmlReaderRequest;
+import org.apache.maven.api.spi.ModelParser;
+import org.apache.maven.api.spi.ModelParserException;
+import org.apache.maven.impl.model.DefaultModelProcessor;
Review Comment:
⚠️ **[MEDIUM] Impl-to-impl coupling via
`DefaultModelProcessor.urlModelSource()`**
`DefaultSuperPomProvider` previously interacted with `ModelProcessor`
exclusively through the SPI interface. This commit introduces a direct import
of `DefaultModelProcessor` (a concrete implementation class) solely to call
`DefaultModelProcessor.urlModelSource(url, modelId)`.
This creates tight coupling between two implementation classes that should
remain independent. If `DefaultModelProcessor` is refactored, renamed, or the
`urlModelSource` factory is moved, `DefaultSuperPomProvider` breaks silently.
The fix is to move `urlModelSource()` — or an equivalent `ModelSource`
factory for URL + modelId — to the existing `Sources` utility class in
`maven-api-core`. `Sources` already provides `fromPath()`, `buildSource()`, and
`resolvedSource()`; a URL variant fits naturally there and would eliminate this
coupling:
```java
// In Sources.java (maven-api-core)
@Nonnull
public static ModelSource urlSource(@Nonnull URL url, @Nullable String
modelId) {
return new UrlModelSource(url, modelId);
}
```
`DefaultSuperPomProvider` could then use `Sources.urlSource(url, modelId)`
without importing any impl class. The `UrlModelSource` record itself can live
in `Sources` (package-private) or be made package-private in the same module.
--
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]