You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by gn...@apache.org on 2026/10/16 14:29:05 UTC

(maven) 01/03: fix: project-extension visibility for Packaging, Type, and Lifecycle registries

This is an automated email from the ASF dual-hosted git repository.

gnodet pushed a commit to branch fix/packaging-provider-leak
in repository https://gitbox.apache.org/repos/asf/maven.git

commit 6449962c541f91df72bcf21e63f4a89d4146d280
Author: Goutam Adwant <86...@users.noreply.github.com>
AuthorDate: Thu Oct 15 11:18:35 2026 -0700

    fix: project-extension visibility for Packaging, Type, and Lifecycle registries
    
    - DefaultExtensibleEnumRegistry: new Lookup-aware constructor; on each
      lookup() call, queries Lookup.lookupList(providerType) first so SISU
      applies project-scope filtering before falling back to statically
      registered values
    - DefaultPackagingRegistry: delegates dynamic lookup to super via
      PackagingProvider.class; retains legacy LifecycleMapping as last resort
    - DefaultTypeRegistry: queries TypeProvider list uncached before the
      ArtifactHandler fallback cache, preventing type leaks across reactor
      projects
    - DefaultLifecycleRegistry: Lookup-aware constructor; stream() merges
      injected and dynamically discovered lifecycles, deduplicating by id
      with dynamic providers taking priority
    - Tests: DefaultExtensibleEnumRegistryTest (builtins, dynamic lookup,
      priority, no-leak-across-projects), DefaultPackagingRegistryTest,
      DefaultTypeRegistryTest, and MavenITgh13306PackagingProviderTest IT
      that builds a real extension contributing app-client packaging and
      verifies isolation across reactor projects
    
    Fixes: #13306
---
 .../internal/impl/DefaultLifecycleRegistry.java    |  27 +++-
 .../internal/impl/DefaultPackagingRegistry.java    |  21 ++--
 .../maven/internal/impl/DefaultTypeRegistry.java   |  56 ++++++---
 .../impl/DefaultLifecycleRegistryTest.java         |  98 +++++++++++++++
 .../impl/DefaultPackagingRegistryTest.java         | 105 ++++++++++++++++
 .../internal/impl/DefaultTypeRegistryTest.java     | 139 +++++++++++++++++++++
 .../maven/impl/ExtensibleEnumRegistries.java       |  38 +++++-
 .../impl/DefaultExtensibleEnumRegistryTest.java    | 118 +++++++++++++++++
 .../it/MavenITgh13306PackagingProviderTest.java    |  57 +++++++++
 .../gh-13306-packaging-provider/client/pom.xml     |  36 ++++++
 .../gh-13306-packaging-provider/extension/pom.xml  |  75 +++++++++++
 .../maven/its/gh13306/CustomPackagingProvider.java |  23 ++--
 .../maven/its/gh13306/CustomTypeProvider.java      |  72 +++++++++++
 .../gh-13306-packaging-provider/reactor/pom.xml    |  30 +++++
 .../reactor/with-extension/pom.xml                 |  39 ++++++
 .../reactor/without-extension/pom.xml              |  29 +++++
 16 files changed, 923 insertions(+), 40 deletions(-)

diff --git a/impl/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultLifecycleRegistry.java b/impl/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultLifecycleRegistry.java
index c25269d033..5dd0687059 100644
--- a/impl/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultLifecycleRegistry.java
+++ b/impl/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultLifecycleRegistry.java
@@ -43,6 +43,7 @@
 import org.apache.maven.api.model.InputSource;
 import org.apache.maven.api.model.Plugin;
 import org.apache.maven.api.services.LifecycleRegistry;
+import org.apache.maven.api.services.Lookup;
 import org.apache.maven.api.services.LookupException;
 import org.apache.maven.api.spi.ExtensibleEnumProvider;
 import org.apache.maven.api.spi.LifecycleProvider;
