gnodet-bot commented on code in PR #13588:
URL: https://github.com/apache/maven/pull/13588#discussion_r4301653560


##########
src/site/markdown/classloading.md:
##########
@@ -0,0 +1,372 @@
+<!---
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+# Maven Classloading
+
+This document describes the classloading mechanism used by Maven 4.x.
+Maven uses [Plexus Classworlds][classworlds] to build a hierarchy of isolated
+classloaders (called **realms**) so that plugins, extensions and the
+Maven core can each see only the classes they are supposed to see.
+
+The following diagram gives an overview of the realm hierarchy during a
+typical Maven build. Solid arrows indicate the parent classloader
+relationship. Dashed blue arrows indicate package imports. Dashed green
+arrows indicate export feeds.
+
+![Maven 4.x Classloader Hierarchy](images/classloading.svg)
+
+Each realm is described in detail below.
+
+## ClassWorlds Bootstrap ClassLoader
+
+This classloader is created and managed by the calling environment: the
+JVM launcher, an integration testing harness, or an IDE embedder.
+
+During a normal command-line invocation this is the JVM System
+ClassLoader and contains:
+
+- `${maven.home}/boot/plexus-classworlds-*.jar` — the Plexus
+  Classworlds library that bootstraps all other realms
+- Any `-javaagent` classes specified on the JVM command line
+
+## Maven Core Realm (`plexus.core`)
+
+Contains all Maven runtime classes: `MavenProject`, `AbstractMojo`,
+Plexus/Sisu DI, SLF4J, Guice, the Aether resolver, and more.
+
+The contents are configured by `${maven.home}/bin/m2.conf` and
+typically include:
+
+- `${maven.home}/lib/ext/*.jar`
+- `${maven.home}/lib/*.jar`
+
+This realm is the **container realm** in the Plexus/Sisu container
+unless core extensions are present, in which case the `maven.ext` realm
+takes over as the container realm (see below).
+
+## Core Extension Realms (`coreExtension>G:A:V`)
+
+Core extensions are loaded from `.mvn/extensions.xml` during Maven
+startup, **before the POM is parsed**. Each core extension gets its own
+isolated classloader. Because they load before POM parsing, core
+extensions can influence the build itself (e.g. polyglot Maven).
+
+```xml
+<?xml version="1.0" encoding="UTF-8"?>
+<extensions>
+  <extension>
+    <groupId>...</groupId>
+    <artifactId>...</artifactId>
+    <version>...</version>
+    <!-- optional: parent-first (default), self-first, plugin -->
+    <classLoadingStrategy>...</classLoadingStrategy>
+  </extension>
+</extensions>
+```
+
+Each extension can use `META-INF/maven/extension.xml` to declare
+exported packages and artifacts. These exports are aggregated into
+`CoreExports` and become visible to all plugins and build extensions
+through the Maven API realm.
+
+The `<classLoadingStrategy>` element controls the realm's parent
+wiring:
+
+| Strategy | Behavior |
+|---|---|
+| `parent-first` (default) | Imports everything from the core realm. Classes 
from the core are preferred over the extension's own. |
+| `plugin` | Imports only `CoreExports` packages (the Maven API surface). Same 
isolation as build extensions. |
+| `self-first` | Uses the core realm as parent but checks its own classes 
first. Allows the extension to override core classes. |
+
+Core extensions are loaded as part of Maven runtime startup and
+disposed of as part of Maven runtime shutdown.
+
+### Exports
+

Review Comment:
   ⚠️ **Wrong default annotation.** `self-first` is the default per 
`core-extensions.mdo` (`<defaultValue>self-first</defaultValue>`). Move the 
`(default)` annotation from `parent-first` to `self-first` and reorder the rows 
for clarity (default first):
   
   ```suggestion
   | `self-first` (default) | Uses the core realm as parent but checks its own 
classes first. Allows the extension to override core classes. |
   | `parent-first` | Imports everything from the core realm. Classes from the 
core are preferred over the extension's own. |
   | `plugin` | Imports only `CoreExports` packages (the Maven API surface). 
Same isolation as build extensions. |
   ```



##########
src/site/markdown/classloading.md:
##########
@@ -0,0 +1,372 @@
+<!---
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+# Maven Classloading
+
+This document describes the classloading mechanism used by Maven 4.x.
+Maven uses [Plexus Classworlds][classworlds] to build a hierarchy of isolated
+classloaders (called **realms**) so that plugins, extensions and the
+Maven core can each see only the classes they are supposed to see.
+
+The following diagram gives an overview of the realm hierarchy during a
+typical Maven build. Solid arrows indicate the parent classloader
+relationship. Dashed blue arrows indicate package imports. Dashed green
+arrows indicate export feeds.
+
+![Maven 4.x Classloader Hierarchy](images/classloading.svg)
+
+Each realm is described in detail below.
+
+## ClassWorlds Bootstrap ClassLoader
+
+This classloader is created and managed by the calling environment: the
+JVM launcher, an integration testing harness, or an IDE embedder.
+
+During a normal command-line invocation this is the JVM System
+ClassLoader and contains:
+
+- `${maven.home}/boot/plexus-classworlds-*.jar` — the Plexus
+  Classworlds library that bootstraps all other realms
+- Any `-javaagent` classes specified on the JVM command line
+
+## Maven Core Realm (`plexus.core`)
+
+Contains all Maven runtime classes: `MavenProject`, `AbstractMojo`,
+Plexus/Sisu DI, SLF4J, Guice, the Aether resolver, and more.
+
+The contents are configured by `${maven.home}/bin/m2.conf` and
+typically include:
+
+- `${maven.home}/lib/ext/*.jar`
+- `${maven.home}/lib/*.jar`
+
+This realm is the **container realm** in the Plexus/Sisu container
+unless core extensions are present, in which case the `maven.ext` realm
+takes over as the container realm (see below).
+
+## Core Extension Realms (`coreExtension>G:A:V`)
+
+Core extensions are loaded from `.mvn/extensions.xml` during Maven
+startup, **before the POM is parsed**. Each core extension gets its own
+isolated classloader. Because they load before POM parsing, core
+extensions can influence the build itself (e.g. polyglot Maven).
+
+```xml
+<?xml version="1.0" encoding="UTF-8"?>
+<extensions>
+  <extension>
+    <groupId>...</groupId>
+    <artifactId>...</artifactId>
+    <version>...</version>
+    <!-- optional: parent-first (default), self-first, plugin -->
+    <classLoadingStrategy>...</classLoadingStrategy>
+  </extension>
+</extensions>
+```
+
+Each extension can use `META-INF/maven/extension.xml` to declare

Review Comment:
   ⚠️ **Wrong order — `self-first` is the default, not `parent-first`.** Fix 
the comment to match `core-extensions.mdo`:
   
   ```suggestion
       <!-- optional: self-first (default), parent-first, plugin -->
   ```



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