From 88e6ec0762914d72dd42fb8be3b1ce0fb1e447c2 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Tue, 21 Jun 2011 18:06:11 +0200 Subject: [PATCH] SONAR-2497 Merge i18n plugin with core --- .../org/sonar/plugins/core/CorePlugin.java | 4 ++ .../sonar/plugins/core}/i18n/I18nManager.java | 4 +- .../plugins/core}/i18n/InstalledPlugin.java | 2 +- .../core/i18n}/FrenchLanguagePack.java | 2 +- .../plugins/core}/i18n/I18nManagerTest.java | 13 ++-- .../core/i18n}/QuebecLanguagePack.java | 2 +- .../src/test/resources/FrenchPlugin.jar | Bin .../FrenchPlugin/META-INF/MANIFEST.MF | 0 .../org/sonar/i18n/test_fr.properties | 0 .../src/test/resources/QuebecPlugin.jar | Bin .../QuebecPlugin/META-INF/MANIFEST.MF | 0 .../org/sonar/i18n/test_fr_CA.properties | 0 .../src/test/resources/StandardPlugin.jar | Bin .../StandardPlugin/META-INF/MANIFEST.MF | 0 .../org/sonar/i18n/test.properties | 0 .../src/test/resources/logback-test.xml | 0 .../org/sonar/plugins/i18n/I18nPlugin.java | 36 ---------- .../sonar/plugins/i18n/I18nPluginTest.java | 33 --------- pom.xml | 1 - sonar-application/pom.xml | 6 -- .../src/main/assembly/conf/logback.xml | 2 +- .../bootstrap/BatchPluginRepository.java | 12 ++-- .../bootstrap/BatchPluginRepositoryTest.java | 26 +++++-- .../java/org/sonar/api/CoreProperties.java | 4 +- sonar-server/pom.xml | 6 -- .../app/controllers/i18n_controller.rb | 64 ++++++++++++++++++ 26 files changed, 112 insertions(+), 105 deletions(-) rename plugins/{sonar-i18n-plugin/src/main/java/org/sonar/plugins => sonar-core-plugin/src/main/java/org/sonar/plugins/core}/i18n/I18nManager.java (98%) rename plugins/{sonar-i18n-plugin/src/main/java/org/sonar/plugins => sonar-core-plugin/src/main/java/org/sonar/plugins/core}/i18n/InstalledPlugin.java (97%) rename plugins/{sonar-i18n-plugin/src/test/java/org/sonar/plugins/i18n/utils => sonar-core-plugin/src/test/java/org/sonar/plugins/core/i18n}/FrenchLanguagePack.java (96%) rename plugins/{sonar-i18n-plugin/src/test/java/org/sonar/plugins => sonar-core-plugin/src/test/java/org/sonar/plugins/core}/i18n/I18nManagerTest.java (93%) rename plugins/{sonar-i18n-plugin/src/test/java/org/sonar/plugins/i18n/utils => sonar-core-plugin/src/test/java/org/sonar/plugins/core/i18n}/QuebecLanguagePack.java (96%) rename plugins/{sonar-i18n-plugin => sonar-core-plugin}/src/test/resources/FrenchPlugin.jar (100%) rename plugins/{sonar-i18n-plugin => sonar-core-plugin}/src/test/resources/FrenchPlugin/META-INF/MANIFEST.MF (100%) rename plugins/{sonar-i18n-plugin => sonar-core-plugin}/src/test/resources/FrenchPlugin/org/sonar/i18n/test_fr.properties (100%) rename plugins/{sonar-i18n-plugin => sonar-core-plugin}/src/test/resources/QuebecPlugin.jar (100%) rename plugins/{sonar-i18n-plugin => sonar-core-plugin}/src/test/resources/QuebecPlugin/META-INF/MANIFEST.MF (100%) rename plugins/{sonar-i18n-plugin => sonar-core-plugin}/src/test/resources/QuebecPlugin/org/sonar/i18n/test_fr_CA.properties (100%) rename plugins/{sonar-i18n-plugin => sonar-core-plugin}/src/test/resources/StandardPlugin.jar (100%) rename plugins/{sonar-i18n-plugin => sonar-core-plugin}/src/test/resources/StandardPlugin/META-INF/MANIFEST.MF (100%) rename plugins/{sonar-i18n-plugin => sonar-core-plugin}/src/test/resources/StandardPlugin/org/sonar/i18n/test.properties (100%) rename plugins/{sonar-i18n-plugin => sonar-core-plugin}/src/test/resources/logback-test.xml (100%) delete mode 100644 plugins/sonar-i18n-plugin/src/main/java/org/sonar/plugins/i18n/I18nPlugin.java delete mode 100644 plugins/sonar-i18n-plugin/src/test/java/org/sonar/plugins/i18n/I18nPluginTest.java create mode 100644 sonar-server/src/main/webapp/WEB-INF/app/controllers/i18n_controller.rb 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 index f3b72b9e0c1..87d1e406442 100644 --- 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 @@ -34,6 +34,7 @@ import org.sonar.plugins.core.charts.XradarChart; import org.sonar.plugins.core.colorizers.JavaColorizerFormat; import org.sonar.plugins.core.duplicationsviewer.DuplicationsViewerDefinition; import org.sonar.plugins.core.hotspots.Hotspots; +import org.sonar.plugins.core.i18n.I18nManager; import org.sonar.plugins.core.metrics.UserManagedMetrics; import org.sonar.plugins.core.security.ApplyProjectRolesDecorator; import org.sonar.plugins.core.sensors.*; @@ -227,6 +228,9 @@ public class CorePlugin extends SonarPlugin { extensions.add(NewCoverageFileAnalyzer.class); extensions.add(NewCoverageAggregator.class); + // i18n + extensions.add(I18nManager.class); + return extensions; } } diff --git a/plugins/sonar-i18n-plugin/src/main/java/org/sonar/plugins/i18n/I18nManager.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/i18n/I18nManager.java similarity index 98% rename from plugins/sonar-i18n-plugin/src/main/java/org/sonar/plugins/i18n/I18nManager.java rename to plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/i18n/I18nManager.java index 6846f88b4ae..8438b706622 100644 --- a/plugins/sonar-i18n-plugin/src/main/java/org/sonar/plugins/i18n/I18nManager.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/i18n/I18nManager.java @@ -17,7 +17,7 @@ * License along with Sonar; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 */ -package org.sonar.plugins.i18n; +package org.sonar.plugins.core.i18n; import com.google.common.collect.Maps; import com.google.common.collect.Sets; @@ -108,7 +108,7 @@ public final class I18nManager implements I18n, ServerExtension, BatchExtension URL propertiesUrl = resources.get(0); if (!alreadyLoadedResources.contains(propertiesUrl.toURI())) { LOG.debug("Found the ResourceBundle base file : {} from classloader : {}", propertiesUrl, classloader); - LOG.info("Add bundleName : {} from classloader : {}", bundleBaseName, classloader); + LOG.debug("Add bundleName : {} from classloader : {}", bundleBaseName, classloader); bundleClassLoader.addResource(bundleDefaultPropertiesFile, classloader); alreadyLoadedResources.add(propertiesUrl.toURI()); diff --git a/plugins/sonar-i18n-plugin/src/main/java/org/sonar/plugins/i18n/InstalledPlugin.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/i18n/InstalledPlugin.java similarity index 97% rename from plugins/sonar-i18n-plugin/src/main/java/org/sonar/plugins/i18n/InstalledPlugin.java rename to plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/i18n/InstalledPlugin.java index d0348df1370..abe4b3cf0de 100644 --- a/plugins/sonar-i18n-plugin/src/main/java/org/sonar/plugins/i18n/InstalledPlugin.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/i18n/InstalledPlugin.java @@ -17,7 +17,7 @@ * License along with Sonar; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 */ -package org.sonar.plugins.i18n; +package org.sonar.plugins.core.i18n; import com.google.common.collect.Lists; import org.sonar.api.Plugin; diff --git a/plugins/sonar-i18n-plugin/src/test/java/org/sonar/plugins/i18n/utils/FrenchLanguagePack.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/i18n/FrenchLanguagePack.java similarity index 96% rename from plugins/sonar-i18n-plugin/src/test/java/org/sonar/plugins/i18n/utils/FrenchLanguagePack.java rename to plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/i18n/FrenchLanguagePack.java index 98c09780bfb..e781f5a891f 100644 --- a/plugins/sonar-i18n-plugin/src/test/java/org/sonar/plugins/i18n/utils/FrenchLanguagePack.java +++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/i18n/FrenchLanguagePack.java @@ -17,7 +17,7 @@ * License along with Sonar; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 */ -package org.sonar.plugins.i18n.utils; +package org.sonar.plugins.core.i18n; import org.sonar.api.i18n.LanguagePack; diff --git a/plugins/sonar-i18n-plugin/src/test/java/org/sonar/plugins/i18n/I18nManagerTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/i18n/I18nManagerTest.java similarity index 93% rename from plugins/sonar-i18n-plugin/src/test/java/org/sonar/plugins/i18n/I18nManagerTest.java rename to plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/i18n/I18nManagerTest.java index f4d075750f6..380f65efe3d 100644 --- a/plugins/sonar-i18n-plugin/src/test/java/org/sonar/plugins/i18n/I18nManagerTest.java +++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/i18n/I18nManagerTest.java @@ -17,9 +17,10 @@ * License along with Sonar; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 */ -package org.sonar.plugins.i18n; +package org.sonar.plugins.core.i18n; import com.google.common.collect.Lists; +import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.sonar.api.i18n.LanguagePack; @@ -36,9 +37,9 @@ import static org.mockito.Mockito.mock; public class I18nManagerTest { - public static String TEST_PLUGIN_CLASS_NAME = "org.sonar.plugins.i18n.utils.StandardPlugin"; - public static String FRENCH_PACK_CLASS_NAME = "org.sonar.plugins.i18n.utils.FrenchLanguagePack"; - public static String QUEBEC_PACK_CLASS_NAME = "org.sonar.plugins.i18n.utils.QuebecLanguagePack"; + public static String TEST_PLUGIN_CLASS_NAME = "org.sonar.plugins.core.i18n.StandardPlugin"; + public static String FRENCH_PACK_CLASS_NAME = "org.sonar.plugins.core.i18n.FrenchLanguagePack"; + public static String QUEBEC_PACK_CLASS_NAME = "org.sonar.plugins.core.i18n.QuebecLanguagePack"; private static URL classSource = I18nManagerTest.class.getProtectionDomain().getCodeSource().getLocation(); private I18nManager manager; @@ -93,8 +94,8 @@ public class I18nManagerTest { public void shouldTranslateUnknownValue() { String result = manager.message(Locale.FRENCH, "unknown", "Default value for Unknown"); assertEquals("Default value for Unknown", result); - assertEquals(1, manager.getUnknownKeys().size()); - assertEquals("Default value for Unknown", manager.getUnknownKeys().getProperty("unknown")); + Assert.assertEquals(1, manager.getUnknownKeys().size()); + Assert.assertEquals("Default value for Unknown", manager.getUnknownKeys().getProperty("unknown")); } public static class TestClassLoader extends URLClassLoader { diff --git a/plugins/sonar-i18n-plugin/src/test/java/org/sonar/plugins/i18n/utils/QuebecLanguagePack.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/i18n/QuebecLanguagePack.java similarity index 96% rename from plugins/sonar-i18n-plugin/src/test/java/org/sonar/plugins/i18n/utils/QuebecLanguagePack.java rename to plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/i18n/QuebecLanguagePack.java index 5e9913e2156..c8ed96a4edb 100644 --- a/plugins/sonar-i18n-plugin/src/test/java/org/sonar/plugins/i18n/utils/QuebecLanguagePack.java +++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/i18n/QuebecLanguagePack.java @@ -17,7 +17,7 @@ * License along with Sonar; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 */ -package org.sonar.plugins.i18n.utils; +package org.sonar.plugins.core.i18n; import org.sonar.api.i18n.LanguagePack; diff --git a/plugins/sonar-i18n-plugin/src/test/resources/FrenchPlugin.jar b/plugins/sonar-core-plugin/src/test/resources/FrenchPlugin.jar similarity index 100% rename from plugins/sonar-i18n-plugin/src/test/resources/FrenchPlugin.jar rename to plugins/sonar-core-plugin/src/test/resources/FrenchPlugin.jar diff --git a/plugins/sonar-i18n-plugin/src/test/resources/FrenchPlugin/META-INF/MANIFEST.MF b/plugins/sonar-core-plugin/src/test/resources/FrenchPlugin/META-INF/MANIFEST.MF similarity index 100% rename from plugins/sonar-i18n-plugin/src/test/resources/FrenchPlugin/META-INF/MANIFEST.MF rename to plugins/sonar-core-plugin/src/test/resources/FrenchPlugin/META-INF/MANIFEST.MF diff --git a/plugins/sonar-i18n-plugin/src/test/resources/FrenchPlugin/org/sonar/i18n/test_fr.properties b/plugins/sonar-core-plugin/src/test/resources/FrenchPlugin/org/sonar/i18n/test_fr.properties similarity index 100% rename from plugins/sonar-i18n-plugin/src/test/resources/FrenchPlugin/org/sonar/i18n/test_fr.properties rename to plugins/sonar-core-plugin/src/test/resources/FrenchPlugin/org/sonar/i18n/test_fr.properties diff --git a/plugins/sonar-i18n-plugin/src/test/resources/QuebecPlugin.jar b/plugins/sonar-core-plugin/src/test/resources/QuebecPlugin.jar similarity index 100% rename from plugins/sonar-i18n-plugin/src/test/resources/QuebecPlugin.jar rename to plugins/sonar-core-plugin/src/test/resources/QuebecPlugin.jar diff --git a/plugins/sonar-i18n-plugin/src/test/resources/QuebecPlugin/META-INF/MANIFEST.MF b/plugins/sonar-core-plugin/src/test/resources/QuebecPlugin/META-INF/MANIFEST.MF similarity index 100% rename from plugins/sonar-i18n-plugin/src/test/resources/QuebecPlugin/META-INF/MANIFEST.MF rename to plugins/sonar-core-plugin/src/test/resources/QuebecPlugin/META-INF/MANIFEST.MF diff --git a/plugins/sonar-i18n-plugin/src/test/resources/QuebecPlugin/org/sonar/i18n/test_fr_CA.properties b/plugins/sonar-core-plugin/src/test/resources/QuebecPlugin/org/sonar/i18n/test_fr_CA.properties similarity index 100% rename from plugins/sonar-i18n-plugin/src/test/resources/QuebecPlugin/org/sonar/i18n/test_fr_CA.properties rename to plugins/sonar-core-plugin/src/test/resources/QuebecPlugin/org/sonar/i18n/test_fr_CA.properties diff --git a/plugins/sonar-i18n-plugin/src/test/resources/StandardPlugin.jar b/plugins/sonar-core-plugin/src/test/resources/StandardPlugin.jar similarity index 100% rename from plugins/sonar-i18n-plugin/src/test/resources/StandardPlugin.jar rename to plugins/sonar-core-plugin/src/test/resources/StandardPlugin.jar diff --git a/plugins/sonar-i18n-plugin/src/test/resources/StandardPlugin/META-INF/MANIFEST.MF b/plugins/sonar-core-plugin/src/test/resources/StandardPlugin/META-INF/MANIFEST.MF similarity index 100% rename from plugins/sonar-i18n-plugin/src/test/resources/StandardPlugin/META-INF/MANIFEST.MF rename to plugins/sonar-core-plugin/src/test/resources/StandardPlugin/META-INF/MANIFEST.MF diff --git a/plugins/sonar-i18n-plugin/src/test/resources/StandardPlugin/org/sonar/i18n/test.properties b/plugins/sonar-core-plugin/src/test/resources/StandardPlugin/org/sonar/i18n/test.properties similarity index 100% rename from plugins/sonar-i18n-plugin/src/test/resources/StandardPlugin/org/sonar/i18n/test.properties rename to plugins/sonar-core-plugin/src/test/resources/StandardPlugin/org/sonar/i18n/test.properties diff --git a/plugins/sonar-i18n-plugin/src/test/resources/logback-test.xml b/plugins/sonar-core-plugin/src/test/resources/logback-test.xml similarity index 100% rename from plugins/sonar-i18n-plugin/src/test/resources/logback-test.xml rename to plugins/sonar-core-plugin/src/test/resources/logback-test.xml diff --git a/plugins/sonar-i18n-plugin/src/main/java/org/sonar/plugins/i18n/I18nPlugin.java b/plugins/sonar-i18n-plugin/src/main/java/org/sonar/plugins/i18n/I18nPlugin.java deleted file mode 100644 index 0e6495c021a..00000000000 --- a/plugins/sonar-i18n-plugin/src/main/java/org/sonar/plugins/i18n/I18nPlugin.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.plugins.i18n; - -import org.sonar.api.SonarPlugin; - -import java.util.Arrays; -import java.util.List; - -/** - * @since 2.9 - */ -public final class I18nPlugin extends SonarPlugin { - - public List getExtensions() { - return Arrays.asList(I18nManager.class, I18nWebService.class); - } - -} diff --git a/plugins/sonar-i18n-plugin/src/test/java/org/sonar/plugins/i18n/I18nPluginTest.java b/plugins/sonar-i18n-plugin/src/test/java/org/sonar/plugins/i18n/I18nPluginTest.java deleted file mode 100644 index 9fc007149e8..00000000000 --- a/plugins/sonar-i18n-plugin/src/test/java/org/sonar/plugins/i18n/I18nPluginTest.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.plugins.i18n; - -import org.junit.Test; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.number.OrderingComparisons.greaterThanOrEqualTo; - -public class I18nPluginTest { - - @Test - public void shouldGetExtensions() { - assertThat(new I18nPlugin().getExtensions().size(), greaterThanOrEqualTo(2)); - } -} diff --git a/pom.xml b/pom.xml index fb95f636230..5e43e693a05 100644 --- a/pom.xml +++ b/pom.xml @@ -48,7 +48,6 @@ plugins/sonar-cpd-plugin plugins/sonar-squid-java-plugin plugins/sonar-design-plugin - plugins/sonar-i18n-plugin diff --git a/sonar-application/pom.xml b/sonar-application/pom.xml index da36b404335..6e83c28617d 100644 --- a/sonar-application/pom.xml +++ b/sonar-application/pom.xml @@ -208,12 +208,6 @@ ${project.version} runtime - - org.codehaus.sonar.plugins - sonar-i18n-plugin - ${project.version} - runtime - org.sonatype.jsw-binaries jsw-binaries diff --git a/sonar-application/src/main/assembly/conf/logback.xml b/sonar-application/src/main/assembly/conf/logback.xml index c11fca34b93..50b83f80122 100644 --- a/sonar-application/src/main/assembly/conf/logback.xml +++ b/sonar-application/src/main/assembly/conf/logback.xml @@ -103,7 +103,7 @@ - + diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchPluginRepository.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchPluginRepository.java index e8d698d2959..249c94b79b7 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchPluginRepository.java +++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchPluginRepository.java @@ -42,6 +42,7 @@ import java.util.*; public class BatchPluginRepository implements PluginRepository { private static final Logger LOG = LoggerFactory.getLogger(BatchPluginRepository.class); + private static final String CORE_PLUGIN = "core"; private ArtifactDownloader artifactDownloader; private Map pluginsByKey; @@ -52,12 +53,12 @@ public class BatchPluginRepository implements PluginRepository { public BatchPluginRepository(ArtifactDownloader artifactDownloader, Configuration configuration) { this.artifactDownloader = artifactDownloader; - if (configuration.getString(CoreProperties.INCLUDE_PLUGINS) != null) { - whiteList = Sets.newTreeSet(Arrays.asList(configuration.getStringArray(CoreProperties.INCLUDE_PLUGINS))); + if (configuration.getString(CoreProperties.BATCH_INCLUDE_PLUGINS) != null) { + whiteList = Sets.newTreeSet(Arrays.asList(configuration.getStringArray(CoreProperties.BATCH_INCLUDE_PLUGINS))); LOG.info("Include plugins: " + Joiner.on(", ").join(whiteList)); } - if (configuration.getString(CoreProperties.EXCLUDE_PLUGINS) != null) { - blackList = Sets.newTreeSet(Arrays.asList(configuration.getStringArray(CoreProperties.EXCLUDE_PLUGINS))); + if (configuration.getString(CoreProperties.BATCH_EXCLUDE_PLUGINS) != null) { + blackList = Sets.newTreeSet(Arrays.asList(configuration.getStringArray(CoreProperties.BATCH_EXCLUDE_PLUGINS))); LOG.info("Exclude plugins: " + Joiner.on(", ").join(blackList)); } // TODO reactivate somewhere else: LOG.info("Execution environment: {} {}", environment.getKey(), environment.getVersion()); @@ -124,6 +125,9 @@ public class BatchPluginRepository implements PluginRepository { } boolean isAccepted(String pluginKey) { + if (CORE_PLUGIN.equals(pluginKey)) { + return true; + } if (whiteList != null) { return whiteList.contains(pluginKey); } diff --git a/sonar-batch/src/test/java/org/sonar/batch/bootstrap/BatchPluginRepositoryTest.java b/sonar-batch/src/test/java/org/sonar/batch/bootstrap/BatchPluginRepositoryTest.java index 82bbf91ed33..00b291a2279 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/bootstrap/BatchPluginRepositoryTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/bootstrap/BatchPluginRepositoryTest.java @@ -118,7 +118,7 @@ public class BatchPluginRepositoryTest { when(downloader.downloadPlugin(checkstyleExt)).thenReturn(copyFiles("sonar-checkstyle-extensions-plugin-0.1-SNAPSHOT.jar")); PropertiesConfiguration conf = new PropertiesConfiguration(); - conf.setProperty(CoreProperties.EXCLUDE_PLUGINS, "checkstyle"); + conf.setProperty(CoreProperties.BATCH_EXCLUDE_PLUGINS, "checkstyle"); repository = new BatchPluginRepository(downloader, conf); repository.doStart(Arrays.asList(checkstyle, checkstyleExt)); @@ -149,17 +149,33 @@ public class BatchPluginRepositoryTest { @Test public void whiteListShouldTakePrecedenceOverBlackList() { PropertiesConfiguration conf = new PropertiesConfiguration(); - conf.setProperty(CoreProperties.INCLUDE_PLUGINS, "checkstyle,pmd,findbugs"); - conf.setProperty(CoreProperties.EXCLUDE_PLUGINS, "cobertura,pmd"); + conf.setProperty(CoreProperties.BATCH_INCLUDE_PLUGINS, "checkstyle,pmd,findbugs"); + conf.setProperty(CoreProperties.BATCH_EXCLUDE_PLUGINS, "cobertura,pmd"); repository = new BatchPluginRepository(mock(ArtifactDownloader.class), conf); assertThat(repository.isAccepted("pmd"), Matchers.is(true)); } + @Test + public void corePluginShouldAlwaysBeInWhiteList() { + PropertiesConfiguration conf = new PropertiesConfiguration(); + conf.setProperty(CoreProperties.BATCH_INCLUDE_PLUGINS, "checkstyle,pmd,findbugs"); + repository = new BatchPluginRepository(mock(ArtifactDownloader.class), conf); + assertThat(repository.isAccepted("core"), Matchers.is(true)); + } + + @Test + public void corePluginShouldNeverBeInBlackList() { + PropertiesConfiguration conf = new PropertiesConfiguration(); + conf.setProperty(CoreProperties.BATCH_EXCLUDE_PLUGINS, "core,findbugs"); + repository = new BatchPluginRepository(mock(ArtifactDownloader.class), conf); + assertThat(repository.isAccepted("core"), Matchers.is(true)); + } + @Test public void shouldCheckWhitelist() { PropertiesConfiguration conf = new PropertiesConfiguration(); - conf.setProperty(CoreProperties.INCLUDE_PLUGINS, "checkstyle,pmd,findbugs"); + conf.setProperty(CoreProperties.BATCH_INCLUDE_PLUGINS, "checkstyle,pmd,findbugs"); repository = new BatchPluginRepository(mock(ArtifactDownloader.class), conf); assertThat(repository.isAccepted("checkstyle"), Matchers.is(true)); @@ -170,7 +186,7 @@ public class BatchPluginRepositoryTest { @Test public void shouldCheckBlackListIfNoWhiteList() { PropertiesConfiguration conf = new PropertiesConfiguration(); - conf.setProperty(CoreProperties.EXCLUDE_PLUGINS, "checkstyle,pmd,findbugs"); + conf.setProperty(CoreProperties.BATCH_EXCLUDE_PLUGINS, "checkstyle,pmd,findbugs"); repository = new BatchPluginRepository(mock(ArtifactDownloader.class), conf); assertThat(repository.isAccepted("checkstyle"), Matchers.is(false)); diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java b/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java index e19a5a3f13b..01c652308cb 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java @@ -103,8 +103,8 @@ public interface CoreProperties { String SERVER_STARTTIME = "sonar.core.startTime"; // format is yyyy-MM-dd'T'HH:mm:ssZ String SKIP_TENDENCIES_PROPERTY = "sonar.skipTendencies"; boolean SKIP_TENDENCIES_DEFAULT_VALUE = false; - String INCLUDE_PLUGINS = "sonar.includePlugins"; - String EXCLUDE_PLUGINS = "sonar.excludePlugins"; + String BATCH_INCLUDE_PLUGINS = "sonar.includePlugins"; + String BATCH_EXCLUDE_PLUGINS = "sonar.excludePlugins"; /* CPD */ String CPD_PLUGIN = "cpd"; diff --git a/sonar-server/pom.xml b/sonar-server/pom.xml index 7d1fe84dcdc..5205ad689de 100644 --- a/sonar-server/pom.xml +++ b/sonar-server/pom.xml @@ -454,12 +454,6 @@ ${project.version} provided - - org.codehaus.sonar.plugins - sonar-i18n-plugin - ${project.version} - provided - diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/i18n_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/i18n_controller.rb new file mode 100644 index 00000000000..30ba45178db --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/i18n_controller.rb @@ -0,0 +1,64 @@ +# +# Sonar, entreprise quality control tool. +# Copyright (C) 2008-2011 SonarSource +# mailto:contact AT sonarsource DOT com +# +# Sonar 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. +# +# Sonar 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 Sonar; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 +# + +require "json" + +class I18nController < Api::ApiController + + def index + render :text => "Use one of the following:
" + end + + # + # GET /i18n/unknown_keys + # + def unknown_keys + begin + output = "" + properties = i18n_manager.unknown_keys + + properties.keys.sort.each {|key| output += "#{key}=#{properties[key]}\n" } + + output = "# No unknown keys" if output.empty? + + respond_to do |format| + format.json { render :json => JSON(properties) } + format.xml { render :xml => xml_not_supported } + format.text { render :text => output } + end + + rescue ApiException => e + render_error(e.msg, e.code) + + rescue Exception => e + logger.error("Fails to execute #{request.url} : #{e.message}") + render_error(e.message) + end + end + + private + + def i18n_manager + java_facade.getComponentByClassname('i18n', 'org.sonar.plugins.core.i18n.I18nManager') + end + +end \ No newline at end of file -- 2.39.5