@@ -101,18 +102,26 @@ public class DefaultLifecycleRegistry implements LifecycleRegistry {
     public static final String SCOPE_TEST = DependencyScope.TEST.id();
 
     private final List<LifecycleProvider> providers;
+    private final Lookup lookup;
 
     public DefaultLifecycleRegistry() {
         this(Collections.emptyList());
     }
 
-    @Inject
     public DefaultLifecycleRegistry(List<LifecycleProvider> providers) {
+        this(null, providers);
+    }
+
+    @Inject
+    public DefaultLifecycleRegistry(Lookup lookup, List<LifecycleProvider> providers) {
+        this.lookup = lookup;
         List<LifecycleProvider> p = new ArrayList<>(providers);
         p.add(() -> List.of(new CleanLifecycle(), new DefaultLifecycle(), new SiteLifecycle()));
         this.providers = p;
-        // validate lifecycle
-        for (Lifecycle lifecycle : this) {
+        // validate lifecycle using only injected providers (safe during construction —
+        // dynamic lookup may not be usable yet)
+        for (Lifecycle lifecycle :
+                providers.stream().flatMap(pr -> pr.provides().stream()).toList()) {
             Set<String> set = new HashSet<>();
             lifecycle.allPhases().forEach(phase -> {
                 if (!set.add(phase.name())) {
@@ -135,6 +144,18 @@ public Iterator<Lifecycle> iterator() {
 
     @Override
     public Stream<Lifecycle> stream() {
+        if (lookup != null) {
+            // Dynamic discovery includes constructor-injected + project-extension providers.
+            // Built-in lifecycles (clean, default, site) are added as a lambda and not
+            // discoverable via Lookup, so we always include the injected providers too.
+            // Deduplicate by id, with dynamic providers taking priority.
+            Map<String, Lifecycle> result = new LinkedHashMap<>();
+            providers.stream().flatMap(p -> p.provides().stream()).forEach(lf -> result.put(lf.id(), lf));
+            lookup.lookupList(LifecycleProvider.class).stream()
+                    .flatMap(p -> p.provides().stream())
+                    .forEach(lf -> result.put(lf.id(), lf));
+            return result.values().stream();
+        }
         return providers.stream().map(ExtensibleEnumProvider::provides).flatMap(Collection::stream);
     }
 
diff --git a/impl/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultPackagingRegistry.java b/impl/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultPackagingRegistry.java
index d865d12b4a..63ec5d17a7 100644
--- a/impl/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultPackagingRegistry.java
+++ b/impl/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultPackagingRegistry.java
@@ -66,29 +66,30 @@ public class DefaultPackagingRegistry
 
     @Inject
     public DefaultPackagingRegistry(Lookup lookup, TypeRegistry typeRegistry, List<PackagingProvider> providers) {
-        super(providers);
+        super(lookup, PackagingProvider.class, providers, new Packaging[0]);
         this.lookup = lookup;
         this.typeRegistry = typeRegistry;
     }
 
     @Override
     public Optional<Packaging> lookup(String id) {
-        id = id.toLowerCase(Locale.ROOT);
-        // TODO: we should be able to inject a Map<String, LifecycleMapping> directly,
-        // however, SISU visibility filtering can only happen when an explicit
-        // lookup is performed. The whole problem here is caused by "project extensions"
-        // which are bound to a project's classloader, without any clear definition
-        // of a "project scope"
+        Optional<Packaging> result = super.lookup(id);
+        if (result.isPresent()) {
+            return result;
+        }
+        // Legacy LifecycleMapping fallback: SISU visibility filtering requires
+        // an explicit lookup (project extensions are bound to a project classloader)
+        String packagingId = id.toLowerCase(Locale.ROOT);
         LifecycleMapping lifecycleMapping =
-                lookup.lookupOptional(LifecycleMapping.class, id).orElse(null);
+                lookup.lookupOptional(LifecycleMapping.class, packagingId).orElse(null);
         if (lifecycleMapping == null) {
             return Optional.empty();
         }
-        Type type = typeRegistry.lookup(id).orElse(null);
+        Type type = typeRegistry.lookup(packagingId).orElse(null);
         if (type == null) {
             return Optional.empty();
         }
-        return Optional.of(new DefaultPackaging(id, type, getPlugins(lifecycleMapping)));
+        return Optional.of(new DefaultPackaging(packagingId, type, getPlugins(lifecycleMapping)));
     }
 
     private Map<String, PluginContainer> getPlugins(LifecycleMapping lifecycleMapping) {
diff --git a/impl/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultTypeRegistry.java b/impl/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultTypeRegistry.java
index fb925a60ad..3d450ce336 100644
--- a/impl/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultTypeRegistry.java
+++ b/impl/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultTypeRegistry.java
@@ -74,30 +74,48 @@ public Optional<Type> lookup(String id) {
         return Optional.of(require(id));
     }
 
+    /**
+     * Resolves a {@link Type} by id.
+     *
+     * <p><b>Performance note:</b> {@code lookup.lookupList(TypeProvider.class)} is called on every
+     * invocation — intentionally uncached — so that SISU's project-scoped visibility filtering
+     * applies correctly when a project extension contributes a {@link TypeProvider}. SISU's own
+     * internal registry is locked but bounded in cardinality (O(tens) of providers), so the
+     * overhead is negligible under parallel builds. Only the legacy {@link
+     * org.apache.maven.artifact.handler.ArtifactHandler} fallback path is cached in
+     * {@code usedTypes}.</p>
+     *
+     * @param id the type identifier, must not be {@code null}
+     * @return the resolved {@link Type}, never {@code null}
+     * @throws org.apache.maven.api.services.MavenException if the type cannot be resolved
+     */
     @Override
     @Nonnull
     public Type require(String id) {
         requireNonNull(id, "id cannot be null");
-        return usedTypes.computeIfAbsent(id, i -> {
-            Type type = lookup.lookupList(TypeProvider.class).stream()
-                    .flatMap(p -> p.provides().stream())
-                    .filter(t -> Objects.equals(id, t.id()))
-                    .findFirst()
-                    .orElse(null);
-            if (type == null) {
-                // Copy data as the ArtifactHandler is not immutable, but Type should be.
-                ArtifactHandler handler = manager.getArtifactHandler(id);
-                type = new DefaultType(
-                        id,
-                        languageRegistry.lookup(handler.getLanguage()).orElseGet(() -> handler::getLanguage),
-                        handler.getExtension(),
-                        handler.getClassifier(),
-                        handler.isIncludesDependencies(),
-                        handler.isAddedToClasspath()
-                                ? new JavaPathType[] {JavaPathType.CLASSES, JavaPathType.MODULES}
-                                : new JavaPathType[] {});
-            }
+        // Dynamic providers are queried first (uncached) so that SISU visibility
+        // filtering works correctly for project-extension-contributed types.
+        // Only the legacy ArtifactHandler fallback is cached.
+        Type type = lookup.lookupList(TypeProvider.class).stream()
+                .flatMap(p -> p.provides().stream())
+                .filter(t -> Objects.equals(id, t.id()))
+                .findFirst()
+                .orElse(null);
+        if (type != null) {
             return type;
+        }
+        return usedTypes.computeIfAbsent(id, i -> {
+            // Copy data as the ArtifactHandler is not immutable, but Type should be.
+            ArtifactHandler handler = manager.getArtifactHandler(id);
+            return new DefaultType(
+                    id,
+                    languageRegistry.lookup(handler.getLanguage()).orElseGet(() -> handler::getLanguage),
+                    handler.getExtension(),
+                    handler.getClassifier(),
+                    handler.isIncludesDependencies(),
+                    handler.isAddedToClasspath()
+                            ? new JavaPathType[] {JavaPathType.CLASSES, JavaPathType.MODULES}
+                            : new JavaPathType[] {});
         });
     }
 }
diff --git a/impl/maven-core/src/test/java/org/apache/maven/internal/impl/DefaultLifecycleRegistryTest.java b/impl/maven-core/src/test/java/org/apache/maven/internal/impl/DefaultLifecycleRegistryTest.java
index a154a23c9d..ec403dd5c1 100644
--- a/impl/maven-core/src/test/java/org/apache/maven/internal/impl/DefaultLifecycleRegistryTest.java
+++ b/impl/maven-core/src/test/java/org/apache/maven/internal/impl/DefaultLifecycleRegistryTest.java
@@ -18,9 +18,21 @@
  */
 package org.apache.maven.internal.impl;
 
+import java.util.Collection;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.apache.maven.api.Lifecycle;
+import org.apache.maven.api.services.Lookup;
+import org.apache.maven.api.spi.LifecycleProvider;
 import org.junit.jupiter.api.Test;
 
+import static org.junit.jupiter.api.Assertions.assertNotSame;
 import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
 
 class DefaultLifecycleRegistryTest {
 
@@ -28,4 +40,90 @@ class DefaultLifecycleRegistryTest {
     void returnsNullImplementationVersionWhenClassHasNoPackage() {
         assertNull(DefaultLifecycleRegistry.getImplementationVersion(int.class));
     }
+
+    @Test
+    void findsLifecycleFromDynamicProviderLookup() {
+        Lookup lookup = mock(Lookup.class);
+        Lifecycle custom = stubLifecycle("app-lifecycle");
+        LifecycleProvider provider = () -> List.of(custom);
+        when(lookup.lookupList(LifecycleProvider.class)).thenReturn(List.of(provider));
+
+        DefaultLifecycleRegistry registry = new DefaultLifecycleRegistry(lookup, List.of());
+
+        assertTrue(registry.lookup("app-lifecycle").isPresent());
+        assertSame(custom, registry.lookup("app-lifecycle").get());
+    }
+
+    @Test
+    void dynamicProviderTakesPriorityOverInjectedProvider() {
+        Lifecycle injected = stubLifecycle("my-lifecycle");
+        Lifecycle dynamic = stubLifecycle("my-lifecycle");
+
+        Lookup lookup = mock(Lookup.class);
+        LifecycleProvider dynamicProvider = () -> List.of(dynamic);
+        when(lookup.lookupList(LifecycleProvider.class)).thenReturn(List.of(dynamicProvider));
+
+        DefaultLifecycleRegistry registry = new DefaultLifecycleRegistry(lookup, List.of(() -> List.of(injected)));
+
+        assertSame(dynamic, registry.lookup("my-lifecycle").get());
+        assertNotSame(injected, registry.lookup("my-lifecycle").get());
+    }
+
+    @Test
+    void doesNotRetainDynamicLifecycleAcrossProjects() {
+        Lifecycle custom = stubLifecycle("app-lifecycle");
+        LifecycleProvider provider = () -> List.of(custom);
+        AtomicReference<List<LifecycleProvider>> visible = new AtomicReference<>(List.of(provider));
+
+        Lookup lookup = mock(Lookup.class);
+        when(lookup.lookupList(LifecycleProvider.class)).thenAnswer(inv -> visible.get());
+
+        DefaultLifecycleRegistry registry = new DefaultLifecycleRegistry(lookup, List.of());
+
+        // project A: provider is visible
+        assertSame(custom, registry.lookup("app-lifecycle").get());
+
+        // project B: provider is gone (different project classloader)
+        visible.set(List.of());
+        assertTrue(
+                registry.lookup("app-lifecycle").isEmpty(),
+                "Dynamic lifecycle must not leak into a project that does not declare the extension");
+    }
+
+    @Test
+    void builtinLifecyclesAlwaysPresent() {
+        DefaultLifecycleRegistry registry = new DefaultLifecycleRegistry(List.of());
+        assertTrue(registry.lookup("default").isPresent());
+        assertTrue(registry.lookup("clean").isPresent());
+        assertTrue(registry.lookup("site").isPresent());
+    }
+
+    @Test
+    void builtinLifecyclesAlwaysPresentWithLookup() {
+        Lookup lookup = mock(Lookup.class);
+        when(lookup.lookupList(LifecycleProvider.class)).thenReturn(List.of());
+        DefaultLifecycleRegistry registry = new DefaultLifecycleRegistry(lookup, List.of());
+        assertTrue(registry.lookup("default").isPresent());
+        assertTrue(registry.lookup("clean").isPresent());
+        assertTrue(registry.lookup("site").isPresent());
+    }
+
+    private static Lifecycle stubLifecycle(String id) {
+        return new Lifecycle() {
+            @Override
+            public String id() {
+                return id;
+            }
+
+            @Override
+            public Collection<Phase> phases() {
+                return List.of();
+            }
+
+            @Override
+            public Collection<Alias> aliases() {
+                return List.of();
+            }
+        };
+    }
 }
diff --git a/impl/maven-core/src/test/java/org/apache/maven/internal/impl/DefaultPackagingRegistryTest.java b/impl/maven-core/src/test/java/org/apache/maven/internal/impl/DefaultPackagingRegistryTest.java
new file mode 100644
index 0000000000..12a9d8f122
--- /dev/null
+++ b/impl/maven-core/src/test/java/org/apache/maven/internal/impl/DefaultPackagingRegistryTest.java
@@ -0,0 +1,105 @@
+/*
+ * 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.
+ */
+package org.apache.maven.internal.impl;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.apache.maven.api.Packaging;
+import org.apache.maven.api.Type;
+import org.apache.maven.api.services.Lookup;
+import org.apache.maven.api.services.TypeRegistry;
+import org.apache.maven.api.spi.PackagingProvider;
+import org.apache.maven.lifecycle.mapping.LifecycleMapping;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+class DefaultPackagingRegistryTest {
+
+    @Test
+    void findsProviderVisibleThroughProjectLookup() {
+        Lookup lookup = mock(Lookup.class);
+        TypeRegistry types = mock(TypeRegistry.class);
+        Packaging packaging = packaging("app-client");
+        PackagingProvider provider = () -> List.of(packaging);
+        when(lookup.lookupList(PackagingProvider.class)).thenReturn(List.of(provider));
+
+        DefaultPackagingRegistry registry = new DefaultPackagingRegistry(lookup, types, List.of());
+
+        assertSame(packaging, registry.lookup("APP-CLIENT").orElseThrow());
+    }
+
+    @Test
+    void doesNotRetainProviderFromAnotherProjectLookup() {
+        Lookup lookup = mock(Lookup.class);
+        Packaging packaging = packaging("app-client");
+        PackagingProvider provider = () -> List.of(packaging);
+        AtomicReference<List<PackagingProvider>> visible = new AtomicReference<>(List.of(provider));
+        when(lookup.lookupList(PackagingProvider.class)).thenAnswer(invocation -> visible.get());
+
+        DefaultPackagingRegistry registry = new DefaultPackagingRegistry(lookup, mock(TypeRegistry.class), List.of());
+
+        assertSame(packaging, registry.lookup("app-client").orElseThrow());
+        visible.set(List.of());
+        assertTrue(registry.lookup("app-client").isEmpty());
+    }
+
+    @Test
+    void findsProviderInjectedWhenRegistryWasConstructed() {
+        Lookup lookup = mock(Lookup.class);
+        Packaging packaging = packaging("app-client");
+        PackagingProvider provider = () -> List.of(packaging);
+
+        DefaultPackagingRegistry registry =
+                new DefaultPackagingRegistry(lookup, mock(TypeRegistry.class), List.of(provider));
+
+        assertSame(packaging, registry.lookup("app-client").orElseThrow());
+    }
+
+    @Test
+    void retainsLegacyLifecycleMappingFallback() {
+        Lookup lookup = mock(Lookup.class);
+        TypeRegistry types = mock(TypeRegistry.class);
+        LifecycleMapping mapping = mock(LifecycleMapping.class);
+        Type type = mock(Type.class);
+        when(lookup.lookupOptional(LifecycleMapping.class, "jar")).thenReturn(Optional.of(mapping));
+        when(mapping.getLifecycles()).thenReturn(Map.of());
+        when(types.lookup("jar")).thenReturn(Optional.of(type));
+
+        DefaultPackagingRegistry registry = new DefaultPackagingRegistry(lookup, types, List.of());
+        Packaging packaging = registry.lookup("jar").orElseThrow();
+
+        assertEquals("jar", packaging.id());
+        assertSame(type, packaging.type());
+        assertTrue(packaging.plugins().isEmpty());
+    }
+
+    private static Packaging packaging(String id) {
+        Packaging packaging = mock(Packaging.class);
+        when(packaging.id()).thenReturn(id);
+        return packaging;
+    }
+}
diff --git a/impl/maven-core/src/test/java/org/apache/maven/internal/impl/DefaultTypeRegistryTest.java b/impl/maven-core/src/test/java/org/apache/maven/internal/impl/DefaultTypeRegistryTest.java
new file mode 100644
index 0000000000..81817a0d86
--- /dev/null
+++ b/impl/maven-core/src/test/java/org/apache/maven/internal/impl/DefaultTypeRegistryTest.java
@@ -0,0 +1,139 @@
+/*
+ * 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.
+ */
+package org.apache.maven.internal.impl;
+
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.apache.maven.api.Language;
+import org.apache.maven.api.PathType;
+import org.apache.maven.api.Type;
+import org.apache.maven.api.services.LanguageRegistry;
+import org.apache.maven.api.services.Lookup;
+import org.apache.maven.api.spi.TypeProvider;
+import org.apache.maven.artifact.handler.ArtifactHandler;
+import org.apache.maven.artifact.handler.manager.LegacyArtifactHandlerManager;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+class DefaultTypeRegistryTest {
+
+    @Test
+    void findsTypeFromDynamicProviderLookup() {
+        Lookup lookup = mock(Lookup.class);
+        Type customType = stubType("app-client");
+        TypeProvider provider = () -> List.of(customType);
+        when(lookup.lookupList(TypeProvider.class)).thenReturn(List.of(provider));
+
+        DefaultTypeRegistry registry =
+                new DefaultTypeRegistry(lookup, mock(LanguageRegistry.class), mock(LegacyArtifactHandlerManager.class));
+
+        assertSame(customType, registry.require("app-client"));
+    }
+
+    @Test
+    void doesNotRetainDynamicTypeAcrossProjects() {
+        Lookup lookup = mock(Lookup.class);
+        LanguageRegistry langReg = mock(LanguageRegistry.class);
+        LegacyArtifactHandlerManager handlerMgr = mock(LegacyArtifactHandlerManager.class);
+        ArtifactHandler fallbackHandler = stubHandler();
+        when(handlerMgr.getArtifactHandler(anyString())).thenReturn(fallbackHandler);
+        when(langReg.lookup(anyString())).thenReturn(java.util.Optional.of(Language.NONE));
+
+        Type customType = stubType("app-client");
+        TypeProvider provider = () -> List.of(customType);
+        AtomicReference<List<TypeProvider>> visible = new AtomicReference<>(List.of(provider));
+        when(lookup.lookupList(TypeProvider.class)).thenAnswer(inv -> visible.get());
+
+        DefaultTypeRegistry registry = new DefaultTypeRegistry(lookup, langReg, handlerMgr);
+
+        assertSame(customType, registry.require("app-client"));
+        visible.set(List.of());
+        Type fallback = registry.require("app-client");
+        assertEquals("app-client", fallback.id());
+        assertNotSame(customType, fallback);
+    }
+
+    @Test
+    void fallsBackToLegacyArtifactHandler() {
+        Lookup lookup = mock(Lookup.class);
+        LanguageRegistry langReg = mock(LanguageRegistry.class);
+        LegacyArtifactHandlerManager handlerMgr = mock(LegacyArtifactHandlerManager.class);
+        ArtifactHandler handler = stubHandler();
+        when(lookup.lookupList(TypeProvider.class)).thenReturn(List.of());
+        when(handlerMgr.getArtifactHandler("jar")).thenReturn(handler);
+        when(langReg.lookup("java")).thenReturn(java.util.Optional.of(Language.JAVA_FAMILY));
+
+        DefaultTypeRegistry registry = new DefaultTypeRegistry(lookup, langReg, handlerMgr);
+        Type type = registry.require("jar");
+
+        assertEquals("jar", type.id());
+    }
+
+    private static Type stubType(String id) {
+        return new Type() {
+            @Override
+            public String id() {
+                return id;
+            }
+
+            @Override
+            public Language getLanguage() {
+                return Language.JAVA_FAMILY;
+            }
+
+            @Override
+            public String getExtension() {
+                return "jar";
+            }
+
+            @Override
+            public String getClassifier() {
+                return null;
+            }
+
+            @Override
+            public boolean isIncludesDependencies() {
+                return false;
+            }
+
+            @Override
+            public Set<PathType> getPathTypes() {
+                return Set.of();
+            }
+        };
+    }
+
+    private static ArtifactHandler stubHandler() {
+        ArtifactHandler handler = mock(ArtifactHandler.class);
+        when(handler.getLanguage()).thenReturn("java");
+        when(handler.getExtension()).thenReturn("jar");
+        when(handler.getClassifier()).thenReturn(null);
+        when(handler.isIncludesDependencies()).thenReturn(false);
+        when(handler.isAddedToClasspath()).thenReturn(true);
+        return handler;
+    }
+}
diff --git a/impl/maven-impl/src/main/java/org/apache/maven/impl/ExtensibleEnumRegistries.java b/impl/maven-impl/src/main/java/org/apache/maven/impl/ExtensibleEnumRegistries.java
index 5716538702..bfbd307bf5 100644
--- a/impl/maven-impl/src/main/java/org/apache/maven/impl/ExtensibleEnumRegistries.java
+++ b/impl/maven-impl/src/main/java/org/apache/maven/impl/ExtensibleEnumRegistries.java
@@ -35,6 +35,7 @@
 import org.apache.maven.api.di.Singleton;
 import org.apache.maven.api.services.ExtensibleEnumRegistry;
 import org.apache.maven.api.services.LanguageRegistry;
+import org.apache.maven.api.services.Lookup;
 import org.apache.maven.api.services.PathScopeRegistry;
 import org.apache.maven.api.services.ProjectScopeRegistry;
 import org.apache.maven.api.spi.ExtensibleEnumProvider;
@@ -89,15 +90,50 @@ public abstract static class DefaultExtensibleEnumRegistry<
             implements ExtensibleEnumRegistry<T> {
 
         protected final Map<String, T> values;
+        private final Lookup lookup;
+        private final Class<P> providerType;
 
+        @SafeVarargs
         public DefaultExtensibleEnumRegistry(List<P> providers, T... builtinValues) {
+            this(null, null, providers, builtinValues);
+        }
+
+        @SafeVarargs
+        public DefaultExtensibleEnumRegistry(
+                Lookup lookup, Class<P> providerType, List<P> providers, T... builtinValues) {
+            this.lookup = lookup;
+            this.providerType = providerType;
             values = Stream.concat(Stream.of(builtinValues), providers.stream().flatMap(p -> p.provides().stream()))
                     .collect(Collectors.toUnmodifiableMap(t -> t.id().toLowerCase(Locale.ROOT), t -> t));
         }
 
+        /**
+         * Looks up an enum value by id, checking dynamic providers before the static registry.
+         *
+         * <p><b>Cardinality assumption:</b> when dynamic lookup is enabled, this method iterates
+         * all registered providers and all their values on every call — O(n·m) where {@code n} is
+         * the number of providers and {@code m} is the average number of values per provider.
+         * Both are expected to be O(tens) in practice (a handful of SPI providers, each contributing
+         * a small set of values). This method is <em>not</em> designed for cardinalities in the
+         * thousands; callers that need to look up the same value repeatedly in a tight loop should
+         * cache the result themselves.</p>
+         *
+         * @param id the enum value id, must not be {@code null}
+         * @return the matching value, or {@code Optional.empty()} if not found
+         */
         @Override
         public Optional<T> lookup(String id) {
-            return Optional.ofNullable(values.get(requireNonNull(id, "id").toLowerCase(Locale.ROOT)));
+            String key = requireNonNull(id, "id").toLowerCase(Locale.ROOT);
+            if (lookup != null && providerType != null) {
+                Optional<T> result = lookup.lookupList(providerType).stream()
+                        .flatMap(p -> p.provides().stream())
+                        .filter(t -> key.equals(t.id().toLowerCase(Locale.ROOT)))
+                        .findFirst();
+                if (result.isPresent()) {
+                    return result;
+                }
+            }
+            return Optional.ofNullable(values.get(key));
         }
     }
 }
diff --git a/impl/maven-impl/src/test/java/org/apache/maven/impl/DefaultExtensibleEnumRegistryTest.java b/impl/maven-impl/src/test/java/org/apache/maven/impl/DefaultExtensibleEnumRegistryTest.java
new file mode 100644
index 0000000000..984e70bd8f
--- /dev/null
+++ b/impl/maven-impl/src/test/java/org/apache/maven/impl/DefaultExtensibleEnumRegistryTest.java
@@ -0,0 +1,118 @@
+/*
+ * 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.
+ */
+package org.apache.maven.impl;
+
+import java.util.List;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.apache.maven.api.ExtensibleEnum;
+import org.apache.maven.api.services.Lookup;
+import org.apache.maven.api.spi.ExtensibleEnumProvider;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+class DefaultExtensibleEnumRegistryTest {
+
+    private static final TestValue FOO = new TestValue("foo");
+    private static final TestValue BAR = new TestValue("bar");
+    private static final TestValue CUSTOM = new TestValue("custom");
+
+    @Test
+    void lookupFindsBuiltinValues() {
+        var registry = new TestRegistry(List.of(), FOO, BAR);
+        assertSame(FOO, registry.lookup("foo").orElseThrow());
+        assertSame(BAR, registry.lookup("BAR").orElseThrow());
+    }
+
+    @Test
+    void lookupFindsConstructorInjectedProviders() {
+        TestProvider provider = () -> List.of(CUSTOM);
+        var registry = new TestRegistry(List.of(provider));
+        assertSame(CUSTOM, registry.lookup("custom").orElseThrow());
+    }
+
+    @Test
+    void dynamicLookupFindsProjectExtensionProviders() {
+        Lookup lookup = mock(Lookup.class);
+        TestProvider provider = () -> List.of(CUSTOM);
+        when(lookup.lookupList(TestProvider.class)).thenReturn(List.of(provider));
+
+        var registry = new TestRegistry(lookup, List.of());
+        assertSame(CUSTOM, registry.lookup("custom").orElseThrow());
+    }
+
+    @Test
+    void dynamicLookupTakesPriorityOverConstructorInjected() {
+        Lookup lookup = mock(Lookup.class);
+        TestValue builtin = new TestValue("foo");
+        TestValue override = new TestValue("foo");
+        TestProvider dynamicProvider = () -> List.of(override);
+        TestProvider injectedProvider = () -> List.of(builtin);
+        when(lookup.lookupList(TestProvider.class)).thenReturn(List.of(dynamicProvider));
+
+        var registry = new TestRegistry(lookup, List.of(injectedProvider));
+        assertSame(override, registry.lookup("foo").orElseThrow());
+    }
+
+    @Test
+    void dynamicLookupDoesNotRetainProviderAcrossProjects() {
+        Lookup lookup = mock(Lookup.class);
+        TestValue custom = new TestValue("custom");
+        TestProvider provider = () -> List.of(custom);
+        AtomicReference<List<TestProvider>> visible = new AtomicReference<>(List.of(provider));
+        when(lookup.lookupList(TestProvider.class)).thenAnswer(inv -> visible.get());
+
+        var registry = new TestRegistry(lookup, List.of());
+
+        assertSame(custom, registry.lookup("custom").orElseThrow());
+        visible.set(List.of());
+        assertTrue(registry.lookup("custom").isEmpty());
+    }
+
+    @Test
+    void fallsBackToBuiltinWhenDynamicLookupFindsNothing() {
+        Lookup lookup = mock(Lookup.class);
+        when(lookup.lookupList(TestProvider.class)).thenReturn(List.of());
+
+        TestValue foo = new TestValue("foo");
+        var registry = new TestRegistry(lookup, List.of(), foo);
+        assertSame(foo, registry.lookup("foo").orElseThrow());
+    }
+
+    record TestValue(String id) implements ExtensibleEnum {}
+
+    interface TestProvider extends ExtensibleEnumProvider<TestValue> {}
+
+    static class TestRegistry extends ExtensibleEnumRegistries.DefaultExtensibleEnumRegistry<TestValue, TestProvider> {
+
+        @SafeVarargs
+        TestRegistry(List<TestProvider> providers, TestValue... builtins) {
+            super(providers, builtins);
+        }
+
+        @SafeVarargs
+        TestRegistry(Lookup lookup, List<TestProvider> providers, TestValue... builtins) {
+            super(lookup, TestProvider.class, providers, builtins);
+        }
+    }
+}
diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITgh13306PackagingProviderTest.java b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITgh13306PackagingProviderTest.java
new file mode 100644
index 0000000000..6a0144c637
--- /dev/null
+++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITgh13306PackagingProviderTest.java
@@ -0,0 +1,57 @@
+/*
+ * 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.
+ */
+package org.apache.maven.it;
+
+import java.nio.file.Path;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+class MavenITgh13306PackagingProviderTest extends AbstractMavenIntegrationTestCase {
+
+    @Test
+    void providerFromProjectExtensionIsVisibleOnlyToItsProject() throws Exception {
+        Path testDir = extractResources("gh-13306-packaging-provider");
+
+        Verifier verifier = newVerifier(testDir.resolve("extension"));
+        verifier.setAutoclean(false);
+        verifier.deleteArtifacts("org.apache.maven.its.gh13306");
+        verifier.addCliArgument("install");
+        verifier.execute();
+        verifier.verifyErrorFreeLog();
+
+        verifier = newVerifier(testDir.resolve("client"));
+        verifier.setAutoclean(false);
+        verifier.addCliArgument("validate");
+        verifier.execute();
+        verifier.verifyErrorFreeLog();
+
+        verifier = newVerifier(testDir.resolve("reactor"));
+        verifier.setAutoclean(false);
+        verifier.addCliArgument("validate");
+        try {
+            verifier.execute();
+            fail("The packaging provider leaked into a project without the extension");
+        } catch (VerificationException e) {
+            assertTrue(e.getMessage().contains("Unknown packaging: app-client"), e.getMessage());
+            assertTrue(e.getMessage().contains("without-extension"), e.getMessage());
+        }
+    }
+}
diff --git a/its/core-it-suite/src/test/resources/gh-13306-packaging-provider/client/pom.xml b/its/core-it-suite/src/test/resources/gh-13306-packaging-provider/client/pom.xml
new file mode 100644
index 0000000000..4cacee9960
--- /dev/null
+++ b/its/core-it-suite/src/test/resources/gh-13306-packaging-provider/client/pom.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.maven.its.gh13306</groupId>
+  <artifactId>client</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <packaging>app-client</packaging>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.its.gh13306</groupId>
+        <artifactId>packaging-extension</artifactId>
+        <version>1.0-SNAPSHOT</version>
+        <extensions>true</extensions>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/its/core-it-suite/src/test/resources/gh-13306-packaging-provider/extension/pom.xml b/its/core-it-suite/src/test/resources/gh-13306-packaging-provider/extension/pom.xml
new file mode 100644
index 0000000000..5a8e99ff5c
--- /dev/null
+++ b/its/core-it-suite/src/test/resources/gh-13306-packaging-provider/extension/pom.xml
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.maven.its.gh13306</groupId>
+  <artifactId>packaging-extension</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <packaging>maven-plugin</packaging>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-api-core</artifactId>
+      <version>4.0.0-rc-7</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-api-di</artifactId>
+      <version>4.0.0-rc-7</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-api-spi</artifactId>
+      <version>4.0.0-rc-7</version>
+      <scope>provided</scope>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-plugin-plugin</artifactId>
+        <version>4.0.0-beta-1</version>
+        <extensions>true</extensions>
+        <configuration>
+          <goalPrefix>packaging</goalPrefix>
+          <skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <version>3.14.0</version>
+        <configuration>
+          <release>17</release>
+          <proc>full</proc>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/impl/maven-core/src/test/java/org/apache/maven/internal/impl/DefaultLifecycleRegistryTest.java b/its/core-it-suite/src/test/resources/gh-13306-packaging-provider/extension/src/main/java/org/apache/maven/its/gh13306/CustomPackagingProvider.java
similarity index 54%
copy from impl/maven-core/src/test/java/org/apache/maven/internal/impl/DefaultLifecycleRegistryTest.java
copy to its/core-it-suite/src/test/resources/gh-13306-packaging-provider/extension/src/main/java/org/apache/maven/its/gh13306/CustomPackagingProvider.java
index a154a23c9d..42ef85125b 100644
--- a/impl/maven-core/src/test/java/org/apache/maven/internal/impl/DefaultLifecycleRegistryTest.java
+++ b/its/core-it-suite/src/test/resources/gh-13306-packaging-provider/extension/src/main/java/org/apache/maven/its/gh13306/CustomPackagingProvider.java
@@ -16,16 +16,25 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.maven.internal.impl;
+package org.apache.maven.its.gh13306;
 
-import org.junit.jupiter.api.Test;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
 
-import static org.junit.jupiter.api.Assertions.assertNull;
+import org.apache.maven.api.Packaging;
+import org.apache.maven.api.Type;
+import org.apache.maven.api.di.Named;
+import org.apache.maven.api.model.PluginContainer;
+import org.apache.maven.api.spi.PackagingProvider;
 
-class DefaultLifecycleRegistryTest {
+@Named
+public class CustomPackagingProvider implements PackagingProvider {
 
-    @Test
-    void returnsNullImplementationVersionWhenClassHasNoPackage() {
-        assertNull(DefaultLifecycleRegistry.getImplementationVersion(int.class));
+    @Override
+    public Collection<Packaging> provides() {
+        return List.of(new CustomPackaging("app-client", new CustomTypeProvider.CustomType(), Map.of()));
     }
+
+    private record CustomPackaging(String id, Type type, Map<String, PluginContainer> plugins) implements Packaging {}
 }
diff --git a/its/core-it-suite/src/test/resources/gh-13306-packaging-provider/extension/src/main/java/org/apache/maven/its/gh13306/CustomTypeProvider.java b/its/core-it-suite/src/test/resources/gh-13306-packaging-provider/extension/src/main/java/org/apache/maven/its/gh13306/CustomTypeProvider.java
new file mode 100644
index 0000000000..1b5d1d3820
--- /dev/null
+++ b/its/core-it-suite/src/test/resources/gh-13306-packaging-provider/extension/src/main/java/org/apache/maven/its/gh13306/CustomTypeProvider.java
@@ -0,0 +1,72 @@
+/*
+ * 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.
+ */
+package org.apache.maven.its.gh13306;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.maven.api.JavaPathType;
+import org.apache.maven.api.Language;
+import org.apache.maven.api.PathType;
+import org.apache.maven.api.Type;
+import org.apache.maven.api.di.Named;
+import org.apache.maven.api.spi.TypeProvider;
+
+@Named
+public class CustomTypeProvider implements TypeProvider {
+
+    @Override
+    public Collection<Type> provides() {
+        return List.of(new CustomType());
+    }
+
+    static class CustomType implements Type {
+
+        @Override
+        public String id() {
+            return "app-client";
+        }
+
+        @Override
+        public Language getLanguage() {
+            return Language.JAVA_FAMILY;
+        }
+
+        @Override
+        public String getExtension() {
+            return "jar";
+        }
+
+        @Override
+        public String getClassifier() {
+            return null;
+        }
+
+        @Override
+        public boolean isIncludesDependencies() {
+            return false;
+        }
+
+        @Override
+        public Set<PathType> getPathTypes() {
+            return Set.of(JavaPathType.CLASSES);
+        }
+    }
+}
diff --git a/its/core-it-suite/src/test/resources/gh-13306-packaging-provider/reactor/pom.xml b/its/core-it-suite/src/test/resources/gh-13306-packaging-provider/reactor/pom.xml
new file mode 100644
index 0000000000..756251bb70
--- /dev/null
+++ b/its/core-it-suite/src/test/resources/gh-13306-packaging-provider/reactor/pom.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.maven.its.gh13306</groupId>
+  <artifactId>reactor</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <packaging>pom</packaging>
+  <modules>
+    <module>with-extension</module>
+    <module>without-extension</module>
+  </modules>
+</project>
diff --git a/its/core-it-suite/src/test/resources/gh-13306-packaging-provider/reactor/with-extension/pom.xml b/its/core-it-suite/src/test/resources/gh-13306-packaging-provider/reactor/with-extension/pom.xml
new file mode 100644
index 0000000000..fead60c4c7
--- /dev/null
+++ b/its/core-it-suite/src/test/resources/gh-13306-packaging-provider/reactor/with-extension/pom.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.maven.its.gh13306</groupId>
+    <artifactId>reactor</artifactId>
+    <version>1.0-SNAPSHOT</version>
+  </parent>
+  <artifactId>with-extension</artifactId>
+  <packaging>app-client</packaging>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.its.gh13306</groupId>
+        <artifactId>packaging-extension</artifactId>
+        <version>1.0-SNAPSHOT</version>
+        <extensions>true</extensions>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/its/core-it-suite/src/test/resources/gh-13306-packaging-provider/reactor/without-extension/pom.xml b/its/core-it-suite/src/test/resources/gh-13306-packaging-provider/reactor/without-extension/pom.xml
new file mode 100644
index 0000000000..c7bad7e479
--- /dev/null
+++ b/its/core-it-suite/src/test/resources/gh-13306-packaging-provider/reactor/without-extension/pom.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.maven.its.gh13306</groupId>
+    <artifactId>reactor</artifactId>
+    <version>1.0-SNAPSHOT</version>
+  </parent>
+  <artifactId>without-extension</artifactId>
+  <packaging>app-client</packaging>
+</project>