* the entry point classes as defined in manifests. It assumes that JAR files are compatible with current
* environment (minimal sonarqube version, compatibility between plugins, ...):
* <ul>
- * <li>server verifies compatibility of JARs before deploying them at startup (see ServerPluginRepository)</li>
- * <li>batch loads only the plugins deployed on server (see BatchPluginRepository)</li>
+ * <li>server verifies compatibility of JARs before deploying them at startup (see ServerPluginRepository)</li>
+ * <li>batch loads only the plugins deployed on server (see BatchPluginRepository)</li>
* </ul>
* <p/>
* Plugins have their own isolated classloader, inheriting only from API classes.
// The plugins that extend other plugins can only add some files to classloader.
// They can't change metadata like ordering strategy or compatibility mode.
if (Strings.isNullOrEmpty(info.getBasePlugin())) {
+ if (info.isUseChildFirstClassLoader()) {
+ Loggers.get(getClass()).warn("Plugin {} [{}] uses a child first classloader which is deprecated", info.getName(), info.getKey());
+ }
def.setSelfFirstStrategy(info.isUseChildFirstClassLoader());
Version minSqVersion = info.getMinimalSqVersion();
boolean compatibilityMode = minSqVersion != null && minSqVersion.compareToIgnoreQualifier(COMPATIBILITY_MODE_MAX_VERSION) < 0;
import com.google.common.collect.ImmutableMap;
import java.io.File;
+import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
// TODO test mask - require change in sonar-classloader
}
+ @Test
+ public void log_warning_if_plugin_uses_child_first_classloader() throws IOException {
+ File jarFile = temp.newFile();
+ PluginInfo info = new PluginInfo("foo")
+ .setJarFile(jarFile)
+ .setUseChildFirstClassLoader(true)
+ .setMainClass("org.foo.FooPlugin");
+
+ Collection<PluginClassLoaderDef> defs = underTest.defineClassloaders(ImmutableMap.of("foo", info));
+ assertThat(defs).extracting(PluginClassLoaderDef::getBasePluginKey).containsExactly("foo");
+
+ List<String> warnings = logTester.logs(LoggerLevel.WARN);
+ assertThat(warnings).contains("Plugin foo [foo] uses a child first classloader which is deprecated");
+ }
+
@Test
public void log_warning_if_plugin_is_built_with_api_5_2_or_lower() throws Exception {
File jarFile = temp.newFile();