From cae779e4fbc6565a581f2c6adf9fb15348005603 Mon Sep 17 00:00:00 2001 From: Stephen Connolly Date: Tue, 17 Oct 2017 19:17:17 +0100 Subject: [PATCH] Revert "[MNG-6275] Maven Embedder compatible fix" This reverts commit 27a2bda3f4a8f5385c4cab360ed7365d3d3d3c09. --- .../classrealm/DefaultClassRealmManager.java | 2 +- .../DefaultClassRealmManagerTest.java | 107 ------------------ 2 files changed, 1 insertion(+), 108 deletions(-) delete mode 100644 maven-core/src/test/java/org/apache/maven/classrealm/DefaultClassRealmManagerTest.java 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 013ab2349d..6ce192588b 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 @@ -120,7 +120,7 @@ public class DefaultClassRealmManager { try { - ClassRealm classRealm = world.newRealm( realmId, PARENT_CLASSLOADER ); + ClassRealm classRealm = world.newRealm( realmId, null ); if ( logger.isDebugEnabled() ) { diff --git a/maven-core/src/test/java/org/apache/maven/classrealm/DefaultClassRealmManagerTest.java b/maven-core/src/test/java/org/apache/maven/classrealm/DefaultClassRealmManagerTest.java deleted file mode 100644 index 6d074b9bd0..0000000000 --- a/maven-core/src/test/java/org/apache/maven/classrealm/DefaultClassRealmManagerTest.java +++ /dev/null @@ -1,107 +0,0 @@ -package org.apache.maven.classrealm; - -/* - * 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. - */ - -import java.util.ServiceLoader; - -import javax.script.ScriptEngineFactory; - -import org.apache.maven.model.Model; -import org.apache.maven.model.Plugin; -import org.codehaus.plexus.ContainerConfiguration; -import org.codehaus.plexus.PlexusConstants; -import org.codehaus.plexus.PlexusTestCase; -import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.junit.Test; - -public class DefaultClassRealmManagerTest extends PlexusTestCase -{ - private ClassRealmManager classRealmManager; - private boolean haveScriptEngineFactory; - - @Override - protected void setUp() - throws Exception - { - super.setUp(); - this.classRealmManager = lookup( ClassRealmManager.class ); - ClassLoader testRealm = getClass().getClassLoader(); - ServiceLoader sef = ServiceLoader.load( ScriptEngineFactory.class, testRealm ); - // TODO switch to Assume.assumeTrue( sef.iterator().hasNext() ) when PlexusTestCase - // supports assumptions. Not every Java 7 JRE has a ScriptEngineFactory. - this.haveScriptEngineFactory = sef.iterator().hasNext(); - } - - @Override - protected void customizeContainerConfiguration( ContainerConfiguration configuration ) - { - configuration.setClassPathScanning( PlexusConstants.SCANNING_INDEX ); - } - - @Test - public void testMNG6275_pluginRealmDefaultParentClassLoader() - { - Plugin plugin = new Plugin(); - plugin.setVersion( "VERSION" ); - - ClassLoader parent = null; - - ClassRealm pluginRealm = classRealmManager.createPluginRealm( plugin, parent, null, null, null ); - ServiceLoader sef = ServiceLoader.load( ScriptEngineFactory.class, pluginRealm ); - assertEquals( haveScriptEngineFactory, sef.iterator().hasNext() ); - } - - @Test - public void testMNG6275_extensionRealmDefaultParentClassLoader() - { - Plugin extension = new Plugin(); - extension.setVersion( "VERSION" ); - - ClassRealm extensionRealm = classRealmManager.createExtensionRealm( extension, null ); - ServiceLoader sef = ServiceLoader.load( ScriptEngineFactory.class, extensionRealm ); - assertEquals( haveScriptEngineFactory, sef.iterator().hasNext() ); - } - - @Test - public void testMNG6275_projectRealmDefaultParentClassLoader() - { - Model model = new Model(); - - ClassRealm projectRealm = classRealmManager.createProjectRealm( model, null ); - ServiceLoader sef = ServiceLoader.load( ScriptEngineFactory.class, projectRealm ); - assertEquals( haveScriptEngineFactory, sef.iterator().hasNext() ); - } - - @Test - public void testMNG6275_mavenApiRealmDefaultParentClassLoader() - { - ClassRealm mavenApiRealm = classRealmManager.getMavenApiRealm(); - ServiceLoader sef = ServiceLoader.load( ScriptEngineFactory.class, mavenApiRealm ); - assertEquals( haveScriptEngineFactory, sef.iterator().hasNext() ); - } - - @Test - public void testMNG6275_coreRealmDefaultParentClassLoader() - { - ClassRealm coreRealm = classRealmManager.getCoreRealm(); - ServiceLoader sef = ServiceLoader.load( ScriptEngineFactory.class, coreRealm ); - assertEquals( haveScriptEngineFactory, sef.iterator().hasNext() ); - } -}