slawekjaranowski commented on PR #14190:
URL: https://github.com/apache/maven/pull/14190#issuecomment-7286680845

   > Um, is sisu _exported artifact_ by Maven? AFAIR, only plexus is. As not 
exported artifact, it will be resolved and added to classpath, and may cause 
classloader issues too...
   
   Good point — I checked it on all branches where this change goes (master, 
maven-4.0.x, maven-3.10.x, maven-3.9.x):
   
   **Exported artifacts.** Only `org.eclipse.sisu:org.eclipse.sisu.plexus` (and 
the legacy `org.sonatype.sisu:sisu-inject-plexus`) is an exported artifact. 
`org.eclipse.sisu:org.eclipse.sisu.inject` is not, so if a plugin has it in its 
runtime dependencies, the jar does end up in the plugin realm 
(`DefaultClassRealmManager` filters only exact `groupId:artifactId` matches).
   
   **Why exporting the package is still safe.** Classworlds loads imports first 
(import → self → parent, `SelfFirstStrategy`), so with `org.eclipse.sisu.*` 
exported the `org.eclipse.sisu` package always comes from core, even when a 
plugin brings its own copy. That is exactly what we need: `@Priority`, 
`@Typed`, `@Description`, ... are the same classes the core container checks. 
The plugin's copy only provides the sub-packages (`org.eclipse.sisu.inject`, 
`space`, `wire`, ...), which a plugin can use on its own; those types never 
matched the core container's anyway (different classes from a different realm).
   
   **Why not export the artifact as well.** If `org.eclipse.sisu.inject` were 
an exported artifact, the whole jar would be removed from the plugin realm and 
only the exported `org.eclipse.sisu` package would remain visible. All other 
packages from that jar would be blocked: `org.eclipse.sisu.inject`, `.space`, 
`.wire`, `.bean`, `.launch`, `.osgi` and the legacy `org.sonatype.inject`. 
Plugins that use them today on their own copy (e.g. class-space scanning or 
their own injector) would fail with `NoClassDefFoundError` — a breaking change, 
unless we also exported all those packages, which this PR deliberately avoids.
   
   **Plugins should have Sisu in `provided` scope**, like the other artifacts 
Maven provides. It usually comes transitively via `maven-plugin-api` / 
`maven-core`, which are `provided`, and then no Sisu jar ends up in the plugin 
realm at all. This is the maven-enforcer case: with `-X`, the 
`maven-enforcer-plugin:3.7.0` realm contains no Sisu jar. The difference from 
e.g. `javax.inject` is that a wrong scope is harmless there, because core 
filters exported artifacts out, while for `sisu.inject` it isn't.
   


-- 
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