aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2015-05-27 14:27:34 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2015-05-28 09:29:05 +0200
commit386e6a13b460e25ad032004d3635b071bf91e104 (patch)
treefd223fb5d79b39e6882ab83e5bf5dec5f5fed0db
parent92f01954fc68bcbe8004b1e8433a469ca67118e7 (diff)
downloadsonarqube-386e6a13b460e25ad032004d3635b071bf91e104.tar.gz
sonarqube-386e6a13b460e25ad032004d3635b071bf91e104.zip
SONAR-6370 drop core plugin
The core plugin was highly coupled with core, so it did not respect classloader isolation as other plugins.
-rw-r--r--plugins/sonar-core-plugin/pom.xml43
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java33
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/package-info.java23
-rw-r--r--pom.xml1
-rw-r--r--sonar-application/pom.xml7
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchPluginPredicate.java19
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/bootstrap/BatchPluginPredicateTest.java16
-rw-r--r--sonar-core/src/main/java/org/sonar/core/i18n/DefaultI18n.java46
-rw-r--r--sonar-core/src/main/java/org/sonar/core/i18n/I18nClassloader.java1
-rw-r--r--sonar-core/src/test/java/org/sonar/core/i18n/DefaultI18nTest.java47
10 files changed, 34 insertions, 202 deletions
diff --git a/plugins/sonar-core-plugin/pom.xml b/plugins/sonar-core-plugin/pom.xml
deleted file mode 100644
index 770bdb4ed90..00000000000
--- a/plugins/sonar-core-plugin/pom.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.codehaus.sonar</groupId>
- <artifactId>sonar</artifactId>
- <version>5.2-SNAPSHOT</version>
- <relativePath>../..</relativePath>
- </parent>
- <groupId>org.codehaus.sonar.plugins</groupId>
- <artifactId>sonar-core-plugin</artifactId>
- <packaging>sonar-plugin</packaging>
- <name>SonarQube :: Plugins :: Core</name>
-
- <dependencies>
- <dependency>
- <groupId>org.codehaus.sonar</groupId>
- <artifactId>sonar-plugin-api</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>com.google.code.findbugs</groupId>
- <artifactId>jsr305</artifactId>
- <scope>provided</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.codehaus.sonar</groupId>
- <artifactId>sonar-packaging-maven-plugin</artifactId>
- <configuration>
- <pluginKey>core</pluginKey>
- <pluginName>Core</pluginName>
- <pluginClass>org.sonar.plugins.core.CorePlugin</pluginClass>
- <pluginDescription>
- <![CDATA[Provides all common components required to cover all languages.]]></pluginDescription>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java
deleted file mode 100644
index ceb5531722f..00000000000
--- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.plugins.core;
-
-import java.util.Collections;
-import java.util.List;
-import org.sonar.api.SonarPlugin;
-
-public final class CorePlugin extends SonarPlugin {
-
- @Override
- public List getExtensions() {
- return Collections.emptyList();
- }
-
-}
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/package-info.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/package-info.java
deleted file mode 100644
index 289afcacc66..00000000000
--- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/package-info.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-@ParametersAreNonnullByDefault
-package org.sonar.plugins.core;
-
-import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/pom.xml b/pom.xml
index f1a529eb47e..e7d4485e6c5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -27,7 +27,6 @@
<module>sonar-plugin-api</module>
<module>server</module>
<module>sonar-testing-harness</module>
- <module>plugins/sonar-core-plugin</module>
<module>plugins/sonar-l10n-en-plugin</module>
<module>plugins/sonar-email-notifications-plugin</module>
<module>plugins/sonar-xoo-plugin</module>
diff --git a/sonar-application/pom.xml b/sonar-application/pom.xml
index dbf50534e4d..ef50d795c6a 100644
--- a/sonar-application/pom.xml
+++ b/sonar-application/pom.xml
@@ -91,13 +91,6 @@
<!-- core plugins -->
<dependency>
<groupId>org.codehaus.sonar.plugins</groupId>
- <artifactId>sonar-core-plugin</artifactId>
- <version>${project.version}</version>
- <type>sonar-plugin</type>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.codehaus.sonar.plugins</groupId>
<artifactId>sonar-l10n-en-plugin</artifactId>
<version>${project.version}</version>
<type>sonar-plugin</type>
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchPluginPredicate.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchPluginPredicate.java
index 5381037ccf2..b68a51b1bf2 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchPluginPredicate.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchPluginPredicate.java
@@ -23,30 +23,27 @@ import com.google.common.base.Joiner;
import com.google.common.base.Predicate;
import com.google.common.base.Splitter;
import com.google.common.collect.Lists;
+import java.text.MessageFormat;
+import java.util.List;
+import java.util.Set;
+import javax.annotation.Nonnull;
import org.apache.commons.lang.StringUtils;
-import org.sonar.api.batch.BatchSide;
import org.sonar.api.CoreProperties;
+import org.sonar.api.batch.BatchSide;
import org.sonar.api.config.Settings;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
-import javax.annotation.Nonnull;
-
-import java.text.MessageFormat;
-import java.util.List;
-import java.util.Set;
-
import static com.google.common.collect.Sets.newHashSet;
/**
* Filters the plugins to be enabled during analysis
*/
@BatchSide
-public class BatchPluginPredicate implements Predicate<String>{
+public class BatchPluginPredicate implements Predicate<String> {
private static final Logger LOG = Loggers.get(BatchPluginPredicate.class);
- private static final String CORE_PLUGIN_KEY = "core";
private static final String BUILDBREAKER_PLUGIN_KEY = "buildbreaker";
private static final String PROPERTY_IS_DEPRECATED_MSG = "Property {0} is deprecated. Please use {1} instead.";
private static final Joiner COMMA_JOINER = Joiner.on(", ");
@@ -86,10 +83,6 @@ public class BatchPluginPredicate implements Predicate<String>{
@Override
public boolean apply(@Nonnull String pluginKey) {
- if (CORE_PLUGIN_KEY.equals(pluginKey)) {
- return !mode.isMediumTest();
- }
-
if (BUILDBREAKER_PLUGIN_KEY.equals(pluginKey) && mode.isPreview()) {
LOG.info("Build Breaker plugin is no more supported in preview/incremental mode");
return false;
diff --git a/sonar-batch/src/test/java/org/sonar/batch/bootstrap/BatchPluginPredicateTest.java b/sonar-batch/src/test/java/org/sonar/batch/bootstrap/BatchPluginPredicateTest.java
index 57176404845..511d29d9244 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/bootstrap/BatchPluginPredicateTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/bootstrap/BatchPluginPredicateTest.java
@@ -59,22 +59,6 @@ public class BatchPluginPredicateTest {
}
@Test
- public void accept_core_plugin_even_if_not_in_inclusions() {
- when(mode.isPreview()).thenReturn(true);
- settings.setProperty(CoreProperties.PREVIEW_INCLUDE_PLUGINS, "checkstyle,pmd,findbugs");
- BatchPluginPredicate predicate = new BatchPluginPredicate(settings, mode);
- assertThat(predicate.apply("core")).isTrue();
- }
-
- @Test
- public void accept_core_plugin_even_if_declared_in_exclusions() {
- when(mode.isPreview()).thenReturn(true);
- settings.setProperty(CoreProperties.PREVIEW_EXCLUDE_PLUGINS, "core,findbugs");
- BatchPluginPredicate predicate = new BatchPluginPredicate(settings, mode);
- assertThat(predicate.apply("core")).isTrue();
- }
-
- @Test
public void verify_both_inclusions_and_exclusions() {
when(mode.isPreview()).thenReturn(true);
settings
diff --git a/sonar-core/src/main/java/org/sonar/core/i18n/DefaultI18n.java b/sonar-core/src/main/java/org/sonar/core/i18n/DefaultI18n.java
index c72cc88c38c..fbde3475122 100644
--- a/sonar-core/src/main/java/org/sonar/core/i18n/DefaultI18n.java
+++ b/sonar-core/src/main/java/org/sonar/core/i18n/DefaultI18n.java
@@ -21,21 +21,6 @@ package org.sonar.core.i18n;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
-import org.apache.commons.io.IOUtils;
-import org.picocontainer.Startable;
-import org.sonar.api.batch.BatchSide;
-import org.sonar.api.server.ServerSide;
-import org.sonar.api.i18n.I18n;
-import org.sonar.api.utils.SonarException;
-import org.sonar.api.utils.System2;
-import org.sonar.api.utils.log.Logger;
-import org.sonar.api.utils.log.Loggers;
-import org.sonar.core.platform.PluginInfo;
-import org.sonar.core.platform.PluginRepository;
-
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
@@ -52,6 +37,19 @@ import java.util.Map;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import java.util.Set;
+import javax.annotation.CheckForNull;
+import javax.annotation.Nullable;
+import org.apache.commons.io.IOUtils;
+import org.picocontainer.Startable;
+import org.sonar.api.batch.BatchSide;
+import org.sonar.api.i18n.I18n;
+import org.sonar.api.server.ServerSide;
+import org.sonar.api.utils.SonarException;
+import org.sonar.api.utils.System2;
+import org.sonar.api.utils.log.Logger;
+import org.sonar.api.utils.log.Loggers;
+import org.sonar.core.platform.PluginInfo;
+import org.sonar.core.platform.PluginRepository;
@BatchSide
@ServerSide
@@ -91,18 +89,18 @@ public class DefaultI18n implements I18n, Startable {
void doStart(ClassLoader classloader) {
this.classloader = classloader;
this.propertyToBundles = new HashMap<>();
+
+ // org.sonar.l10n.core bundle is provided by sonar-core module
+ initPlugin("core");
+
Collection<PluginInfo> infos = pluginRepository.getPluginInfos();
- if (infos.isEmpty()) {
- addPlugin("core");
- } else {
- for (PluginInfo plugin : infos) {
- addPlugin(plugin.getKey());
- }
+ for (PluginInfo plugin : infos) {
+ initPlugin(plugin.getKey());
}
LOG.debug("Loaded {} properties from l10n bundles", propertyToBundles.size());
}
- private void addPlugin(String pluginKey) {
+ private void initPlugin(String pluginKey) {
try {
String bundleKey = BUNDLE_PACKAGE + pluginKey;
ResourceBundle bundle = ResourceBundle.getBundle(bundleKey, Locale.ENGLISH, this.classloader, control);
@@ -233,8 +231,4 @@ public class DefaultI18n implements I18n, Startable {
}
return MessageFormat.format(message.replaceAll("'", "''"), parameters);
}
-
- ClassLoader getBundleClassLoader() {
- return classloader;
- }
}
diff --git a/sonar-core/src/main/java/org/sonar/core/i18n/I18nClassloader.java b/sonar-core/src/main/java/org/sonar/core/i18n/I18nClassloader.java
index 9647eb784ca..9c672864ead 100644
--- a/sonar-core/src/main/java/org/sonar/core/i18n/I18nClassloader.java
+++ b/sonar-core/src/main/java/org/sonar/core/i18n/I18nClassloader.java
@@ -75,6 +75,7 @@ class I18nClassloader extends URLClassLoader {
Plugin plugin = pluginRepository.getPluginInstance(info.getKey());
list.add(plugin.getClass().getClassLoader());
}
+ list.add(I18nClassloader.class.getClassLoader());
return list;
}
}
diff --git a/sonar-core/src/test/java/org/sonar/core/i18n/DefaultI18nTest.java b/sonar-core/src/test/java/org/sonar/core/i18n/DefaultI18nTest.java
index 110694aff65..9cd5a7ff7bc 100644
--- a/sonar-core/src/test/java/org/sonar/core/i18n/DefaultI18nTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/i18n/DefaultI18nTest.java
@@ -19,6 +19,10 @@
*/
package org.sonar.core.i18n;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Locale;
+import java.util.TimeZone;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -29,13 +33,6 @@ import org.sonar.api.utils.System2;
import org.sonar.core.platform.PluginInfo;
import org.sonar.core.platform.PluginRepository;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Locale;
-import java.util.TimeZone;
-
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -51,7 +48,7 @@ public class DefaultI18nTest {
@Before
public void before() {
PluginRepository pluginRepository = mock(PluginRepository.class);
- List<PluginInfo> plugins = Arrays.asList(newPlugin("core"), newPlugin("sqale"), newPlugin("frpack"), newPlugin("checkstyle"), newPlugin("other"));
+ List<PluginInfo> plugins = Arrays.asList(newPlugin("sqale"), newPlugin("frpack"), newPlugin("checkstyle"), newPlugin("other"));
when(pluginRepository.getPluginInfos()).thenReturn(plugins);
manager = new DefaultI18n(pluginRepository, system2);
@@ -59,12 +56,8 @@ public class DefaultI18nTest {
}
@Test
- public void load_core_bundle_when_no_plugin() {
- DefaultI18n manager = new DefaultI18n(mock(PluginRepository.class), system2);
- manager.doStart(getClass().getClassLoader());
-
- assertThat(manager.getPropertyKeys().contains("any")).isTrue();
- assertThat(manager.getPropertyKeys().contains("assignee")).isTrue();
+ public void load_core_bundle() {
+ assertThat(manager.message(Locale.ENGLISH, "any", null)).isEqualTo("Any");
}
@Test
@@ -196,32 +189,6 @@ public class DefaultI18nTest {
assertThat(manager.formatInteger(Locale.ENGLISH, 100000)).isEqualTo("100,000");
}
- static URLClassLoader newCheckstyleClassloader() {
- return newClassLoader("/org/sonar/core/i18n/I18nClassloaderTest/");
- }
-
- /**
- * Example of plugin that embeds its own translations (English + French).
- */
- static URLClassLoader newSqaleClassloader() {
- return newClassLoader("/org/sonar/core/i18n/sqalePlugin/");
- }
-
- /**
- * "Language Pack" contains various translations for different plugins.
- */
- static URLClassLoader newFrenchPackClassloader() {
- return newClassLoader("/org/sonar/core/i18n/frenchPack/");
- }
-
- private static URLClassLoader newClassLoader(String... resourcePaths) {
- URL[] urls = new URL[resourcePaths.length];
- for (int index = 0; index < resourcePaths.length; index++) {
- urls[index] = DefaultI18nTest.class.getResource(resourcePaths[index]);
- }
- return new URLClassLoader(urls);
- }
-
private PluginInfo newPlugin(String key) {
PluginInfo plugin = mock(PluginInfo.class);
when(plugin.getKey()).thenReturn(key);