diff --git a/maven-core/src/main/java/org/apache/maven/classrealm/ClassRealmManager.java b/maven-core/src/main/java/org/apache/maven/classrealm/ClassRealmManager.java index b72fe95460..20c5f23538 100644 --- a/maven-core/src/main/java/org/apache/maven/classrealm/ClassRealmManager.java +++ b/maven-core/src/main/java/org/apache/maven/classrealm/ClassRealmManager.java @@ -35,6 +35,13 @@ import org.codehaus.plexus.classworlds.realm.ClassRealm; public interface ClassRealmManager { + /** + * Gets the class realm hosting the Maven core. + * + * @return The class realm hosting the Maven core, never {@code null}. + */ + ClassRealm getCoreRealm(); + /** * Creates a new class realm for the specified project and its build extensions. * diff --git a/maven-core/src/main/java/org/apache/maven/classrealm/DefaultClassRealmManager.java b/maven-core/src/main/java/org/apache/maven/classrealm/DefaultClassRealmManager.java index 1c4ad31e65..84bd1bc237 100644 --- a/maven-core/src/main/java/org/apache/maven/classrealm/DefaultClassRealmManager.java +++ b/maven-core/src/main/java/org/apache/maven/classrealm/DefaultClassRealmManager.java @@ -104,7 +104,7 @@ public class DefaultClassRealmManager } else { - classRealm.setParentRealm( container.getContainerRealm() ); + classRealm.setParentRealm( getCoreRealm() ); importMavenApi( classRealm ); } @@ -141,7 +141,7 @@ public class DefaultClassRealmManager */ private void importXpp3Dom( ClassRealm importingRealm ) { - ClassRealm coreRealm = container.getContainerRealm(); + ClassRealm coreRealm = getCoreRealm(); importingRealm.importFrom( coreRealm, "org.codehaus.plexus.util.xml.Xpp3Dom" ); importingRealm.importFrom( coreRealm, "org.codehaus.plexus.util.xml.pull.XmlPullParser" ); @@ -185,6 +185,11 @@ public class DefaultClassRealmManager importingRealm.importFromParent( "org.codehaus.plexus.PlexusContainerException" ); } + public ClassRealm getCoreRealm() + { + return container.getContainerRealm(); + } + public ClassRealm createProjectRealm( Model model ) { if ( model == null ) diff --git a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingHelper.java b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingHelper.java index 772e81ac2c..7279fda2f4 100644 --- a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingHelper.java +++ b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingHelper.java @@ -439,7 +439,7 @@ public class DefaultProjectBuildingHelper if ( projectRealm == null ) { - projectRealm = container.getContainerRealm(); + projectRealm = classRealmManager.getCoreRealm(); } Thread.currentThread().setContextClassLoader( projectRealm );