aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2015-07-29 08:35:12 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2015-07-29 08:35:12 +0200
commitf8aa003429adae63fc479a34afcff4149459ddd2 (patch)
tree0d0655499887dec5a3e982c8a5604976050f7497 /sonar-batch
parent0f15f1633e5dfa9b24a61a524f963fc0f68d08c7 (diff)
downloadsonarqube-f8aa003429adae63fc479a34afcff4149459ddd2.tar.gz
sonarqube-f8aa003429adae63fc479a34afcff4149459ddd2.zip
Revert "SONAR-6746 Drop Plugin interface + batch cleanup"
This reverts commit 70c24eb376e514098f228bef76194536995c4957.
Diffstat (limited to 'sonar-batch')
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/ProfileLoader.java38
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchPluginInstaller.java9
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchPluginRepository.java15
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/bootstrap/ExtensionInstaller.java6
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/bootstrap/GlobalContainer.java13
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/bootstrap/PluginInstaller.java7
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/compute/package-info.java24
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/debt/package-info.java23
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/deprecated/ResourceFilters.java49
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/index/Data.java28
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/index/ResourceNotPersistedException.java34
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/index/StringData.java40
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/mediumtest/FakePluginInstaller.java13
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/ModuleScanContainer.java2
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/bootstrap/BatchPluginRepositoryTest.java6
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/bootstrap/ExtensionInstallerTest.java8
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/deprecated/ResourceFiltersTest.java47
17 files changed, 332 insertions, 30 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/ProfileLoader.java b/sonar-batch/src/main/java/org/sonar/batch/ProfileLoader.java
new file mode 100644
index 00000000000..bc00a1c1a31
--- /dev/null
+++ b/sonar-batch/src/main/java/org/sonar/batch/ProfileLoader.java
@@ -0,0 +1,38 @@
+/*
+ * 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.batch;
+
+import org.sonar.api.config.Settings;
+import org.sonar.api.profiles.RulesProfile;
+
+/**
+ * This interface is implemented by the views plugin!!
+ *
+ * @deprecated in 4.2
+ */
+@Deprecated
+public interface ProfileLoader {
+
+ /**
+ * Loads quality profile for specified project.
+ */
+ RulesProfile load(Settings settings);
+
+}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchPluginInstaller.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchPluginInstaller.java
index 8bc7ba788eb..b6744b5ff4a 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchPluginInstaller.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchPluginInstaller.java
@@ -19,18 +19,21 @@
*/
package org.sonar.batch.bootstrap;
+import com.google.common.io.Files;
+
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.Lists;
-import com.google.common.io.Files;
+
import java.io.File;
import java.io.IOException;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+
import org.apache.commons.lang.CharUtils;
import org.apache.commons.lang.StringUtils;
-import org.sonar.api.SonarPlugin;
+import org.sonar.api.Plugin;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
import org.sonar.api.utils.log.Profiler;
@@ -79,7 +82,7 @@ public class BatchPluginInstaller implements PluginInstaller {
* @see org.sonar.batch.mediumtest.BatchMediumTester
*/
@Override
- public Map<String, SonarPlugin> installLocals() {
+ public Map<String, Plugin> installLocals() {
return Collections.emptyMap();
}
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 bba8bea0ab2..bf1d7d12519 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
@@ -21,14 +21,15 @@ package org.sonar.batch.bootstrap;
import com.google.common.base.Preconditions;
import com.google.common.collect.Maps;
-import java.util.Collection;
-import java.util.Map;
import org.picocontainer.Startable;
-import org.sonar.api.SonarPlugin;
+import org.sonar.api.Plugin;
import org.sonar.core.platform.PluginInfo;
import org.sonar.core.platform.PluginLoader;
import org.sonar.core.platform.PluginRepository;
+import java.util.Collection;
+import java.util.Map;
+
/**
* Orchestrates the installation and loading of plugins
*/
@@ -37,7 +38,7 @@ public class BatchPluginRepository implements PluginRepository, Startable {
private final PluginInstaller installer;
private final PluginLoader loader;
- private Map<String, SonarPlugin> pluginInstancesByKeys;
+ private Map<String, Plugin> pluginInstancesByKeys;
private Map<String, PluginInfo> infosByKeys;
public BatchPluginRepository(PluginInstaller installer, PluginLoader loader) {
@@ -51,7 +52,7 @@ public class BatchPluginRepository implements PluginRepository, Startable {
pluginInstancesByKeys = Maps.newHashMap(loader.load(infosByKeys));
// this part is only used by tests
- for (Map.Entry<String, SonarPlugin> entry : installer.installLocals().entrySet()) {
+ for (Map.Entry<String, Plugin> entry : installer.installLocals().entrySet()) {
String pluginKey = entry.getKey();
infosByKeys.put(pluginKey, new PluginInfo(pluginKey));
pluginInstancesByKeys.put(pluginKey, entry.getValue());
@@ -80,8 +81,8 @@ public class BatchPluginRepository implements PluginRepository, Startable {
}
@Override
- public SonarPlugin getPluginInstance(String key) {
- SonarPlugin instance = pluginInstancesByKeys.get(key);
+ public Plugin getPluginInstance(String key) {
+ Plugin instance = pluginInstancesByKeys.get(key);
Preconditions.checkState(instance != null, String.format("Plugin [%s] does not exist", key));
return instance;
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ExtensionInstaller.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ExtensionInstaller.java
index d0860693004..aa4f22e4e1e 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ExtensionInstaller.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ExtensionInstaller.java
@@ -20,9 +20,11 @@
package org.sonar.batch.bootstrap;
import java.util.List;
+
import javax.annotation.Nullable;
+
import org.sonar.api.ExtensionProvider;
-import org.sonar.api.SonarPlugin;
+import org.sonar.api.Plugin;
import org.sonar.batch.bootstrapper.EnvironmentInformation;
import org.sonar.core.platform.ComponentContainer;
import org.sonar.core.platform.PluginInfo;
@@ -49,7 +51,7 @@ public class ExtensionInstaller {
// plugin extensions
for (PluginInfo pluginInfo : pluginRepository.getPluginInfos()) {
- SonarPlugin plugin = pluginRepository.getPluginInstance(pluginInfo.getKey());
+ Plugin plugin = pluginRepository.getPluginInstance(pluginInfo.getKey());
for (Object extension : plugin.getExtensions()) {
doInstall(container, matcher, pluginInfo, extension);
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/GlobalContainer.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/GlobalContainer.java
index db806c103c9..882aa173e48 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/GlobalContainer.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/GlobalContainer.java
@@ -26,8 +26,10 @@ import org.sonar.batch.rule.RulesProvider;
import java.util.List;
import java.util.Map;
+
import org.sonar.api.CoreProperties;
-import org.sonar.api.SonarPlugin;
+import org.sonar.api.Plugin;
+import org.sonar.api.utils.Durations;
import org.sonar.api.utils.System2;
import org.sonar.api.utils.UriReader;
import org.sonar.batch.index.CachesManager;
@@ -44,6 +46,8 @@ import org.sonar.batch.repository.ServerIssuesLoader;
import org.sonar.batch.repository.user.UserRepository;
import org.sonar.batch.scan.ProjectScanContainer;
import org.sonar.core.config.Logback;
+import org.sonar.core.i18n.DefaultI18n;
+import org.sonar.core.i18n.RuleI18nManager;
import org.sonar.core.platform.ComponentContainer;
import org.sonar.core.platform.PluginClassloaderFactory;
import org.sonar.core.platform.PluginInfo;
@@ -83,7 +87,7 @@ public class GlobalContainer extends ComponentContainer {
BatchPluginPredicate.class,
ExtensionInstaller.class,
- CachesManager.class,
+ CachesManager.class,
GlobalMode.class,
GlobalSettings.class,
new RulesProvider(),
@@ -97,6 +101,9 @@ public class GlobalContainer extends ComponentContainer {
new PersistentCacheProvider(),
new WSLoaderGlobalProvider(),
System2.INSTANCE,
+ DefaultI18n.class,
+ Durations.class,
+ RuleI18nManager.class,
new GlobalRepositoriesProvider(),
UserRepository.class);
addIfMissing(BatchPluginInstaller.class, PluginInstaller.class);
@@ -121,7 +128,7 @@ public class GlobalContainer extends ComponentContainer {
private void installPlugins() {
PluginRepository pluginRepository = getComponentByType(PluginRepository.class);
for (PluginInfo pluginInfo : pluginRepository.getPluginInfos()) {
- SonarPlugin instance = pluginRepository.getPluginInstance(pluginInfo.getKey());
+ Plugin instance = pluginRepository.getPluginInstance(pluginInfo.getKey());
addExtension(pluginInfo, instance);
}
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/PluginInstaller.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/PluginInstaller.java
index dac66e617f0..e1213cfbe13 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/PluginInstaller.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/PluginInstaller.java
@@ -19,11 +19,12 @@
*/
package org.sonar.batch.bootstrap;
-import java.util.Map;
-import org.sonar.api.SonarPlugin;
import org.sonar.api.batch.BatchSide;
+import org.sonar.api.Plugin;
import org.sonar.core.platform.PluginInfo;
+import java.util.Map;
+
@BatchSide
public interface PluginInstaller {
@@ -38,5 +39,5 @@ public interface PluginInstaller {
* Used only by tests.
* @see org.sonar.batch.mediumtest.BatchMediumTester
*/
- Map<String, SonarPlugin> installLocals();
+ Map<String, Plugin> installLocals();
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/compute/package-info.java b/sonar-batch/src/main/java/org/sonar/batch/compute/package-info.java
new file mode 100644
index 00000000000..7fd21f3ba7c
--- /dev/null
+++ b/sonar-batch/src/main/java/org/sonar/batch/compute/package-info.java
@@ -0,0 +1,24 @@
+/*
+ * 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.batch.compute;
+
+import javax.annotation.ParametersAreNonnullByDefault;
+
diff --git a/sonar-batch/src/main/java/org/sonar/batch/debt/package-info.java b/sonar-batch/src/main/java/org/sonar/batch/debt/package-info.java
new file mode 100644
index 00000000000..98d74a000ac
--- /dev/null
+++ b/sonar-batch/src/main/java/org/sonar/batch/debt/package-info.java
@@ -0,0 +1,23 @@
+/*
+ * 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.batch.debt;
+
+import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/sonar-batch/src/main/java/org/sonar/batch/deprecated/ResourceFilters.java b/sonar-batch/src/main/java/org/sonar/batch/deprecated/ResourceFilters.java
new file mode 100644
index 00000000000..f60713506d7
--- /dev/null
+++ b/sonar-batch/src/main/java/org/sonar/batch/deprecated/ResourceFilters.java
@@ -0,0 +1,49 @@
+/*
+ * 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.batch.deprecated;
+
+import com.google.common.base.Joiner;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.sonar.api.batch.ResourceFilter;
+
+/**
+ * @since 1.12
+ */
+public class ResourceFilters {
+
+ public ResourceFilters(ResourceFilter[] filters) {
+ this(LoggerFactory.getLogger(ResourceFilters.class), filters);
+ }
+
+ public ResourceFilters() {
+ // perfect
+ }
+
+ ResourceFilters(Logger logger, ResourceFilter[] filters) {
+ check(logger, filters);
+ }
+
+ private void check(Logger logger, ResourceFilter[] filters) {
+ if (filters.length > 0) {
+ logger.warn("ResourceFilters are not supported since version 4.2: " + Joiner.on(", ").join(filters));
+ }
+ }
+}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/Data.java b/sonar-batch/src/main/java/org/sonar/batch/index/Data.java
new file mode 100644
index 00000000000..aa47c04e799
--- /dev/null
+++ b/sonar-batch/src/main/java/org/sonar/batch/index/Data.java
@@ -0,0 +1,28 @@
+/*
+ * 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.batch.index;
+
+import java.io.Serializable;
+
+public interface Data extends Serializable {
+
+ String writeString();
+
+}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/ResourceNotPersistedException.java b/sonar-batch/src/main/java/org/sonar/batch/index/ResourceNotPersistedException.java
new file mode 100644
index 00000000000..1cf29c6fd76
--- /dev/null
+++ b/sonar-batch/src/main/java/org/sonar/batch/index/ResourceNotPersistedException.java
@@ -0,0 +1,34 @@
+/*
+ * 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.batch.index;
+
+import org.sonar.api.resources.Resource;
+import org.sonar.api.utils.SonarException;
+
+/**
+ * @since 2.6
+ */
+public final class ResourceNotPersistedException extends SonarException {
+
+ public ResourceNotPersistedException(Resource resource) {
+ super(resource.toString());
+ }
+
+}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/StringData.java b/sonar-batch/src/main/java/org/sonar/batch/index/StringData.java
new file mode 100644
index 00000000000..6a88b5979b2
--- /dev/null
+++ b/sonar-batch/src/main/java/org/sonar/batch/index/StringData.java
@@ -0,0 +1,40 @@
+/*
+ * 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.batch.index;
+
+public class StringData implements Data {
+ private String data = null;
+
+ public StringData() {
+ }
+
+ public StringData(String s) {
+ this.data = s;
+ }
+
+ public String data() {
+ return data;
+ }
+
+ @Override
+ public String writeString() {
+ return data;
+ }
+}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/mediumtest/FakePluginInstaller.java b/sonar-batch/src/main/java/org/sonar/batch/mediumtest/FakePluginInstaller.java
index f7544d2956b..cbd837c66c9 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/mediumtest/FakePluginInstaller.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/mediumtest/FakePluginInstaller.java
@@ -19,24 +19,25 @@
*/
package org.sonar.batch.mediumtest;
+import org.sonar.api.Plugin;
+import org.sonar.batch.bootstrap.PluginInstaller;
+import org.sonar.core.platform.PluginInfo;
+
import java.io.File;
import java.util.HashMap;
import java.util.Map;
-import org.sonar.api.SonarPlugin;
-import org.sonar.batch.bootstrap.PluginInstaller;
-import org.sonar.core.platform.PluginInfo;
public class FakePluginInstaller implements PluginInstaller {
private final Map<String, PluginInfo> infosByKeys = new HashMap<>();
- private final Map<String, SonarPlugin> instancesByKeys = new HashMap<>();
+ private final Map<String, Plugin> instancesByKeys = new HashMap<>();
public FakePluginInstaller add(String pluginKey, File jarFile) {
infosByKeys.put(pluginKey, PluginInfo.create(jarFile));
return this;
}
- public FakePluginInstaller add(String pluginKey, SonarPlugin instance) {
+ public FakePluginInstaller add(String pluginKey, Plugin instance) {
instancesByKeys.put(pluginKey, instance);
return this;
}
@@ -47,7 +48,7 @@ public class FakePluginInstaller implements PluginInstaller {
}
@Override
- public Map<String, SonarPlugin> installLocals() {
+ public Map<String, Plugin> installLocals() {
return instancesByKeys;
}
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/ModuleScanContainer.java b/sonar-batch/src/main/java/org/sonar/batch/scan/ModuleScanContainer.java
index 039da7d57e0..1363134d449 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/ModuleScanContainer.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/ModuleScanContainer.java
@@ -35,6 +35,7 @@ import org.sonar.batch.bootstrap.ExtensionInstaller;
import org.sonar.batch.bootstrap.ExtensionMatcher;
import org.sonar.batch.bootstrap.ExtensionUtils;
import org.sonar.batch.deprecated.DeprecatedSensorContext;
+import org.sonar.batch.deprecated.ResourceFilters;
import org.sonar.batch.deprecated.perspectives.BatchPerspectives;
import org.sonar.batch.events.EventBus;
import org.sonar.batch.index.DefaultIndex;
@@ -146,6 +147,7 @@ public class ModuleScanContainer extends ComponentContainer {
BatchExtensionDictionnary.class,
IssueFilters.class,
CoverageExclusions.class,
+ ResourceFilters.class,
// rules
ModuleQProfiles.class,
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 5f260785615..2adf1b31452 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
@@ -21,7 +21,7 @@ package org.sonar.batch.bootstrap;
import com.google.common.collect.ImmutableMap;
import org.junit.Test;
-import org.sonar.api.SonarPlugin;
+import org.sonar.api.Plugin;
import org.sonar.core.platform.PluginInfo;
import org.sonar.core.platform.PluginLoader;
@@ -42,7 +42,7 @@ public class BatchPluginRepositoryTest {
public void install_and_load_plugins() {
PluginInfo info = new PluginInfo("squid");
ImmutableMap<String, PluginInfo> infos = ImmutableMap.of("squid", info);
- SonarPlugin instance = mock(SonarPlugin.class);
+ Plugin instance = mock(Plugin.class);
when(loader.load(infos)).thenReturn(ImmutableMap.of("squid", instance));
when(installer.installRemotes()).thenReturn(infos);
@@ -53,7 +53,7 @@ public class BatchPluginRepositoryTest {
assertThat(underTest.getPluginInstance("squid")).isSameAs(instance);
underTest.stop();
- verify(loader).unload(anyCollectionOf(SonarPlugin.class));
+ verify(loader).unload(anyCollectionOf(Plugin.class));
}
@Test
diff --git a/sonar-batch/src/test/java/org/sonar/batch/bootstrap/ExtensionInstallerTest.java b/sonar-batch/src/test/java/org/sonar/batch/bootstrap/ExtensionInstallerTest.java
index 68fd361319e..aef314012ca 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/bootstrap/ExtensionInstallerTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/bootstrap/ExtensionInstallerTest.java
@@ -19,19 +19,21 @@
*/
package org.sonar.batch.bootstrap;
-import java.util.Arrays;
-import java.util.List;
import org.apache.commons.lang.ClassUtils;
import org.junit.Before;
import org.junit.Test;
import org.sonar.api.BatchExtension;
import org.sonar.api.ExtensionProvider;
+import org.sonar.api.Plugin;
import org.sonar.api.SonarPlugin;
import org.sonar.api.batch.SupportedEnvironment;
import org.sonar.batch.bootstrapper.EnvironmentInformation;
import org.sonar.core.platform.ComponentContainer;
import org.sonar.core.platform.PluginInfo;
+import java.util.Arrays;
+import java.util.List;
+
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -41,7 +43,7 @@ public class ExtensionInstallerTest {
GlobalMode mode;
BatchPluginRepository pluginRepository = mock(BatchPluginRepository.class);
- private static SonarPlugin newPluginInstance(final Object... extensions) {
+ private static Plugin newPluginInstance(final Object... extensions) {
return new SonarPlugin() {
public List getExtensions() {
return Arrays.asList(extensions);
diff --git a/sonar-batch/src/test/java/org/sonar/batch/deprecated/ResourceFiltersTest.java b/sonar-batch/src/test/java/org/sonar/batch/deprecated/ResourceFiltersTest.java
new file mode 100644
index 00000000000..0a4ad891ce7
--- /dev/null
+++ b/sonar-batch/src/test/java/org/sonar/batch/deprecated/ResourceFiltersTest.java
@@ -0,0 +1,47 @@
+/*
+ * 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.batch.deprecated;
+
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.sonar.api.batch.ResourceFilter;
+
+import static org.mockito.Matchers.startsWith;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+
+public class ResourceFiltersTest {
+ @Test
+ public void warn_on_resource_filters() {
+ Logger logger = mock(Logger.class);
+ ResourceFilter[] filters = {mock(ResourceFilter.class)};
+ new ResourceFilters(logger, filters);
+ verify(logger).warn(startsWith("ResourceFilters are not supported since version 4.2"));
+
+ // verify that the standard constructor does not fail
+ new ResourceFilters(filters);
+ }
+
+ @Test
+ public void ok_if_no_resource_filters() {
+ // just for verify that it does not fail. Should check that no warning is logged.
+ new ResourceFilters();
+ }
+}