]> source.dussan.org Git - sonarqube.git/commitdiff
Refactor plugin management for better maintainability
authorSimon Brandhof <simon.brandhof@gmail.com>
Sun, 16 Mar 2014 13:06:00 +0000 (14:06 +0100)
committerSimon Brandhof <simon.brandhof@gmail.com>
Sun, 16 Mar 2014 13:06:00 +0000 (14:06 +0100)
66 files changed:
sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchPluginInstaller.java [deleted file]
sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchPluginJarInstaller.java [new file with mode: 0644]
sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchPluginRepository.java
sonar-batch/src/main/java/org/sonar/batch/bootstrap/BootstrapContainer.java
sonar-batch/src/test/java/org/sonar/batch/bootstrap/BatchPluginInstallerTest.java [deleted file]
sonar-batch/src/test/java/org/sonar/batch/bootstrap/BatchPluginJarInstallerTest.java [new file with mode: 0644]
sonar-batch/src/test/java/org/sonar/batch/bootstrap/BatchPluginRepositoryTest.java
sonar-batch/src/test/resources/org/sonar/batch/bootstrap/BatchPluginInstallerTest/sonar-checkstyle-plugin-2.8.jar [deleted file]
sonar-batch/src/test/resources/org/sonar/batch/bootstrap/BatchPluginJarInstallerTest/sonar-checkstyle-plugin-2.8.jar [new file with mode: 0644]
sonar-core/src/main/java/org/sonar/core/plugins/PluginInstaller.java [deleted file]
sonar-core/src/main/java/org/sonar/core/plugins/PluginJarInstaller.java [new file with mode: 0644]
sonar-core/src/main/java/org/sonar/core/profiling/Profiling.java
sonar-core/src/test/java/org/sonar/core/plugins/PluginInstallerTest.java [deleted file]
sonar-core/src/test/java/org/sonar/core/plugins/PluginJarInstallerTest.java [new file with mode: 0644]
sonar-plugin-api/src/main/java/org/sonar/api/platform/PluginRepository.java
sonar-server/src/main/java/org/sonar/server/db/EmbeddedDatabaseFactory.java
sonar-server/src/main/java/org/sonar/server/platform/DatabaseServerCompatibility.java
sonar-server/src/main/java/org/sonar/server/platform/DefaultServerFileSystem.java
sonar-server/src/main/java/org/sonar/server/platform/DefaultServerUpgradeStatus.java
sonar-server/src/main/java/org/sonar/server/platform/PersistentSettings.java
sonar-server/src/main/java/org/sonar/server/platform/Platform.java
sonar-server/src/main/java/org/sonar/server/platform/RailsAppsDeployer.java
sonar-server/src/main/java/org/sonar/server/platform/ServerComponentsStarter.java
sonar-server/src/main/java/org/sonar/server/platform/ServerImpl.java
sonar-server/src/main/java/org/sonar/server/platform/ServerLifecycleNotifier.java
sonar-server/src/main/java/org/sonar/server/platform/SettingsChangeNotifier.java
sonar-server/src/main/java/org/sonar/server/plugins/DefaultServerPluginRepository.java [deleted file]
sonar-server/src/main/java/org/sonar/server/plugins/InstalledPluginReferentialFactory.java
sonar-server/src/main/java/org/sonar/server/plugins/PluginDeployer.java [deleted file]
sonar-server/src/main/java/org/sonar/server/plugins/PluginDownloader.java
sonar-server/src/main/java/org/sonar/server/plugins/ServerExtensionInstaller.java
sonar-server/src/main/java/org/sonar/server/plugins/ServerPluginInstaller.java [deleted file]
sonar-server/src/main/java/org/sonar/server/plugins/ServerPluginJarInstaller.java [new file with mode: 0644]
sonar-server/src/main/java/org/sonar/server/plugins/ServerPluginJarsInstaller.java [new file with mode: 0644]
sonar-server/src/main/java/org/sonar/server/plugins/ServerPluginRepository.java [new file with mode: 0644]
sonar-server/src/main/java/org/sonar/server/plugins/StaticResourcesServlet.java
sonar-server/src/main/java/org/sonar/server/plugins/UpdateCenterClient.java
sonar-server/src/main/java/org/sonar/server/plugins/UpdateCenterMatrixFactory.java
sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java
sonar-server/src/test/java/org/sonar/server/plugins/DefaultServerPluginRepositoryTest.java [deleted file]
sonar-server/src/test/java/org/sonar/server/plugins/PluginDeployerTest.java [deleted file]
sonar-server/src/test/java/org/sonar/server/plugins/ServerExtensionInstallerTest.java [deleted file]
sonar-server/src/test/java/org/sonar/server/plugins/ServerPluginJarsInstallerTest.java [new file with mode: 0644]
sonar-server/src/test/java/org/sonar/server/plugins/ServerPluginRepositoryTest.java [new file with mode: 0644]
sonar-server/src/test/resources/org/sonar/server/plugins/DefaultServerPluginRepositoryTest/sonar-artifact-size-plugin-0.2.jar [deleted file]
sonar-server/src/test/resources/org/sonar/server/plugins/PluginDeployerTest/deployBundledPluginsOnFreshInstall/extensions/plugins/foo-plugin.jar [deleted file]
sonar-server/src/test/resources/org/sonar/server/plugins/PluginDeployerTest/deployBundledPluginsOnFreshInstall/lib/bundled-plugins/bar-plugin.jar [deleted file]
sonar-server/src/test/resources/org/sonar/server/plugins/PluginDeployerTest/deployPlugin/extensions/plugins/foo-plugin.jar [deleted file]
sonar-server/src/test/resources/org/sonar/server/plugins/PluginDeployerTest/deployPlugin/lib/bundled-plugins/bar-plugin.jar [deleted file]
sonar-server/src/test/resources/org/sonar/server/plugins/PluginDeployerTest/deployPluginExtensions/extensions/plugins/foo-plugin.jar [deleted file]
sonar-server/src/test/resources/org/sonar/server/plugins/PluginDeployerTest/deployPluginExtensions/extensions/rules/foo/foo-extension.txt [deleted file]
sonar-server/src/test/resources/org/sonar/server/plugins/PluginDeployerTest/failIfTwoPluginsWithSameKey/extensions/plugins/foo-plugin1.jar [deleted file]
sonar-server/src/test/resources/org/sonar/server/plugins/PluginDeployerTest/failIfTwoPluginsWithSameKey/extensions/plugins/foo-plugin2.jar [deleted file]
sonar-server/src/test/resources/org/sonar/server/plugins/PluginDeployerTest/ignoreJarsWhichAreNotPlugins/extensions/plugins/not-a-plugin.jar [deleted file]
sonar-server/src/test/resources/org/sonar/server/plugins/PluginDeployerTest/should_fail_on_plugin_depending_on_more_recent_sonar/extensions/plugins/sonar-switch-off-violations-plugin-1.1.jar [deleted file]
sonar-server/src/test/resources/org/sonar/server/plugins/ServerPluginJarsInstallerTest/deployBundledPluginsOnFreshInstall/extensions/plugins/foo-plugin.jar [new file with mode: 0644]
sonar-server/src/test/resources/org/sonar/server/plugins/ServerPluginJarsInstallerTest/deployBundledPluginsOnFreshInstall/lib/bundled-plugins/bar-plugin.jar [new file with mode: 0644]
sonar-server/src/test/resources/org/sonar/server/plugins/ServerPluginJarsInstallerTest/deployPlugin/extensions/plugins/foo-plugin.jar [new file with mode: 0644]
sonar-server/src/test/resources/org/sonar/server/plugins/ServerPluginJarsInstallerTest/deployPlugin/lib/bundled-plugins/bar-plugin.jar [new file with mode: 0644]
sonar-server/src/test/resources/org/sonar/server/plugins/ServerPluginJarsInstallerTest/deployPluginExtensions/extensions/plugins/foo-plugin.jar [new file with mode: 0644]
sonar-server/src/test/resources/org/sonar/server/plugins/ServerPluginJarsInstallerTest/deployPluginExtensions/extensions/rules/foo/foo-extension.txt [new file with mode: 0644]
sonar-server/src/test/resources/org/sonar/server/plugins/ServerPluginJarsInstallerTest/failIfTwoPluginsWithSameKey/extensions/plugins/foo-plugin1.jar [new file with mode: 0644]
sonar-server/src/test/resources/org/sonar/server/plugins/ServerPluginJarsInstallerTest/failIfTwoPluginsWithSameKey/extensions/plugins/foo-plugin2.jar [new file with mode: 0644]
sonar-server/src/test/resources/org/sonar/server/plugins/ServerPluginJarsInstallerTest/ignoreJarsWhichAreNotPlugins/extensions/plugins/not-a-plugin.jar [new file with mode: 0644]
sonar-server/src/test/resources/org/sonar/server/plugins/ServerPluginJarsInstallerTest/should_fail_on_plugin_depending_on_more_recent_sonar/extensions/plugins/sonar-switch-off-violations-plugin-1.1.jar [new file with mode: 0644]
sonar-server/src/test/resources/org/sonar/server/plugins/ServerPluginRepositoryTest/sonar-artifact-size-plugin-0.2.jar [new file with mode: 0644]

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
deleted file mode 100644 (file)
index 7f23a2e..0000000
+++ /dev/null
@@ -1,49 +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.batch.bootstrap;
-
-import org.sonar.api.BatchComponent;
-import org.sonar.core.plugins.DefaultPluginMetadata;
-import org.sonar.core.plugins.PluginInstaller;
-import org.sonar.home.cache.FileCache;
-
-import java.io.File;
-import java.io.IOException;
-
-public class BatchPluginInstaller extends PluginInstaller implements BatchComponent {
-
-  private FileCache cache;
-
-  public BatchPluginInstaller(FileCache cache) {
-    this.cache = cache;
-  }
-
-  public DefaultPluginMetadata installToCache(File pluginFile, boolean isCore) {
-    DefaultPluginMetadata metadata = extractMetadata(pluginFile, isCore);
-    install(metadata, null, pluginFile);
-    return metadata;
-  }
-
-  @Override
-  protected File extractPluginDependencies(File pluginFile, File pluginBasedir) throws IOException {
-    return cache.unzip(pluginFile);
-  }
-
-}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchPluginJarInstaller.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchPluginJarInstaller.java
new file mode 100644 (file)
index 0000000..8866cf7
--- /dev/null
@@ -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.bootstrap;
+
+import org.sonar.api.BatchComponent;
+import org.sonar.core.plugins.DefaultPluginMetadata;
+import org.sonar.core.plugins.PluginJarInstaller;
+import org.sonar.home.cache.FileCache;
+
+import java.io.File;
+import java.io.IOException;
+
+public class BatchPluginJarInstaller extends PluginJarInstaller implements BatchComponent {
+
+  private FileCache cache;
+
+  public BatchPluginJarInstaller(FileCache cache) {
+    this.cache = cache;
+  }
+
+  public DefaultPluginMetadata installToCache(File pluginFile, boolean isCore) {
+    DefaultPluginMetadata metadata = extractMetadata(pluginFile, isCore);
+    install(metadata, null, pluginFile);
+    return metadata;
+  }
+
+  @Override
+  protected File extractPluginDependencies(File pluginFile, File pluginBasedir) throws IOException {
+    return cache.unzip(pluginFile);
+  }
+
+}
index 8a93f2589169ceecf6fc42c6ed83a64f23cb4790..e0e366282a17f24f8f235bd2260561927452614d 100644 (file)
@@ -51,10 +51,10 @@ public class BatchPluginRepository implements PluginRepository {
   private Settings settings;
   private PluginClassloaders classLoaders;
   private final AnalysisMode analysisMode;
-  private final BatchPluginInstaller pluginInstaller;
+  private final BatchPluginJarInstaller pluginInstaller;
 
   public BatchPluginRepository(PluginDownloader pluginDownloader, Settings settings, AnalysisMode analysisMode,
-                               BatchPluginInstaller pluginInstaller) {
+                               BatchPluginJarInstaller pluginInstaller) {
     this.pluginDownloader = pluginDownloader;
     this.settings = settings;
     this.analysisMode = analysisMode;
index 40f027d3cd9bcc949c22325f945183987228863c..c6bd4a1f93e055be77aedaebed3291dc061df4e9 100644 (file)
@@ -72,7 +72,7 @@ public class BootstrapContainer extends ComponentContainer {
       AnalysisMode.class,
       PluginDownloader.class,
       BatchPluginRepository.class,
-      BatchPluginInstaller.class,
+      BatchPluginJarInstaller.class,
       BatchSettings.class,
       ServerClient.class,
       ExtensionInstaller.class,
diff --git a/sonar-batch/src/test/java/org/sonar/batch/bootstrap/BatchPluginInstallerTest.java b/sonar-batch/src/test/java/org/sonar/batch/bootstrap/BatchPluginInstallerTest.java
deleted file mode 100644 (file)
index de90342..0000000
+++ /dev/null
@@ -1,77 +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.batch.bootstrap;
-
-import org.apache.commons.io.FileUtils;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
-import org.sonar.core.plugins.DefaultPluginMetadata;
-import org.sonar.home.cache.FileCacheBuilder;
-
-import java.io.File;
-import java.io.IOException;
-
-import static org.fest.assertions.Assertions.assertThat;
-
-public class BatchPluginInstallerTest {
-
-  private BatchPluginInstaller extractor;
-
-  @ClassRule
-  public static TemporaryFolder temporaryFolder = new TemporaryFolder();
-
-  private File userHome;
-
-  @Before
-  public void setUp() throws IOException {
-    userHome = temporaryFolder.newFolder();
-    extractor = new BatchPluginInstaller(new FileCacheBuilder().setUserHome(userHome).build());
-  }
-
-  @Test
-  public void should_copy_and_extract_dependencies() throws IOException {
-    File fileFromCache = getFileFromCache("sonar-checkstyle-plugin-2.8.jar");
-    DefaultPluginMetadata metadata = extractor.installToCache(fileFromCache, true);
-
-    assertThat(metadata.getKey()).isEqualTo("checkstyle");
-    assertThat(new File(fileFromCache.getParent(), "sonar-checkstyle-plugin-2.8.jar")).exists();
-    assertThat(new File(fileFromCache.getParent(), "sonar-checkstyle-plugin-2.8.jar_unzip/META-INF/lib/checkstyle-5.1.jar")).exists();
-  }
-
-  @Test
-  public void should_extract_only_dependencies() throws IOException {
-    File fileFromCache = getFileFromCache("sonar-checkstyle-plugin-2.8.jar");
-    extractor.installToCache(fileFromCache, true);
-
-    assertThat(new File(fileFromCache.getParent(), "sonar-checkstyle-plugin-2.8.jar")).exists();
-    assertThat(new File(fileFromCache.getParent(), "sonar-checkstyle-plugin-2.8.jar_unzip/META-INF/MANIFEST.MF")).doesNotExist();
-    assertThat(new File(fileFromCache.getParent(), "sonar-checkstyle-plugin-2.8.jar_unzip/org/sonar/plugins/checkstyle/CheckstyleVersion.class")).doesNotExist();
-  }
-
-  File getFileFromCache(String filename) throws IOException {
-    File src = FileUtils.toFile(BatchPluginInstallerTest.class.getResource("/org/sonar/batch/bootstrap/BatchPluginInstallerTest/" + filename));
-    File destFile = new File(new File(userHome, "" + filename.hashCode()), filename);
-    FileUtils.copyFile(src, destFile);
-    return destFile;
-  }
-
-}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/bootstrap/BatchPluginJarInstallerTest.java b/sonar-batch/src/test/java/org/sonar/batch/bootstrap/BatchPluginJarInstallerTest.java
new file mode 100644 (file)
index 0000000..52b80a8
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * 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.bootstrap;
+
+import org.apache.commons.io.FileUtils;
+import org.junit.Before;
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
+import org.sonar.core.plugins.DefaultPluginMetadata;
+import org.sonar.home.cache.FileCacheBuilder;
+
+import java.io.File;
+import java.io.IOException;
+
+import static org.fest.assertions.Assertions.assertThat;
+
+public class BatchPluginJarInstallerTest {
+
+  private BatchPluginJarInstaller extractor;
+
+  @ClassRule
+  public static TemporaryFolder temporaryFolder = new TemporaryFolder();
+
+  private File userHome;
+
+  @Before
+  public void setUp() throws IOException {
+    userHome = temporaryFolder.newFolder();
+    extractor = new BatchPluginJarInstaller(new FileCacheBuilder().setUserHome(userHome).build());
+  }
+
+  @Test
+  public void should_copy_and_extract_dependencies() throws IOException {
+    File fileFromCache = getFileFromCache("sonar-checkstyle-plugin-2.8.jar");
+    DefaultPluginMetadata metadata = extractor.installToCache(fileFromCache, true);
+
+    assertThat(metadata.getKey()).isEqualTo("checkstyle");
+    assertThat(new File(fileFromCache.getParent(), "sonar-checkstyle-plugin-2.8.jar")).exists();
+    assertThat(new File(fileFromCache.getParent(), "sonar-checkstyle-plugin-2.8.jar_unzip/META-INF/lib/checkstyle-5.1.jar")).exists();
+  }
+
+  @Test
+  public void should_extract_only_dependencies() throws IOException {
+    File fileFromCache = getFileFromCache("sonar-checkstyle-plugin-2.8.jar");
+    extractor.installToCache(fileFromCache, true);
+
+    assertThat(new File(fileFromCache.getParent(), "sonar-checkstyle-plugin-2.8.jar")).exists();
+    assertThat(new File(fileFromCache.getParent(), "sonar-checkstyle-plugin-2.8.jar_unzip/META-INF/MANIFEST.MF")).doesNotExist();
+    assertThat(new File(fileFromCache.getParent(), "sonar-checkstyle-plugin-2.8.jar_unzip/org/sonar/plugins/checkstyle/CheckstyleVersion.class")).doesNotExist();
+  }
+
+  File getFileFromCache(String filename) throws IOException {
+    File src = FileUtils.toFile(BatchPluginJarInstallerTest.class.getResource("/org/sonar/batch/bootstrap/BatchPluginJarInstallerTest/" + filename));
+    File destFile = new File(new File(userHome, "" + filename.hashCode()), filename);
+    FileUtils.copyFile(src, destFile);
+    return destFile;
+  }
+
+}
index 84f92b7eab6881875f15122d822c968e8a83b1f8..41a6d0048d5fe66b506e063fa9e348bfa8108aae 100644 (file)
@@ -71,7 +71,7 @@ public class BatchPluginRepositoryTest {
     PluginDownloader downloader = mock(PluginDownloader.class);
     when(downloader.downloadPlugin(checkstyle)).thenReturn(fileFromCache("sonar-checkstyle-plugin-2.8.jar"));
 
-    repository = new BatchPluginRepository(downloader, new Settings(), mode, new BatchPluginInstaller(cache));
+    repository = new BatchPluginRepository(downloader, new Settings(), mode, new BatchPluginJarInstaller(cache));
 
     repository.doStart(Arrays.asList(checkstyle));
 
@@ -90,7 +90,7 @@ public class BatchPluginRepositoryTest {
     when(downloader.downloadPlugin(checkstyle)).thenReturn(fileFromCache("sonar-checkstyle-plugin-2.8.jar"));
     when(downloader.downloadPlugin(checkstyleExt)).thenReturn(fileFromCache("sonar-checkstyle-extensions-plugin-0.1-SNAPSHOT.jar"));
 
-    repository = new BatchPluginRepository(downloader, new Settings(), mode, new BatchPluginInstaller(cache));
+    repository = new BatchPluginRepository(downloader, new Settings(), mode, new BatchPluginJarInstaller(cache));
 
     repository.doStart(Arrays.asList(checkstyle, checkstyleExt));
 
@@ -112,7 +112,7 @@ public class BatchPluginRepositoryTest {
 
     Settings settings = new Settings();
     settings.setProperty(CoreProperties.BATCH_EXCLUDE_PLUGINS, "checkstyle");
-    repository = new BatchPluginRepository(downloader, settings, mode, new BatchPluginInstaller(cache));
+    repository = new BatchPluginRepository(downloader, settings, mode, new BatchPluginJarInstaller(cache));
 
     repository.doStart(Arrays.asList(checkstyle, checkstyleExt));
 
diff --git a/sonar-batch/src/test/resources/org/sonar/batch/bootstrap/BatchPluginInstallerTest/sonar-checkstyle-plugin-2.8.jar b/sonar-batch/src/test/resources/org/sonar/batch/bootstrap/BatchPluginInstallerTest/sonar-checkstyle-plugin-2.8.jar
deleted file mode 100644 (file)
index f937399..0000000
Binary files a/sonar-batch/src/test/resources/org/sonar/batch/bootstrap/BatchPluginInstallerTest/sonar-checkstyle-plugin-2.8.jar and /dev/null differ
diff --git a/sonar-batch/src/test/resources/org/sonar/batch/bootstrap/BatchPluginJarInstallerTest/sonar-checkstyle-plugin-2.8.jar b/sonar-batch/src/test/resources/org/sonar/batch/bootstrap/BatchPluginJarInstallerTest/sonar-checkstyle-plugin-2.8.jar
new file mode 100644 (file)
index 0000000..f937399
Binary files /dev/null and b/sonar-batch/src/test/resources/org/sonar/batch/bootstrap/BatchPluginJarInstallerTest/sonar-checkstyle-plugin-2.8.jar differ
diff --git a/sonar-core/src/main/java/org/sonar/core/plugins/PluginInstaller.java b/sonar-core/src/main/java/org/sonar/core/plugins/PluginInstaller.java
deleted file mode 100644 (file)
index 7433310..0000000
+++ /dev/null
@@ -1,90 +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.core.plugins;
-
-import org.sonar.api.BatchComponent;
-import org.sonar.api.ServerComponent;
-import org.sonar.api.utils.SonarException;
-import org.sonar.updatecenter.common.PluginManifest;
-
-import javax.annotation.Nullable;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Arrays;
-
-public abstract class PluginInstaller implements BatchComponent, ServerComponent {
-
-  protected static final String FAIL_TO_INSTALL_PLUGIN = "Fail to install plugin: ";
-
-  protected void install(DefaultPluginMetadata metadata, @Nullable File pluginBasedir, File deployedPlugin) {
-    try {
-      metadata.addDeployedFile(deployedPlugin);
-      copyDependencies(metadata, deployedPlugin, pluginBasedir);
-    } catch (IOException e) {
-      throw new SonarException(FAIL_TO_INSTALL_PLUGIN + metadata, e);
-    }
-  }
-
-  private void copyDependencies(DefaultPluginMetadata metadata, File pluginFile, @Nullable File pluginBasedir) throws IOException {
-    if (!metadata.getPathsToInternalDeps().isEmpty()) {
-      // needs to unzip the jar
-      File baseDir = extractPluginDependencies(pluginFile, pluginBasedir);
-      for (String depPath : metadata.getPathsToInternalDeps()) {
-        File dependency = new File(baseDir, depPath);
-        if (!dependency.isFile() || !dependency.exists()) {
-          throw new IllegalArgumentException("Dependency " + depPath + " can not be found in " + pluginFile.getName());
-        }
-        metadata.addDeployedFile(dependency);
-      }
-    }
-  }
-
-  protected abstract File extractPluginDependencies(File pluginFile, @Nullable File pluginBasedir) throws IOException;
-
-  public DefaultPluginMetadata extractMetadata(File file, boolean isCore) {
-    try {
-      PluginManifest manifest = new PluginManifest(file);
-      DefaultPluginMetadata metadata = DefaultPluginMetadata.create(file);
-      metadata.setKey(manifest.getKey());
-      metadata.setName(manifest.getName());
-      metadata.setDescription(manifest.getDescription());
-      metadata.setLicense(manifest.getLicense());
-      metadata.setOrganization(manifest.getOrganization());
-      metadata.setOrganizationUrl(manifest.getOrganizationUrl());
-      metadata.setMainClass(manifest.getMainClass());
-      metadata.setVersion(manifest.getVersion());
-      metadata.setSonarVersion(manifest.getSonarVersion());
-      metadata.setHomepage(manifest.getHomepage());
-      metadata.setIssueTrackerUrl(manifest.getIssueTrackerUrl());
-      metadata.setPathsToInternalDeps(Arrays.asList(manifest.getDependencies()));
-      metadata.setUseChildFirstClassLoader(manifest.isUseChildFirstClassLoader());
-      metadata.setBasePlugin(manifest.getBasePlugin());
-      metadata.setImplementationBuild(manifest.getImplementationBuild());
-      metadata.setParent(manifest.getParent());
-      metadata.setRequiredPlugins(Arrays.asList(manifest.getRequirePlugins()));
-      metadata.setCore(isCore);
-      return metadata;
-
-    } catch (IOException e) {
-      throw new IllegalStateException("Fail to extract plugin metadata from file: " + file, e);
-    }
-  }
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/plugins/PluginJarInstaller.java b/sonar-core/src/main/java/org/sonar/core/plugins/PluginJarInstaller.java
new file mode 100644 (file)
index 0000000..0f9a06d
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ * 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.core.plugins;
+
+import org.sonar.api.BatchComponent;
+import org.sonar.api.ServerComponent;
+import org.sonar.api.utils.SonarException;
+import org.sonar.updatecenter.common.PluginManifest;
+
+import javax.annotation.Nullable;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Arrays;
+
+public abstract class PluginJarInstaller implements BatchComponent, ServerComponent {
+
+  protected static final String FAIL_TO_INSTALL_PLUGIN = "Fail to install plugin: ";
+
+  protected void install(DefaultPluginMetadata metadata, @Nullable File pluginBasedir, File deployedPlugin) {
+    try {
+      metadata.addDeployedFile(deployedPlugin);
+      copyDependencies(metadata, deployedPlugin, pluginBasedir);
+    } catch (IOException e) {
+      throw new SonarException(FAIL_TO_INSTALL_PLUGIN + metadata, e);
+    }
+  }
+
+  private void copyDependencies(DefaultPluginMetadata metadata, File pluginFile, @Nullable File pluginBasedir) throws IOException {
+    if (!metadata.getPathsToInternalDeps().isEmpty()) {
+      // needs to unzip the jar
+      File baseDir = extractPluginDependencies(pluginFile, pluginBasedir);
+      for (String depPath : metadata.getPathsToInternalDeps()) {
+        File dependency = new File(baseDir, depPath);
+        if (!dependency.isFile() || !dependency.exists()) {
+          throw new IllegalArgumentException("Dependency " + depPath + " can not be found in " + pluginFile.getName());
+        }
+        metadata.addDeployedFile(dependency);
+      }
+    }
+  }
+
+  protected abstract File extractPluginDependencies(File pluginFile, @Nullable File pluginBasedir) throws IOException;
+
+  public DefaultPluginMetadata extractMetadata(File file, boolean isCore) {
+    try {
+      PluginManifest manifest = new PluginManifest(file);
+      DefaultPluginMetadata metadata = DefaultPluginMetadata.create(file);
+      metadata.setKey(manifest.getKey());
+      metadata.setName(manifest.getName());
+      metadata.setDescription(manifest.getDescription());
+      metadata.setLicense(manifest.getLicense());
+      metadata.setOrganization(manifest.getOrganization());
+      metadata.setOrganizationUrl(manifest.getOrganizationUrl());
+      metadata.setMainClass(manifest.getMainClass());
+      metadata.setVersion(manifest.getVersion());
+      metadata.setSonarVersion(manifest.getSonarVersion());
+      metadata.setHomepage(manifest.getHomepage());
+      metadata.setIssueTrackerUrl(manifest.getIssueTrackerUrl());
+      metadata.setPathsToInternalDeps(Arrays.asList(manifest.getDependencies()));
+      metadata.setUseChildFirstClassLoader(manifest.isUseChildFirstClassLoader());
+      metadata.setBasePlugin(manifest.getBasePlugin());
+      metadata.setImplementationBuild(manifest.getImplementationBuild());
+      metadata.setParent(manifest.getParent());
+      metadata.setRequiredPlugins(Arrays.asList(manifest.getRequirePlugins()));
+      metadata.setCore(isCore);
+      return metadata;
+
+    } catch (IOException e) {
+      throw new IllegalStateException("Fail to extract plugin metadata from file: " + file, e);
+    }
+  }
+}
index 6eecd417d179cd7ad40cf7981fd444b5b0833ffa..20ec65982c5608993a2d0ceedb2a3a384a32c6c1 100644 (file)
@@ -21,13 +21,12 @@ package org.sonar.core.profiling;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.sonar.api.ServerExtension;
 import org.sonar.api.config.Settings;
 
 /**
  * @since 4.1
  */
-public final class Profiling implements ServerExtension {
+public class Profiling {
 
   public static final String CONFIG_PROFILING_LEVEL = "sonar.log.profilingLevel";
 
@@ -44,7 +43,7 @@ public final class Profiling implements ServerExtension {
       if (settingsValue != null) {
         try {
           settingsLevel = Level.valueOf(settingsValue);
-        } catch(IllegalArgumentException invalidSettings) {
+        } catch (IllegalArgumentException invalidSettings) {
           LOGGER.debug("Bad profiling settings, profiling is disabled", invalidSettings);
         }
       }
diff --git a/sonar-core/src/test/java/org/sonar/core/plugins/PluginInstallerTest.java b/sonar-core/src/test/java/org/sonar/core/plugins/PluginInstallerTest.java
deleted file mode 100644 (file)
index c37ce8e..0000000
+++ /dev/null
@@ -1,107 +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.core.plugins;
-
-import org.apache.commons.io.FileUtils;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
-
-import java.io.File;
-import java.io.IOException;
-
-import static org.fest.assertions.Assertions.assertThat;
-
-public class PluginInstallerTest {
-
-  private PluginInstaller extractor;
-
-  @ClassRule
-  public static TemporaryFolder temporaryFolder = new TemporaryFolder();
-
-  private File userHome;
-
-  @Before
-  public void setUp() throws IOException {
-    userHome = temporaryFolder.newFolder();
-    extractor = new PluginInstaller() {
-      @Override
-      protected File extractPluginDependencies(File pluginFile, File pluginBasedir) throws IOException {
-        return null;
-      }
-    };
-  }
-
-  @Test
-  public void should_extract_metadata() throws IOException {
-    DefaultPluginMetadata metadata = extractor.extractMetadata(getFileFromCache("sonar-cobertura-plugin-3.1.1.jar"), true);
-
-    assertThat(metadata.getKey()).isEqualTo("cobertura");
-    assertThat(metadata.getBasePlugin()).isNull();
-    assertThat(metadata.getName()).isEqualTo("Cobertura");
-    assertThat(metadata.isCore()).isEqualTo(true);
-    assertThat(metadata.getFile().getName()).isEqualTo("sonar-cobertura-plugin-3.1.1.jar");
-    assertThat(metadata.getVersion()).isEqualTo("3.1.1");
-    assertThat(metadata.getImplementationBuild()).isEqualTo("b9283404030db9ce1529b1fadfb98331686b116d");
-    assertThat(metadata.getHomepage()).isEqualTo("http://www.sonarsource.org/plugins/sonar-cobertura-plugin");
-    assertThat(metadata.getIssueTrackerUrl()).isEqualTo("http://jira.codehaus.org/browse/SONAR");
-  }
-
-  @Test
-  public void should_read_sonar_version() throws IOException {
-    DefaultPluginMetadata metadata = extractor.extractMetadata(getFileFromCache("sonar-switch-off-violations-plugin-1.1.jar"), false);
-
-    assertThat(metadata.getVersion()).isEqualTo("1.1");
-    assertThat(metadata.getSonarVersion()).isEqualTo("2.5");
-  }
-
-  @Test
-  public void should_extract_extension_metadata() throws IOException {
-    DefaultPluginMetadata metadata = extractor.extractMetadata(getFileFromCache("sonar-checkstyle-extensions-plugin-0.1-SNAPSHOT.jar"), true);
-
-    assertThat(metadata.getKey()).isEqualTo("checkstyleextensions");
-    assertThat(metadata.getBasePlugin()).isEqualTo("checkstyle");
-  }
-
-  @Test
-  public void should_extract_parent_information() throws IOException {
-    DefaultPluginMetadata metadata = extractor.extractMetadata(getFileFromCache("fake1bis-plugin-1.0.jar"), true);
-
-    assertThat(metadata.getKey()).isEqualTo("fake1bis");
-    assertThat(metadata.getParent()).isEqualTo("fake1");
-  }
-
-  @Test
-  public void should_extract_requires_plugin_information() throws IOException {
-    DefaultPluginMetadata metadata = extractor.extractMetadata(getFileFromCache("fake2-plugin-1.1.jar"), true);
-
-    assertThat(metadata.getKey()).isEqualTo("fake2");
-    assertThat(metadata.getRequiredPlugins().get(0)).isEqualTo("fake1:1.1");
-  }
-
-  File getFileFromCache(String filename) throws IOException {
-    File src = FileUtils.toFile(PluginInstallerTest.class.getResource("/org/sonar/core/plugins/" + filename));
-    File destFile = new File(new File(userHome, "" + filename.hashCode()), filename);
-    FileUtils.copyFile(src, destFile);
-    return destFile;
-  }
-
-}
diff --git a/sonar-core/src/test/java/org/sonar/core/plugins/PluginJarInstallerTest.java b/sonar-core/src/test/java/org/sonar/core/plugins/PluginJarInstallerTest.java
new file mode 100644 (file)
index 0000000..59532ab
--- /dev/null
@@ -0,0 +1,107 @@
+/*
+ * 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.core.plugins;
+
+import org.apache.commons.io.FileUtils;
+import org.junit.Before;
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
+
+import java.io.File;
+import java.io.IOException;
+
+import static org.fest.assertions.Assertions.assertThat;
+
+public class PluginJarInstallerTest {
+
+  private PluginJarInstaller extractor;
+
+  @ClassRule
+  public static TemporaryFolder temporaryFolder = new TemporaryFolder();
+
+  private File userHome;
+
+  @Before
+  public void setUp() throws IOException {
+    userHome = temporaryFolder.newFolder();
+    extractor = new PluginJarInstaller() {
+      @Override
+      protected File extractPluginDependencies(File pluginFile, File pluginBasedir) throws IOException {
+        return null;
+      }
+    };
+  }
+
+  @Test
+  public void should_extract_metadata() throws IOException {
+    DefaultPluginMetadata metadata = extractor.extractMetadata(getFileFromCache("sonar-cobertura-plugin-3.1.1.jar"), true);
+
+    assertThat(metadata.getKey()).isEqualTo("cobertura");
+    assertThat(metadata.getBasePlugin()).isNull();
+    assertThat(metadata.getName()).isEqualTo("Cobertura");
+    assertThat(metadata.isCore()).isEqualTo(true);
+    assertThat(metadata.getFile().getName()).isEqualTo("sonar-cobertura-plugin-3.1.1.jar");
+    assertThat(metadata.getVersion()).isEqualTo("3.1.1");
+    assertThat(metadata.getImplementationBuild()).isEqualTo("b9283404030db9ce1529b1fadfb98331686b116d");
+    assertThat(metadata.getHomepage()).isEqualTo("http://www.sonarsource.org/plugins/sonar-cobertura-plugin");
+    assertThat(metadata.getIssueTrackerUrl()).isEqualTo("http://jira.codehaus.org/browse/SONAR");
+  }
+
+  @Test
+  public void should_read_sonar_version() throws IOException {
+    DefaultPluginMetadata metadata = extractor.extractMetadata(getFileFromCache("sonar-switch-off-violations-plugin-1.1.jar"), false);
+
+    assertThat(metadata.getVersion()).isEqualTo("1.1");
+    assertThat(metadata.getSonarVersion()).isEqualTo("2.5");
+  }
+
+  @Test
+  public void should_extract_extension_metadata() throws IOException {
+    DefaultPluginMetadata metadata = extractor.extractMetadata(getFileFromCache("sonar-checkstyle-extensions-plugin-0.1-SNAPSHOT.jar"), true);
+
+    assertThat(metadata.getKey()).isEqualTo("checkstyleextensions");
+    assertThat(metadata.getBasePlugin()).isEqualTo("checkstyle");
+  }
+
+  @Test
+  public void should_extract_parent_information() throws IOException {
+    DefaultPluginMetadata metadata = extractor.extractMetadata(getFileFromCache("fake1bis-plugin-1.0.jar"), true);
+
+    assertThat(metadata.getKey()).isEqualTo("fake1bis");
+    assertThat(metadata.getParent()).isEqualTo("fake1");
+  }
+
+  @Test
+  public void should_extract_requires_plugin_information() throws IOException {
+    DefaultPluginMetadata metadata = extractor.extractMetadata(getFileFromCache("fake2-plugin-1.1.jar"), true);
+
+    assertThat(metadata.getKey()).isEqualTo("fake2");
+    assertThat(metadata.getRequiredPlugins().get(0)).isEqualTo("fake1:1.1");
+  }
+
+  File getFileFromCache(String filename) throws IOException {
+    File src = FileUtils.toFile(PluginJarInstallerTest.class.getResource("/org/sonar/core/plugins/" + filename));
+    File destFile = new File(new File(userHome, "" + filename.hashCode()), filename);
+    FileUtils.copyFile(src, destFile);
+    return destFile;
+  }
+
+}
index b40320dadcd33c8d915f480f0737efce3956a22a..ad26ec2dae314b2876034bc53a25956aa7449b8b 100644 (file)
@@ -23,9 +23,11 @@ import org.sonar.api.BatchComponent;
 import org.sonar.api.Plugin;
 import org.sonar.api.ServerComponent;
 
+import javax.annotation.CheckForNull;
 import java.util.Collection;
 
 public interface PluginRepository extends BatchComponent, ServerComponent {
+  @CheckForNull
   Plugin getPlugin(String key);
 
   /**
@@ -41,5 +43,6 @@ public interface PluginRepository extends BatchComponent, ServerComponent {
    * Search for an installed plugin. Returns null if the plugin is not installed.
    * @since 2.9
    */
+  @CheckForNull
   PluginMetadata getMetadata(String pluginKey);
 }
index 183ff4d6ec5ba39a5c5c6490e03370d9e014eb0b..0c49b7c85b90dfcd16dee1c8bd06dee348808911 100644 (file)
 package org.sonar.server.db;
 
 import com.google.common.annotations.VisibleForTesting;
+import org.picocontainer.Startable;
 import org.sonar.api.config.Settings;
 import org.sonar.api.database.DatabaseProperties;
 
-public class EmbeddedDatabaseFactory {
+public class EmbeddedDatabaseFactory implements Startable {
   private final Settings settings;
   private EmbeddedDatabase embeddedDatabase;
 
@@ -31,6 +32,7 @@ public class EmbeddedDatabaseFactory {
     this.settings = settings;
   }
 
+  @Override
   public void start() {
     if (embeddedDatabase == null) {
       String jdbcUrl = settings.getString(DatabaseProperties.PROP_URL);
@@ -41,9 +43,11 @@ public class EmbeddedDatabaseFactory {
     }
   }
 
+  @Override
   public void stop() {
     if (embeddedDatabase != null) {
       embeddedDatabase.stop();
+      embeddedDatabase = null;
     }
   }
 
index 70fd19fc168d6cc0e313b8947cbcb4dde21d7826..75c8ba72a3dbfd3ce07c5e308028a3041d636ba2 100644 (file)
  */
 package org.sonar.server.platform;
 
+import org.picocontainer.Startable;
 import org.slf4j.LoggerFactory;
-import org.sonar.api.ServerComponent;
 import org.sonar.api.utils.MessageException;
 import org.sonar.core.persistence.DatabaseVersion;
 
-public class DatabaseServerCompatibility implements ServerComponent {
-  
+public class DatabaseServerCompatibility implements Startable {
+
   private DatabaseVersion version;
 
   public DatabaseServerCompatibility(DatabaseVersion version) {
     this.version = version;
   }
 
+  @Override
   public void start() {
     DatabaseVersion.Status status = version.getStatus();
-    if (status== DatabaseVersion.Status.REQUIRES_DOWNGRADE) {
+    if (status == DatabaseVersion.Status.REQUIRES_DOWNGRADE) {
       throw MessageException.of("Database relates to a more recent version of sonar. Please check your settings.");
     }
-    if (status== DatabaseVersion.Status.REQUIRES_UPGRADE) {
+    if (status == DatabaseVersion.Status.REQUIRES_UPGRADE) {
       LoggerFactory.getLogger(DatabaseServerCompatibility.class).info("Database must be upgraded. Please browse /setup");
     }
   }
 
+  @Override
+  public void stop() {
+    // do nothing
+  }
 }
index fad981684645cfb119b18ebb6e566ab38c078e9f..3229b6e57801201717465621c22dff332e0a8c62 100644 (file)
@@ -22,6 +22,7 @@ package org.sonar.server.platform;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.filefilter.FileFilterUtils;
 import org.apache.commons.lang.StringUtils;
+import org.picocontainer.Startable;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.sonar.api.CoreProperties;
@@ -41,7 +42,7 @@ import java.util.List;
  *
  * @since 2.2
  */
-public class DefaultServerFileSystem implements ServerFileSystem {
+public class DefaultServerFileSystem implements ServerFileSystem, Startable {
 
   private static final Logger LOGGER = LoggerFactory.getLogger(DefaultServerFileSystem.class);
 
@@ -68,6 +69,7 @@ public class DefaultServerFileSystem implements ServerFileSystem {
     this.homeDir = homeDir;
   }
 
+  @Override
   public void start() {
     LOGGER.info("SonarQube home: " + homeDir.getAbsolutePath());
     if (!homeDir.isDirectory() || !homeDir.exists()) {
@@ -99,10 +101,17 @@ public class DefaultServerFileSystem implements ServerFileSystem {
     }
   }
 
+  @Override
+  public void stop() {
+    // do nothing
+  }
+
+  @Override
   public File getHomeDir() {
     return homeDir;
   }
 
+  @Override
   public File getTempDir() {
     return new File(homeDir, "temp");
   }
@@ -174,6 +183,7 @@ public class DefaultServerFileSystem implements ServerFileSystem {
   /**
    * @deprecated since 4.1
    */
+  @Override
   @Deprecated
   public List<File> getExtensions(String dirName, String... suffixes) {
     File dir = new File(getHomeDir(), "extensions/rules/" + dirName);
index 9569935e78472d6dd1113fd81066900ce1bf4219..29d421513b035372387eda74fa308318e079ea8e 100644 (file)
@@ -21,34 +21,46 @@ package org.sonar.server.platform;
 
 import org.apache.commons.lang.builder.ReflectionToStringBuilder;
 import org.apache.commons.lang.builder.ToStringStyle;
+import org.picocontainer.Startable;
 import org.sonar.api.platform.ServerUpgradeStatus;
 import org.sonar.core.persistence.DatabaseVersion;
 
 /**
  * @since 2.5
  */
-public final class DefaultServerUpgradeStatus implements ServerUpgradeStatus {
+public final class DefaultServerUpgradeStatus implements ServerUpgradeStatus, Startable {
 
+  private final DatabaseVersion dbVersion;
+
+  // available when connected to db
   private int initialDbVersion;
-  private DatabaseVersion dbVersion;
 
   public DefaultServerUpgradeStatus(DatabaseVersion dbVersion) {
     this.dbVersion = dbVersion;
   }
 
+  @Override
   public void start() {
     Integer v = dbVersion.getVersion();
     this.initialDbVersion = (v != null ? v : -1);
   }
 
+  @Override
+  public void stop() {
+
+  }
+
+  @Override
   public boolean isUpgraded() {
     return !isFreshInstall() && (initialDbVersion < DatabaseVersion.LAST_VERSION);
   }
 
+  @Override
   public boolean isFreshInstall() {
-    return initialDbVersion<0;
+    return initialDbVersion < 0;
   }
 
+  @Override
   public int getInitialDbVersion() {
     return initialDbVersion;
   }
index c8c24f1b369912ce3536b8e0c27a9301802240d9..4525746ebfcc0211d91c2011f68cc407c38fc65a 100644 (file)
 package org.sonar.server.platform;
 
 import com.google.common.collect.Maps;
-import org.sonar.api.ServerComponent;
+import org.picocontainer.Startable;
 import org.sonar.api.config.Settings;
 import org.sonar.core.properties.PropertiesDao;
 import org.sonar.core.properties.PropertyDto;
 
 import javax.annotation.Nullable;
-
 import java.util.List;
 import java.util.Map;
 
 /**
  * @since 3.2
  */
-public class PersistentSettings implements ServerComponent {
+public class PersistentSettings implements Startable {
   private final PropertiesDao propertiesDao;
   private final ServerSettings settings;
 
@@ -42,6 +41,7 @@ public class PersistentSettings implements ServerComponent {
     this.settings = settings;
   }
 
+  @Override
   public void start() {
     Map<String, String> databaseProperties = Maps.newHashMap();
     for (PropertyDto property : getGlobalProperties()) {
@@ -50,6 +50,11 @@ public class PersistentSettings implements ServerComponent {
     settings.activateDatabaseSettings(databaseProperties);
   }
 
+  @Override
+  public void stop() {
+    // nothing to do
+  }
+
   public PersistentSettings saveProperty(String key, @Nullable String value) {
     settings.setProperty(key, value);
     propertiesDao.setProperty(new PropertyDto().setKey(key).setValue(value));
@@ -86,7 +91,7 @@ public class PersistentSettings implements ServerComponent {
     return settings;
   }
 
-  public List<PropertyDto> getGlobalProperties(){
+  public List<PropertyDto> getGlobalProperties() {
     return propertiesDao.selectGlobalProperties();
   }
 }
index 62ebbfa76efde64df60dc7f100a315fdf4783e6c..ea7ad0bc995150f08cc3a3a3250991763b11d611 100644 (file)
@@ -51,11 +51,11 @@ import org.sonar.server.db.migrations.DatabaseMigrator;
 import org.sonar.server.es.ESNode;
 import org.sonar.server.platform.ws.PlatformWs;
 import org.sonar.server.platform.ws.RestartHandler;
-import org.sonar.server.plugins.DefaultServerPluginRepository;
+import org.sonar.server.plugins.ServerPluginJarInstaller;
+import org.sonar.server.plugins.ServerPluginJarsInstaller;
+import org.sonar.server.plugins.ServerPluginRepository;
 import org.sonar.server.plugins.InstalledPluginReferentialFactory;
-import org.sonar.server.plugins.PluginDeployer;
 import org.sonar.server.plugins.ServerExtensionInstaller;
-import org.sonar.server.plugins.ServerPluginInstaller;
 import org.sonar.server.startup.ServerMetadataPersister;
 import org.sonar.server.ui.JRubyI18n;
 import org.sonar.server.ui.JRubyProfiling;
@@ -144,22 +144,28 @@ public class Platform {
       level1Container.addSingleton(daoClass);
     }
     level1Container.addSingleton(PurgeProfiler.class);
-    level1Container.addSingleton(PluginDeployer.class);
-    level1Container.addSingleton(ServerPluginInstaller.class);
-    level1Container.addSingleton(InstalledPluginReferentialFactory.class);
-    level1Container.addSingleton(DefaultServerPluginRepository.class);
     level1Container.addSingleton(DefaultServerFileSystem.class);
+    level1Container.addSingleton(PreviewDatabaseFactory.class);
+    level1Container.addSingleton(SemaphoreUpdater.class);
+    level1Container.addSingleton(SemaphoresImpl.class);
+    level1Container.addPicoAdapter(new TempFolderProvider());
+    level1Container.addSingleton(TempFolderCleaner.class);
+
+
+    // plugins
+    level1Container.addSingleton(ServerPluginJarsInstaller.class);
+    level1Container.addSingleton(ServerPluginJarInstaller.class);
+    level1Container.addSingleton(InstalledPluginReferentialFactory.class);
+    level1Container.addSingleton(ServerPluginRepository.class);
+    level1Container.addSingleton(ServerExtensionInstaller.class);
+
+    // depends on plugins
     level1Container.addSingleton(RailsAppsDeployer.class);
     level1Container.addSingleton(JRubyI18n.class);
     level1Container.addSingleton(DefaultI18n.class);
     level1Container.addSingleton(RuleI18nManager.class);
     level1Container.addSingleton(GwtI18n.class);
     level1Container.addSingleton(Durations.class);
-    level1Container.addSingleton(PreviewDatabaseFactory.class);
-    level1Container.addSingleton(SemaphoreUpdater.class);
-    level1Container.addSingleton(SemaphoresImpl.class);
-    level1Container.addPicoAdapter(new TempFolderProvider());
-    level1Container.addSingleton(TempFolderCleaner.class);
     level1Container.startComponents();
   }
 
@@ -175,7 +181,6 @@ public class Platform {
     level2Container = level1Container.createChild();
     level2Container.addSingleton(PersistentSettings.class);
     level2Container.addSingleton(DefaultDatabaseConnector.class);
-    level2Container.addSingleton(ServerExtensionInstaller.class);
     level2Container.addSingleton(ThreadLocalDatabaseSessionFactory.class);
     level2Container.addPicoAdapter(new DatabaseSessionProvider());
     level2Container.addSingleton(ServerMetadataPersister.class);
index 14aa740b3cdab43f6f351493fbac51b2016dc82f..2ba3bd2d4c8d6bfcf5da2b335af8aa1b15f54679 100644 (file)
@@ -23,6 +23,7 @@ import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Function;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang.StringUtils;
+import org.picocontainer.Startable;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.sonar.api.platform.PluginMetadata;
@@ -39,7 +40,8 @@ import java.io.IOException;
  *
  * @since 3.0
  */
-public class RailsAppsDeployer {
+public class RailsAppsDeployer implements Startable {
+
   private static final Logger LOG = LoggerFactory.getLogger(RailsAppsDeployer.class);
   private static final String ROR_PATH = "org/sonar/ror/";
 
@@ -51,6 +53,7 @@ public class RailsAppsDeployer {
     this.pluginRepository = pluginRepository;
   }
 
+  @Override
   public void start() {
     LOG.info("Deploy Ruby on Rails applications");
     File appsDir = prepareRailsDirectory();
@@ -65,6 +68,11 @@ public class RailsAppsDeployer {
     }
   }
 
+  @Override
+  public void stop() {
+    // do nothing
+  }
+
   @VisibleForTesting
   File prepareRailsDirectory() {
     File appsDir = new File(fileSystem.getTempDir(), "ror");
index e825a8a889d294e390534f32ce0ed221a00ade64..c360d947c6c20f8756a5df80f4487a7ab56f951a 100644 (file)
@@ -352,7 +352,7 @@ public class ServerComponentsStarter {
     pico.addSingleton(StringListTypeValidation.class);
 
     ServerExtensionInstaller extensionRegistrar = pico.getComponentByType(ServerExtensionInstaller.class);
-    extensionRegistrar.registerExtensions(pico);
+    extensionRegistrar.installExtensions(pico);
   }
 
   private void executeStartupTaks(ComponentContainer pico) {
index 93ab6bcd2b9e36c0d1a7c3b4eceabbc118308218..79d4e11ac18aa1f56e1ea334c9f554d09a96f012 100644 (file)
@@ -23,6 +23,7 @@ import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Joiner;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang.StringUtils;
+import org.picocontainer.Startable;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.sonar.api.CoreProperties;
@@ -35,7 +36,7 @@ import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.Properties;
 
-public final class ServerImpl extends Server {
+public final class ServerImpl extends Server implements Startable {
   private static final Logger LOG = LoggerFactory.getLogger(ServerImpl.class);
 
   private final Settings settings;
@@ -58,6 +59,7 @@ public final class ServerImpl extends Server {
     this.pomProperties = pomProperties;
   }
 
+  @Override
   public void start() {
     try {
       id = new SimpleDateFormat("yyyyMMddHHmmss").format(startedAt);
@@ -76,6 +78,11 @@ public final class ServerImpl extends Server {
     }
   }
 
+  @Override
+  public void stop() {
+    // do nothing
+  }
+
   @Override
   public String getPermanentServerId() {
     return settings.getString(CoreProperties.PERMANENT_SERVER_ID);
index ea53bb046e052c1b4192de09bf49b972e285f058..ebed1d422b0ac01758c4af28fc7878d3fae4583d 100644 (file)
  */
 package org.sonar.server.platform;
 
+import org.picocontainer.Startable;
 import org.slf4j.LoggerFactory;
-import org.sonar.api.ServerComponent;
+import org.sonar.api.platform.Server;
 import org.sonar.api.platform.ServerStartHandler;
 import org.sonar.api.platform.ServerStopHandler;
-import org.sonar.api.platform.Server;
 
 /**
  * @since 2.2
  */
-public class ServerLifecycleNotifier implements ServerComponent {
+public class ServerLifecycleNotifier implements Startable {
 
   private ServerStartHandler[] startHandlers;
   private ServerStopHandler[] stopHandlers;
@@ -52,6 +52,7 @@ public class ServerLifecycleNotifier implements ServerComponent {
     this(server, new ServerStartHandler[0], new ServerStopHandler[0]);
   }
 
+  @Override
   public void start() {
     /* IMPORTANT :
      we want to be sure that handlers are notified when all other services are started.
@@ -67,6 +68,7 @@ public class ServerLifecycleNotifier implements ServerComponent {
     }
   }
 
+  @Override
   public void stop() {
     LoggerFactory.getLogger(ServerLifecycleNotifier.class).debug("Notify " + ServerStopHandler.class.getSimpleName() + " handlers...");
     for (ServerStopHandler handler : stopHandlers) {
index 96982df506bfaaf696d27af1298a002790395666..747d9946d05ec146fcead77831717312f88fd614 100644 (file)
 package org.sonar.server.platform;
 
 import com.google.common.annotations.VisibleForTesting;
-import org.sonar.api.ServerComponent;
 import org.sonar.api.config.GlobalPropertyChangeHandler;
 
 import javax.annotation.Nullable;
 
-public class SettingsChangeNotifier implements ServerComponent {
+public class SettingsChangeNotifier {
 
   @VisibleForTesting
   GlobalPropertyChangeHandler[] changeHandlers;
diff --git a/sonar-server/src/main/java/org/sonar/server/plugins/DefaultServerPluginRepository.java b/sonar-server/src/main/java/org/sonar/server/plugins/DefaultServerPluginRepository.java
deleted file mode 100644 (file)
index b2cefb8..0000000
+++ /dev/null
@@ -1,90 +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.server.plugins;
-
-import org.picocontainer.Startable;
-import org.slf4j.LoggerFactory;
-import org.sonar.api.Plugin;
-import org.sonar.api.platform.PluginMetadata;
-import org.sonar.api.platform.PluginRepository;
-import org.sonar.core.plugins.PluginClassloaders;
-
-import java.util.Collection;
-import java.util.Map;
-
-/**
- * This class loads JAR files and initializes classloaders of plugins
- */
-public class DefaultServerPluginRepository implements PluginRepository, Startable {
-
-  private final PluginDeployer deployer;
-  private final PluginClassloaders classloaders;
-  private Map<String, Plugin> pluginsByKey;
-
-  public DefaultServerPluginRepository(PluginDeployer deployer) {
-    this.classloaders = new PluginClassloaders(getClass().getClassLoader());
-    this.deployer = deployer;
-  }
-
-  @Override
-  public void start() {
-    Collection<PluginMetadata> metadata = deployer.getMetadata();
-    pluginsByKey = classloaders.init(metadata);
-  }
-
-  @Override
-  public void stop() {
-    classloaders.clean();
-  }
-
-  @Override
-  public Plugin getPlugin(String key) {
-    return pluginsByKey.get(key);
-  }
-
-  public ClassLoader getClassLoader(String pluginKey) {
-    return classloaders.get(pluginKey);
-  }
-
-  public Class getClass(String pluginKey, String classname) {
-    Class clazz = null;
-    ClassLoader classloader = getClassLoader(pluginKey);
-    if (classloader != null) {
-      try {
-        clazz = classloader.loadClass(classname);
-
-      } catch (ClassNotFoundException e) {
-        LoggerFactory.getLogger(getClass()).warn("Class not found in plugin " + pluginKey + ": " + classname, e);
-      }
-    }
-    return clazz;
-  }
-
-  @Override
-  public Collection<PluginMetadata> getMetadata() {
-    return deployer.getMetadata();
-  }
-
-  @Override
-  public PluginMetadata getMetadata(String pluginKey) {
-    return deployer.getMetadata(pluginKey);
-  }
-
-}
index d7e1b3293b24a4b2530bc429f9e18e655010304e..257cd22ca05643432ef4da1915edd55fe1084b58 100644 (file)
  */
 package org.sonar.server.plugins;
 
-import org.sonar.api.ServerComponent;
+import org.picocontainer.Startable;
 import org.sonar.api.platform.PluginRepository;
 import org.sonar.updatecenter.common.PluginReferential;
 
-public class InstalledPluginReferentialFactory implements ServerComponent {
+public class InstalledPluginReferentialFactory implements Startable {
 
   private final PluginRepository pluginRepository;
   private PluginReferential installedPluginReferential;
@@ -32,6 +32,7 @@ public class InstalledPluginReferentialFactory implements ServerComponent {
     this.pluginRepository = pluginRepository;
   }
 
+  @Override
   public void start() {
     try {
       init();
@@ -40,6 +41,11 @@ public class InstalledPluginReferentialFactory implements ServerComponent {
     }
   }
 
+  @Override
+  public void stop() {
+    // nothing to do
+  }
+
   public PluginReferential getInstalledPluginReferential() {
     return installedPluginReferential;
   }
diff --git a/sonar-server/src/main/java/org/sonar/server/plugins/PluginDeployer.java b/sonar-server/src/main/java/org/sonar/server/plugins/PluginDeployer.java
deleted file mode 100644 (file)
index a126ce3..0000000
+++ /dev/null
@@ -1,233 +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.server.plugins;
-
-import com.google.common.base.Joiner;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.lang.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.sonar.api.ServerComponent;
-import org.sonar.api.platform.PluginMetadata;
-import org.sonar.api.platform.Server;
-import org.sonar.api.platform.ServerUpgradeStatus;
-import org.sonar.api.utils.TimeProfiler;
-import org.sonar.core.plugins.DefaultPluginMetadata;
-import org.sonar.server.platform.DefaultServerFileSystem;
-import org.sonar.updatecenter.common.PluginReferential;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
-public class PluginDeployer implements ServerComponent {
-
-  private static final Logger LOG = LoggerFactory.getLogger(PluginDeployer.class);
-
-  private final Server server;
-  private final DefaultServerFileSystem fileSystem;
-  private final ServerPluginInstaller installer;
-  private final Map<String, PluginMetadata> pluginByKeys = Maps.newHashMap();
-  private final ServerUpgradeStatus serverUpgradeStatus;
-
-  public PluginDeployer(Server server, ServerUpgradeStatus serverUpgradeStatus, DefaultServerFileSystem fileSystem, ServerPluginInstaller installer) {
-    this.server = server;
-    this.serverUpgradeStatus = serverUpgradeStatus;
-    this.fileSystem = fileSystem;
-    this.installer = installer;
-  }
-
-  public void start() {
-    TimeProfiler profiler = new TimeProfiler().start("Install plugins");
-
-    deleteUninstalledPlugins();
-
-    loadUserPlugins();
-    if (serverUpgradeStatus.isFreshInstall()) {
-      copyAndLoadBundledPlugins();
-    }
-    moveAndLoadDownloadedPlugins();
-    loadCorePlugins();
-
-    deployPlugins();
-
-    profiler.stop();
-  }
-
-  private void deleteUninstalledPlugins() {
-    File trashDir = fileSystem.getRemovedPluginsDir();
-    try {
-      if (trashDir.exists()) {
-        FileUtils.deleteDirectory(trashDir);
-      }
-    } catch (IOException e) {
-      throw new IllegalStateException("Fail to clean the plugin trash directory: " + trashDir, e);
-    }
-  }
-
-  private void loadUserPlugins() {
-    for (File file : fileSystem.getUserPlugins()) {
-      registerPlugin(file, false, false);
-    }
-  }
-
-  private void registerPlugin(File file, boolean isCore, boolean canDelete) {
-    DefaultPluginMetadata metadata = installer.extractMetadata(file, isCore);
-    if (StringUtils.isBlank(metadata.getKey())) {
-      return;
-    }
-
-    PluginMetadata existing = pluginByKeys.put(metadata.getKey(), metadata);
-
-    if ((existing != null) && !canDelete) {
-      throw new IllegalStateException("Found two plugins with the same key '" + metadata.getKey() + "': " + metadata.getFile().getName() + " and "
-        + existing.getFile().getName());
-    }
-
-    if (existing != null) {
-      FileUtils.deleteQuietly(existing.getFile());
-      LOG.info("Plugin " + metadata.getKey() + " replaced by new version");
-    }
-  }
-
-  private void moveAndLoadDownloadedPlugins() {
-    if (fileSystem.getDownloadedPluginsDir().exists()) {
-      Collection<File> jars = FileUtils.listFiles(fileSystem.getDownloadedPluginsDir(), new String[] {"jar"}, false);
-      for (File jar : jars) {
-        installJarPlugin(jar, true);
-      }
-    }
-  }
-
-  private void copyAndLoadBundledPlugins() {
-    for (File plugin : fileSystem.getBundledPlugins()) {
-      installJarPlugin(plugin, false);
-    }
-  }
-
-  private void installJarPlugin(File jar, boolean deleteSource) {
-    File destDir = fileSystem.getUserPluginsDir();
-    File destFile = new File(destDir, jar.getName());
-    if (destFile.exists()) {
-      // plugin with same filename already installed
-      FileUtils.deleteQuietly(jar);
-    }
-    try {
-      if (deleteSource) {
-        FileUtils.moveFileToDirectory(jar, destDir, true);
-      } else {
-        FileUtils.copyFileToDirectory(jar, destDir, true);
-      }
-      registerPlugin(destFile, false, true);
-
-    } catch (IOException e) {
-      LOG.error("Fail to move plugin: " + jar.getAbsolutePath() + " to " + destDir.getAbsolutePath(), e);
-    }
-  }
-
-  private void loadCorePlugins() {
-    for (File file : fileSystem.getCorePlugins()) {
-      registerPlugin(file, true, false);
-    }
-  }
-
-  public void uninstall(String pluginKey) {
-    for (String key : getPluginReferential().findLastReleasesWithDependencies(pluginKey)) {
-      uninstallPlugin(key);
-    }
-  }
-
-  private void uninstallPlugin(String pluginKey) {
-    PluginMetadata metadata = pluginByKeys.get(pluginKey);
-    if ((metadata != null) && !metadata.isCore()) {
-      try {
-        File masterFile = new File(fileSystem.getUserPluginsDir(), metadata.getFile().getName());
-        FileUtils.moveFileToDirectory(masterFile, fileSystem.getRemovedPluginsDir(), true);
-      } catch (IOException e) {
-        throw new IllegalStateException("Fail to uninstall plugin: " + pluginKey, e);
-      }
-    }
-  }
-
-  public List<String> getUninstalls() {
-    List<String> names = Lists.newArrayList();
-    if (fileSystem.getRemovedPluginsDir().exists()) {
-      List<File> files = (List<File>) FileUtils.listFiles(fileSystem.getRemovedPluginsDir(), new String[] {"jar"}, false);
-      for (File file : files) {
-        names.add(file.getName());
-      }
-    }
-    return names;
-  }
-
-  public void cancelUninstalls() {
-    if (fileSystem.getRemovedPluginsDir().exists()) {
-      List<File> files = (List<File>) FileUtils.listFiles(fileSystem.getRemovedPluginsDir(), new String[] {"jar"}, false);
-      for (File file : files) {
-        try {
-          FileUtils.moveFileToDirectory(file, fileSystem.getUserPluginsDir(), false);
-        } catch (IOException e) {
-          throw new IllegalStateException("Fail to cancel plugin uninstalls", e);
-        }
-      }
-    }
-  }
-
-  private void deployPlugins() {
-    for (PluginMetadata metadata : pluginByKeys.values()) {
-      deploy((DefaultPluginMetadata) metadata);
-    }
-  }
-
-  private void deploy(DefaultPluginMetadata plugin) {
-    LOG.info("Deploy plugin {}", Joiner.on(" / ").skipNulls().join(plugin.getName(), plugin.getVersion(), plugin.getImplementationBuild()));
-
-    Preconditions.checkState(plugin.isCompatibleWith(server.getVersion()),
-      "Plugin %s needs a more recent version of SonarQube than %s. At least %s is expected",
-      plugin.getKey(), server.getVersion(), plugin.getSonarVersion());
-
-    try {
-      File pluginDeployDir = new File(fileSystem.getDeployedPluginsDir(), plugin.getKey());
-      FileUtils.forceMkdir(pluginDeployDir);
-      FileUtils.cleanDirectory(pluginDeployDir);
-
-      installer.installToDir(plugin, pluginDeployDir);
-    } catch (IOException e) {
-      throw new IllegalStateException("Fail to deploy the plugin " + plugin, e);
-    }
-  }
-
-  public Collection<PluginMetadata> getMetadata() {
-    return pluginByKeys.values();
-  }
-
-  public PluginMetadata getMetadata(String pluginKey) {
-    return pluginByKeys.get(pluginKey);
-  }
-
-  private PluginReferential getPluginReferential() {
-    return PluginReferentialMetadataConverter.getInstalledPluginReferential(getMetadata());
-  }
-}
index d96c32e04ac256f051b68e35dce596f5e1a64adf..71ea2d05e965d6c6adfa59b9a3801bc9c8ec12c7 100644 (file)
@@ -24,7 +24,6 @@ import org.apache.commons.lang.StringUtils;
 import org.picocontainer.Startable;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.sonar.api.ServerComponent;
 import org.sonar.api.utils.HttpDownloader;
 import org.sonar.api.utils.SonarException;
 import org.sonar.server.platform.DefaultServerFileSystem;
@@ -39,7 +38,7 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 
-public class PluginDownloader implements ServerComponent, Startable {
+public class PluginDownloader implements Startable {
 
   private static final Logger LOG = LoggerFactory.getLogger(PluginDownloader.class);
   private static final String TMP_SUFFIX = "tmp";
index 1432be8d124b87d9534cc921a332b58c36057166..c084470711cb7a44d87b785f66cbff5da6bbc041 100644 (file)
@@ -41,7 +41,7 @@ public class ServerExtensionInstaller {
     this.pluginRepository = pluginRepository;
   }
 
-  public void registerExtensions(ComponentContainer container) {
+  public void installExtensions(ComponentContainer container) {
     ListMultimap<PluginMetadata, Object> installedExtensionsByPlugin = ArrayListMultimap.create();
 
     for (PluginMetadata pluginMetadata : pluginRepository.getMetadata()) {
diff --git a/sonar-server/src/main/java/org/sonar/server/plugins/ServerPluginInstaller.java b/sonar-server/src/main/java/org/sonar/server/plugins/ServerPluginInstaller.java
deleted file mode 100644 (file)
index 566972c..0000000
+++ /dev/null
@@ -1,63 +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.server.plugins;
-
-import org.apache.commons.io.FileUtils;
-import org.sonar.api.ServerComponent;
-import org.sonar.api.utils.SonarException;
-import org.sonar.api.utils.ZipUtils;
-import org.sonar.core.plugins.DefaultPluginMetadata;
-import org.sonar.core.plugins.PluginInstaller;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.zip.ZipEntry;
-
-public class ServerPluginInstaller extends PluginInstaller implements ServerComponent {
-
-  public void installToDir(DefaultPluginMetadata metadata, File pluginBasedir) {
-    try {
-      File pluginFile = metadata.getFile();
-      File deployedPlugin = copyPlugin(pluginBasedir, pluginFile);
-      install(metadata, pluginBasedir, deployedPlugin);
-    } catch (IOException e) {
-      throw new SonarException(FAIL_TO_INSTALL_PLUGIN + metadata, e);
-    }
-  }
-
-  private File copyPlugin(File pluginBasedir, File pluginFile) throws IOException {
-    FileUtils.forceMkdir(pluginBasedir);
-    File targetFile = new File(pluginBasedir, pluginFile.getName());
-    FileUtils.copyFile(pluginFile, targetFile);
-    return targetFile;
-  }
-
-  @Override
-  protected File extractPluginDependencies(File pluginFile, File pluginBasedir) throws IOException {
-    ZipUtils.unzip(pluginFile, pluginBasedir, new LibFilter());
-    return pluginBasedir;
-  }
-
-  private static final class LibFilter implements ZipUtils.ZipEntryFilter {
-    public boolean accept(ZipEntry entry) {
-      return entry.getName().startsWith("META-INF/lib");
-    }
-  }
-}
diff --git a/sonar-server/src/main/java/org/sonar/server/plugins/ServerPluginJarInstaller.java b/sonar-server/src/main/java/org/sonar/server/plugins/ServerPluginJarInstaller.java
new file mode 100644 (file)
index 0000000..12d1566
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * 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.server.plugins;
+
+import org.apache.commons.io.FileUtils;
+import org.sonar.api.utils.ZipUtils;
+import org.sonar.core.plugins.DefaultPluginMetadata;
+import org.sonar.core.plugins.PluginJarInstaller;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.zip.ZipEntry;
+
+public class ServerPluginJarInstaller extends PluginJarInstaller {
+
+  public void installToDir(DefaultPluginMetadata metadata, File pluginBasedir) {
+    try {
+      File pluginFile = metadata.getFile();
+      File deployedPlugin = copyPlugin(pluginBasedir, pluginFile);
+      install(metadata, pluginBasedir, deployedPlugin);
+    } catch (IOException e) {
+      throw new IllegalStateException(FAIL_TO_INSTALL_PLUGIN + metadata, e);
+    }
+  }
+
+  private File copyPlugin(File pluginBasedir, File pluginFile) throws IOException {
+    FileUtils.forceMkdir(pluginBasedir);
+    File targetFile = new File(pluginBasedir, pluginFile.getName());
+    FileUtils.copyFile(pluginFile, targetFile);
+    return targetFile;
+  }
+
+  @Override
+  protected File extractPluginDependencies(File pluginFile, File pluginBasedir) throws IOException {
+    ZipUtils.unzip(pluginFile, pluginBasedir, new LibFilter());
+    return pluginBasedir;
+  }
+
+  private static final class LibFilter implements ZipUtils.ZipEntryFilter {
+    public boolean accept(ZipEntry entry) {
+      return entry.getName().startsWith("META-INF/lib");
+    }
+  }
+}
diff --git a/sonar-server/src/main/java/org/sonar/server/plugins/ServerPluginJarsInstaller.java b/sonar-server/src/main/java/org/sonar/server/plugins/ServerPluginJarsInstaller.java
new file mode 100644 (file)
index 0000000..e681b0a
--- /dev/null
@@ -0,0 +1,229 @@
+/*
+ * 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.server.plugins;
+
+import com.google.common.base.Joiner;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.sonar.api.platform.PluginMetadata;
+import org.sonar.api.platform.Server;
+import org.sonar.api.platform.ServerUpgradeStatus;
+import org.sonar.api.utils.TimeProfiler;
+import org.sonar.core.plugins.DefaultPluginMetadata;
+import org.sonar.server.platform.DefaultServerFileSystem;
+import org.sonar.updatecenter.common.PluginReferential;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+public class ServerPluginJarsInstaller {
+
+  private static final Logger LOG = LoggerFactory.getLogger(ServerPluginJarsInstaller.class);
+
+  private final Server server;
+  private final DefaultServerFileSystem fileSystem;
+  private final ServerPluginJarInstaller installer;
+  private final Map<String, PluginMetadata> pluginByKeys = Maps.newHashMap();
+  private final ServerUpgradeStatus serverUpgradeStatus;
+
+  public ServerPluginJarsInstaller(Server server, ServerUpgradeStatus serverUpgradeStatus,
+                                   DefaultServerFileSystem fileSystem, ServerPluginJarInstaller installer) {
+    this.server = server;
+    this.serverUpgradeStatus = serverUpgradeStatus;
+    this.fileSystem = fileSystem;
+    this.installer = installer;
+  }
+
+  public void install() {
+    TimeProfiler profiler = new TimeProfiler().start("Install plugins");
+    deleteUninstalledPlugins();
+    loadUserPlugins();
+    if (serverUpgradeStatus.isFreshInstall()) {
+      copyAndLoadBundledPlugins();
+    }
+    moveAndLoadDownloadedPlugins();
+    loadCorePlugins();
+    deployPlugins();
+    profiler.stop();
+  }
+
+  private void deleteUninstalledPlugins() {
+    File trashDir = fileSystem.getRemovedPluginsDir();
+    try {
+      if (trashDir.exists()) {
+        FileUtils.deleteDirectory(trashDir);
+      }
+    } catch (IOException e) {
+      throw new IllegalStateException("Fail to clean the plugin trash directory: " + trashDir, e);
+    }
+  }
+
+  private void loadUserPlugins() {
+    for (File file : fileSystem.getUserPlugins()) {
+      registerPlugin(file, false, false);
+    }
+  }
+
+  private void registerPlugin(File file, boolean isCore, boolean canDelete) {
+    DefaultPluginMetadata metadata = installer.extractMetadata(file, isCore);
+    if (StringUtils.isBlank(metadata.getKey())) {
+      return;
+    }
+
+    PluginMetadata existing = pluginByKeys.put(metadata.getKey(), metadata);
+
+    if ((existing != null) && !canDelete) {
+      throw new IllegalStateException("Found two plugins with the same key '" + metadata.getKey() + "': " + metadata.getFile().getName() + " and "
+        + existing.getFile().getName());
+    }
+
+    if (existing != null) {
+      FileUtils.deleteQuietly(existing.getFile());
+      LOG.info("Plugin " + metadata.getKey() + " replaced by new version");
+    }
+  }
+
+  private void moveAndLoadDownloadedPlugins() {
+    if (fileSystem.getDownloadedPluginsDir().exists()) {
+      Collection<File> jars = FileUtils.listFiles(fileSystem.getDownloadedPluginsDir(), new String[]{"jar"}, false);
+      for (File jar : jars) {
+        installJarPlugin(jar, true);
+      }
+    }
+  }
+
+  private void copyAndLoadBundledPlugins() {
+    for (File plugin : fileSystem.getBundledPlugins()) {
+      installJarPlugin(plugin, false);
+    }
+  }
+
+  private void installJarPlugin(File jar, boolean deleteSource) {
+    File destDir = fileSystem.getUserPluginsDir();
+    File destFile = new File(destDir, jar.getName());
+    if (destFile.exists()) {
+      // plugin with same filename already installed
+      FileUtils.deleteQuietly(jar);
+    }
+    try {
+      if (deleteSource) {
+        FileUtils.moveFileToDirectory(jar, destDir, true);
+      } else {
+        FileUtils.copyFileToDirectory(jar, destDir, true);
+      }
+      registerPlugin(destFile, false, true);
+
+    } catch (IOException e) {
+      LOG.error("Fail to move plugin: " + jar.getAbsolutePath() + " to " + destDir.getAbsolutePath(), e);
+    }
+  }
+
+  private void loadCorePlugins() {
+    for (File file : fileSystem.getCorePlugins()) {
+      registerPlugin(file, true, false);
+    }
+  }
+
+  public void uninstall(String pluginKey) {
+    for (String key : getPluginReferential().findLastReleasesWithDependencies(pluginKey)) {
+      uninstallPlugin(key);
+    }
+  }
+
+  private void uninstallPlugin(String pluginKey) {
+    PluginMetadata metadata = pluginByKeys.get(pluginKey);
+    if ((metadata != null) && !metadata.isCore()) {
+      try {
+        File masterFile = new File(fileSystem.getUserPluginsDir(), metadata.getFile().getName());
+        FileUtils.moveFileToDirectory(masterFile, fileSystem.getRemovedPluginsDir(), true);
+      } catch (IOException e) {
+        throw new IllegalStateException("Fail to uninstall plugin: " + pluginKey, e);
+      }
+    }
+  }
+
+  public List<String> getUninstalls() {
+    List<String> names = Lists.newArrayList();
+    if (fileSystem.getRemovedPluginsDir().exists()) {
+      List<File> files = (List<File>) FileUtils.listFiles(fileSystem.getRemovedPluginsDir(), new String[]{"jar"}, false);
+      for (File file : files) {
+        names.add(file.getName());
+      }
+    }
+    return names;
+  }
+
+  public void cancelUninstalls() {
+    if (fileSystem.getRemovedPluginsDir().exists()) {
+      List<File> files = (List<File>) FileUtils.listFiles(fileSystem.getRemovedPluginsDir(), new String[]{"jar"}, false);
+      for (File file : files) {
+        try {
+          FileUtils.moveFileToDirectory(file, fileSystem.getUserPluginsDir(), false);
+        } catch (IOException e) {
+          throw new IllegalStateException("Fail to cancel plugin uninstalls", e);
+        }
+      }
+    }
+  }
+
+  private void deployPlugins() {
+    for (PluginMetadata metadata : pluginByKeys.values()) {
+      deploy((DefaultPluginMetadata) metadata);
+    }
+  }
+
+  private void deploy(DefaultPluginMetadata plugin) {
+    LOG.info("Deploy plugin {}", Joiner.on(" / ").skipNulls().join(plugin.getName(), plugin.getVersion(), plugin.getImplementationBuild()));
+
+    Preconditions.checkState(plugin.isCompatibleWith(server.getVersion()),
+      "Plugin %s needs a more recent version of SonarQube than %s. At least %s is expected",
+      plugin.getKey(), server.getVersion(), plugin.getSonarVersion());
+
+    try {
+      File pluginDeployDir = new File(fileSystem.getDeployedPluginsDir(), plugin.getKey());
+      FileUtils.forceMkdir(pluginDeployDir);
+      FileUtils.cleanDirectory(pluginDeployDir);
+
+      installer.installToDir(plugin, pluginDeployDir);
+    } catch (IOException e) {
+      throw new IllegalStateException("Fail to deploy the plugin " + plugin, e);
+    }
+  }
+
+  public Collection<PluginMetadata> getMetadata() {
+    return pluginByKeys.values();
+  }
+
+  public PluginMetadata getMetadata(String pluginKey) {
+    return pluginByKeys.get(pluginKey);
+  }
+
+  private PluginReferential getPluginReferential() {
+    return PluginReferentialMetadataConverter.getInstalledPluginReferential(getMetadata());
+  }
+}
diff --git a/sonar-server/src/main/java/org/sonar/server/plugins/ServerPluginRepository.java b/sonar-server/src/main/java/org/sonar/server/plugins/ServerPluginRepository.java
new file mode 100644 (file)
index 0000000..71ab9c4
--- /dev/null
@@ -0,0 +1,94 @@
+/*
+ * 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.server.plugins;
+
+import org.picocontainer.Startable;
+import org.slf4j.LoggerFactory;
+import org.sonar.api.Plugin;
+import org.sonar.api.platform.PluginMetadata;
+import org.sonar.api.platform.PluginRepository;
+import org.sonar.core.plugins.PluginClassloaders;
+
+import javax.annotation.CheckForNull;
+import java.util.Collection;
+import java.util.Map;
+
+/**
+ * This class loads JAR files and initializes classloaders of plugins
+ */
+public class ServerPluginRepository implements PluginRepository, Startable {
+
+  private final ServerPluginJarsInstaller jarsInstaller;
+  private final PluginClassloaders classloaders;
+  private Map<String, Plugin> pluginsByKey;
+
+  public ServerPluginRepository(ServerPluginJarsInstaller jarsInstaller) {
+    this.classloaders = new PluginClassloaders(getClass().getClassLoader());
+    this.jarsInstaller = jarsInstaller;
+  }
+
+  @Override
+  public void start() {
+    jarsInstaller.install();
+    Collection<PluginMetadata> metadata = jarsInstaller.getMetadata();
+    pluginsByKey = classloaders.init(metadata);
+  }
+
+  @Override
+  public void stop() {
+    classloaders.clean();
+  }
+
+  @Override
+  public Plugin getPlugin(String key) {
+    return pluginsByKey.get(key);
+  }
+
+  @CheckForNull
+  public ClassLoader getClassLoader(String pluginKey) {
+    return classloaders.get(pluginKey);
+  }
+
+  @CheckForNull
+  public Class getClass(String pluginKey, String classname) {
+    Class clazz = null;
+    ClassLoader classloader = getClassLoader(pluginKey);
+    if (classloader != null) {
+      try {
+        clazz = classloader.loadClass(classname);
+
+      } catch (ClassNotFoundException e) {
+        LoggerFactory.getLogger(getClass()).warn("Class not found in plugin " + pluginKey + ": " + classname, e);
+      }
+    }
+    return clazz;
+  }
+
+  @Override
+  public Collection<PluginMetadata> getMetadata() {
+    return jarsInstaller.getMetadata();
+  }
+
+  @Override
+  public PluginMetadata getMetadata(String pluginKey) {
+    return jarsInstaller.getMetadata(pluginKey);
+  }
+
+}
index 171205ae82e54d16e4b5a39863b403e542930309..41e0d2a457010c2e4177c984fa005ae461f2df24 100644 (file)
@@ -44,7 +44,7 @@ public class StaticResourcesServlet extends HttpServlet {
     String pluginKey = getPluginKey(request);
     String resource = getResourcePath(request);
 
-    DefaultServerPluginRepository pluginRepository = Platform.getInstance().getContainer().getComponentByType(DefaultServerPluginRepository.class);
+    ServerPluginRepository pluginRepository = Platform.getInstance().getContainer().getComponentByType(ServerPluginRepository.class);
     ClassLoader classLoader = pluginRepository.getClassLoader(pluginKey);
     if (classLoader == null) {
       LOG.error("Plugin not found: " + pluginKey);
index 44f5b9207e74de3bc324abc0e3d7a19ed6f7677c..e1374abdee09f2adf8ee56cd0fee29324242d79a 100644 (file)
@@ -25,7 +25,6 @@ import org.slf4j.LoggerFactory;
 import org.sonar.api.Properties;
 import org.sonar.api.Property;
 import org.sonar.api.PropertyType;
-import org.sonar.api.ServerComponent;
 import org.sonar.api.config.Settings;
 import org.sonar.api.utils.UriReader;
 import org.sonar.updatecenter.common.UpdateCenter;
@@ -43,32 +42,33 @@ import java.util.Date;
  * @since 2.4
  */
 @Properties({
-    @Property(
-        key = "sonar.updatecenter.activate",
-        defaultValue = "true",
-        name = "Enable Update Center",
-        project = false,
-      // hidden from UI
-        global = false,
-        category = "Update Center",
-        type = PropertyType.BOOLEAN),
-    @Property(
-        key = UpdateCenterClient.URL_PROPERTY,
-        defaultValue = "http://update.sonarsource.org/update-center.properties",
-        name = "Update Center URL",
-        project = false,
-      // hidden from UI
-        global = false,
-        category = "Update Center")
+  @Property(
+    key = "sonar.updatecenter.activate",
+    defaultValue = "true",
+    name = "Enable Update Center",
+    project = false,
+    // hidden from UI
+    global = false,
+    category = "Update Center",
+    type = PropertyType.BOOLEAN),
+  @Property(
+    key = UpdateCenterClient.URL_PROPERTY,
+    defaultValue = "http://update.sonarsource.org/update-center.properties",
+    name = "Update Center URL",
+    project = false,
+    // hidden from UI
+    global = false,
+    category = "Update Center")
 })
-public class UpdateCenterClient implements ServerComponent {
+public class UpdateCenterClient {
 
   public static final String URL_PROPERTY = "sonar.updatecenter.url";
   public static final int PERIOD_IN_MILLISECONDS = 60 * 60 * 1000;
-  private URI uri;
+
+  private final URI uri;
+  private final UriReader uriReader;
   private UpdateCenter pluginCenter = null;
   private long lastRefreshDate = 0;
-  private UriReader uriReader;
 
   public UpdateCenterClient(UriReader uriReader, Settings settings) throws URISyntaxException {
     this.uriReader = uriReader;
index 31a4c1b35d92bcbc3ec0c45bdb356d91f1861d40..b793b88cf7749475c7ec09dc8f70d9bfed696981 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.server.plugins;
 
-import org.sonar.api.ServerComponent;
 import org.sonar.api.platform.Server;
 import org.sonar.updatecenter.common.UpdateCenter;
 import org.sonar.updatecenter.common.Version;
@@ -27,7 +26,7 @@ import org.sonar.updatecenter.common.Version;
 /**
  * @since 2.4
  */
-public class UpdateCenterMatrixFactory implements ServerComponent {
+public class UpdateCenterMatrixFactory {
 
   private final UpdateCenterClient centerClient;
   private final Version sonarVersion;
index e64eff95feee4b40e84d37a50a0868ace1231351..bd8bf72af015685f5dd0acc5c85f3a6a354595e5 100644 (file)
@@ -57,7 +57,6 @@ import org.sonar.updatecenter.common.Version;
 
 import javax.annotation.CheckForNull;
 import javax.annotation.Nullable;
-import java.io.File;
 import java.io.IOException;
 import java.net.InetAddress;
 import java.sql.Connection;
@@ -149,15 +148,15 @@ public final class JRubyFacade {
   }
 
   public void uninstallPlugin(String pluginKey) {
-    get(PluginDeployer.class).uninstall(pluginKey);
+    get(ServerPluginJarsInstaller.class).uninstall(pluginKey);
   }
 
   public void cancelPluginUninstalls() {
-    get(PluginDeployer.class).cancelUninstalls();
+    get(ServerPluginJarsInstaller.class).cancelUninstalls();
   }
 
   public List<String> getPluginUninstalls() {
-    return get(PluginDeployer.class).getUninstalls();
+    return get(ServerPluginJarsInstaller.class).getUninstalls();
   }
 
   public UpdateCenter getUpdatePluginCenter(boolean forceReload) {
@@ -304,7 +303,7 @@ public final class JRubyFacade {
 
   public Object getComponentByClassname(String pluginKey, String className) {
     Object component = null;
-    Class<?> componentClass = get(DefaultServerPluginRepository.class).getClass(pluginKey, className);
+    Class<?> componentClass = get(ServerPluginRepository.class).getClass(pluginKey, className);
     if (componentClass != null) {
       component = get(componentClass);
     }
diff --git a/sonar-server/src/test/java/org/sonar/server/plugins/DefaultServerPluginRepositoryTest.java b/sonar-server/src/test/java/org/sonar/server/plugins/DefaultServerPluginRepositoryTest.java
deleted file mode 100644 (file)
index 6a6f943..0000000
+++ /dev/null
@@ -1,67 +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.server.plugins;
-
-import org.junit.After;
-import org.junit.Test;
-import org.sonar.api.platform.PluginMetadata;
-import org.sonar.core.plugins.DefaultPluginMetadata;
-import org.sonar.test.TestUtils;
-
-import java.io.File;
-import java.util.Arrays;
-
-import static org.hamcrest.CoreMatchers.nullValue;
-import static org.hamcrest.core.IsNot.not;
-import static org.junit.Assert.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class DefaultServerPluginRepositoryTest {
-
-  DefaultServerPluginRepository repository;
-
-  @After
-  public void stop() {
-    if (repository != null) {
-      repository.stop();
-    }
-  }
-
-  @Test
-  public void testStart() {
-    PluginDeployer deployer = mock(PluginDeployer.class);
-    File pluginFile = TestUtils.getResource("/org/sonar/server/plugins/DefaultServerPluginRepositoryTest/sonar-artifact-size-plugin-0.2.jar");
-    PluginMetadata plugin = DefaultPluginMetadata.create(pluginFile)
-      .setKey("artifactsize")
-      .setMainClass("org.sonar.plugins.artifactsize.ArtifactSizePlugin")
-      .addDeployedFile(pluginFile);
-    when(deployer.getMetadata()).thenReturn(Arrays.asList(plugin));
-
-    repository = new DefaultServerPluginRepository(deployer);
-    repository.start();
-
-    assertThat(repository.getPlugin("artifactsize"), not(nullValue()));
-    assertThat(repository.getClassLoader("artifactsize"), not(nullValue()));
-    assertThat(repository.getClass("artifactsize", "org.sonar.plugins.artifactsize.ArtifactSizeMetrics"), not(nullValue()));
-    assertThat(repository.getClass("artifactsize", "org.Unknown"), nullValue());
-    assertThat(repository.getClass("other", "org.sonar.plugins.artifactsize.ArtifactSizeMetrics"), nullValue());
-  }
-}
diff --git a/sonar-server/src/test/java/org/sonar/server/plugins/PluginDeployerTest.java b/sonar-server/src/test/java/org/sonar/server/plugins/PluginDeployerTest.java
deleted file mode 100644 (file)
index f2bb3dc..0000000
+++ /dev/null
@@ -1,127 +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.server.plugins;
-
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.junit.rules.TestName;
-import org.sonar.api.platform.PluginMetadata;
-import org.sonar.api.platform.Server;
-import org.sonar.api.platform.ServerUpgradeStatus;
-import org.sonar.server.platform.DefaultServerFileSystem;
-import org.sonar.test.TestUtils;
-
-import java.io.File;
-
-import static org.fest.assertions.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class PluginDeployerTest {
-
-  @Rule
-  public TestName name = new TestName();
-  @Rule
-  public ExpectedException exception = ExpectedException.none();
-  private ServerPluginInstaller extractor;
-  private DefaultServerFileSystem fileSystem;
-  private File homeDir;
-  private File deployDir;
-  private PluginDeployer deployer;
-  private Server server = mock(Server.class);
-  private ServerUpgradeStatus serverUpgradeStatus;
-
-  @Before
-  public void start() {
-    when(server.getVersion()).thenReturn("3.1");
-    homeDir = TestUtils.getResource(PluginDeployerTest.class, name.getMethodName());
-    deployDir = TestUtils.getTestTempDir(PluginDeployerTest.class, name.getMethodName() + "/deploy");
-    fileSystem = new DefaultServerFileSystem(null, homeDir, deployDir);
-    extractor = new ServerPluginInstaller();
-    serverUpgradeStatus = mock(ServerUpgradeStatus.class);
-    deployer = new PluginDeployer(server, serverUpgradeStatus, fileSystem, extractor);
-  }
-
-  @Test
-  public void deployPlugin() {
-    when(serverUpgradeStatus.isFreshInstall()).thenReturn(false);
-
-    deployer.start();
-
-    // check that the plugin is registered
-    assertThat(deployer.getMetadata()).hasSize(1);
-
-    PluginMetadata plugin = deployer.getMetadata("foo");
-    assertThat(plugin.getName()).isEqualTo("Foo");
-    assertThat(plugin.getDeployedFiles()).hasSize(1);
-    assertThat(plugin.isCore()).isFalse();
-    assertThat(plugin.isUseChildFirstClassLoader()).isFalse();
-
-    // check that the file is deployed
-    File deployedJar = new File(deployDir, "plugins/foo/foo-plugin.jar");
-    assertThat(deployedJar).exists();
-    assertThat(deployedJar).isFile();
-  }
-
-  @Test
-  public void deployBundledPluginsOnFreshInstall() {
-    when(serverUpgradeStatus.isFreshInstall()).thenReturn(true);
-
-    deployer.start();
-
-    // check that the plugin is registered
-    assertThat(deployer.getMetadata()).hasSize(2);
-
-    PluginMetadata plugin = deployer.getMetadata("bar");
-    assertThat(plugin.getName()).isEqualTo("Bar");
-    assertThat(plugin.getDeployedFiles()).hasSize(1);
-    assertThat(plugin.isCore()).isFalse();
-    assertThat(plugin.isUseChildFirstClassLoader()).isFalse();
-
-    // check that the file is deployed
-    File deployedJar = new File(deployDir, "plugins/bar/bar-plugin.jar");
-    assertThat(deployedJar).exists();
-    assertThat(deployedJar).isFile();
-  }
-
-  @Test
-  public void ignoreJarsWhichAreNotPlugins() {
-    deployer.start();
-
-    assertThat(deployer.getMetadata()).isEmpty();
-  }
-
-  @Test
-  public void should_fail_on_plugin_depending_on_more_recent_sonar() {
-    when(server.getVersion()).thenReturn("2.0");
-
-    exception.expect(IllegalStateException.class);
-    exception.expectMessage("Plugin switchoffviolations needs a more recent version of SonarQube than 2.0. At least 2.5 is expected");
-
-    deployer.start();
-  }
-
-  @Test(expected = IllegalStateException.class)
-  public void failIfTwoPluginsWithSameKey() {
-    deployer.start();
-  }
-}
diff --git a/sonar-server/src/test/java/org/sonar/server/plugins/ServerExtensionInstallerTest.java b/sonar-server/src/test/java/org/sonar/server/plugins/ServerExtensionInstallerTest.java
deleted file mode 100644 (file)
index 7e4d498..0000000
+++ /dev/null
@@ -1,102 +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.server.plugins;
-
-import org.junit.Test;
-import org.sonar.api.BatchExtension;
-import org.sonar.api.ExtensionProvider;
-import org.sonar.api.ServerExtension;
-import org.sonar.api.SonarPlugin;
-
-import java.util.Arrays;
-import java.util.List;
-
-public class ServerExtensionInstallerTest {
-  @Test
-  public void shouldRegisterServerExtensions() {
-//    ExtensionRegistrar repository = new ExtensionRegistrar(mock(PluginRepository.class));
-//
-//    ComponentContainer container = new ComponentContainer();
-//    repository.registerExtensions(container, Arrays.<Plugin>asList(new FakePlugin(Arrays.<Class>asList(FakeBatchExtension.class, FakeServerExtension.class))));
-//
-//    assertThat(container.getComponentsByType(Extension.class).size(), is(1));
-//    assertThat(container.getComponentsByType(FakeServerExtension.class).size(), is(1));
-//    assertThat(container.getComponentsByType(FakeBatchExtension.class).size(), is(0));
-  }
-
-  @Test
-  public void shouldInvokeServerExtensionProviders() {
-//    DefaultServerPluginRepository repository = new DefaultServerPluginRepository(mock(PluginDeployer.class));
-//
-//    ComponentContainer container = new ComponentContainer();
-//    repository.registerExtensions(container, Arrays.<Plugin>asList(new FakePlugin(Arrays.<Class>asList(FakeExtensionProvider.class))));
-//
-//    assertThat(container.getComponentsByType(Extension.class).size(), is(2));// provider + FakeServerExtension
-//    assertThat(container.getComponentsByType(FakeServerExtension.class).size(), is(1));
-//    assertThat(container.getComponentsByType(FakeBatchExtension.class).size(), is(0));
-  }
-
-  @Test
-  public void shouldNotSupportProvidersOfProviders() {
-//    DefaultServerPluginRepository repository = new DefaultServerPluginRepository(mock(PluginDeployer.class));
-//
-//    ComponentContainer container = new ComponentContainer();
-//    repository.registerExtensions(container, Arrays.<Plugin>asList(new FakePlugin(Arrays.<Class>asList(SuperExtensionProvider.class))));
-//
-//    assertThat(container.getComponentsByType(FakeBatchExtension.class).size(), is(0));
-//    assertThat(container.getComponentsByType(FakeServerExtension.class).size(), is(0));
-  }
-
-  public static class FakePlugin extends SonarPlugin {
-    private List<Class> extensions;
-
-    public FakePlugin(List<Class> extensions) {
-      this.extensions = extensions;
-    }
-
-    public List<Class> getExtensions() {
-      return extensions;
-    }
-  }
-
-  public static class FakeBatchExtension implements BatchExtension {
-
-  }
-
-  public static class FakeServerExtension implements ServerExtension {
-
-  }
-
-  public static class FakeExtensionProvider extends ExtensionProvider implements ServerExtension {
-
-    @Override
-    public Object provide() {
-      return Arrays.<Object> asList(FakeBatchExtension.class, FakeServerExtension.class);
-    }
-  }
-
-  public static class SuperExtensionProvider extends ExtensionProvider implements ServerExtension {
-
-    @Override
-    public Object provide() {
-      return FakeExtensionProvider.class;
-    }
-  }
-}
diff --git a/sonar-server/src/test/java/org/sonar/server/plugins/ServerPluginJarsInstallerTest.java b/sonar-server/src/test/java/org/sonar/server/plugins/ServerPluginJarsInstallerTest.java
new file mode 100644 (file)
index 0000000..6ceb010
--- /dev/null
@@ -0,0 +1,129 @@
+/*
+ * 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.server.plugins;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.junit.rules.TestName;
+import org.sonar.api.platform.PluginMetadata;
+import org.sonar.api.platform.Server;
+import org.sonar.api.platform.ServerUpgradeStatus;
+import org.sonar.server.platform.DefaultServerFileSystem;
+import org.sonar.test.TestUtils;
+
+import java.io.File;
+
+import static org.fest.assertions.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class ServerPluginJarsInstallerTest {
+
+  @Rule
+  public TestName name = new TestName();
+
+  @Rule
+  public ExpectedException exception = ExpectedException.none();
+
+  ServerPluginJarInstaller jarInstaller;
+  DefaultServerFileSystem fileSystem;
+  File homeDir;
+  File deployDir;
+  ServerPluginJarsInstaller jarsInstaller;
+  Server server = mock(Server.class);
+  ServerUpgradeStatus serverUpgradeStatus;
+
+  @Before
+  public void before() {
+    when(server.getVersion()).thenReturn("3.1");
+    homeDir = TestUtils.getResource(ServerPluginJarsInstallerTest.class, name.getMethodName());
+    deployDir = TestUtils.getTestTempDir(ServerPluginJarsInstallerTest.class, name.getMethodName() + "/deploy");
+    fileSystem = new DefaultServerFileSystem(null, homeDir, deployDir);
+    jarInstaller = new ServerPluginJarInstaller();
+    serverUpgradeStatus = mock(ServerUpgradeStatus.class);
+    jarsInstaller = new ServerPluginJarsInstaller(server, serverUpgradeStatus, fileSystem, jarInstaller);
+  }
+
+  @Test
+  public void deployPlugin() {
+    when(serverUpgradeStatus.isFreshInstall()).thenReturn(false);
+
+    jarsInstaller.install();
+
+    // check that the plugin is registered
+    assertThat(jarsInstaller.getMetadata()).hasSize(1);
+
+    PluginMetadata plugin = jarsInstaller.getMetadata("foo");
+    assertThat(plugin.getName()).isEqualTo("Foo");
+    assertThat(plugin.getDeployedFiles()).hasSize(1);
+    assertThat(plugin.isCore()).isFalse();
+    assertThat(plugin.isUseChildFirstClassLoader()).isFalse();
+
+    // check that the file is deployed
+    File deployedJar = new File(deployDir, "plugins/foo/foo-plugin.jar");
+    assertThat(deployedJar).exists();
+    assertThat(deployedJar).isFile();
+  }
+
+  @Test
+  public void deployBundledPluginsOnFreshInstall() {
+    when(serverUpgradeStatus.isFreshInstall()).thenReturn(true);
+
+    jarsInstaller.install();
+
+    // check that the plugin is registered
+    assertThat(jarsInstaller.getMetadata()).hasSize(2);
+
+    PluginMetadata plugin = jarsInstaller.getMetadata("bar");
+    assertThat(plugin.getName()).isEqualTo("Bar");
+    assertThat(plugin.getDeployedFiles()).hasSize(1);
+    assertThat(plugin.isCore()).isFalse();
+    assertThat(plugin.isUseChildFirstClassLoader()).isFalse();
+
+    // check that the file is deployed
+    File deployedJar = new File(deployDir, "plugins/bar/bar-plugin.jar");
+    assertThat(deployedJar).exists();
+    assertThat(deployedJar).isFile();
+  }
+
+  @Test
+  public void ignoreJarsWhichAreNotPlugins() {
+    jarsInstaller.install();
+
+    assertThat(jarsInstaller.getMetadata()).isEmpty();
+  }
+
+  @Test
+  public void should_fail_on_plugin_depending_on_more_recent_sonar() {
+    when(server.getVersion()).thenReturn("2.0");
+
+    exception.expect(IllegalStateException.class);
+    exception.expectMessage("Plugin switchoffviolations needs a more recent version of SonarQube than 2.0. At least 2.5 is expected");
+
+    jarsInstaller.install();
+  }
+
+  @Test(expected = IllegalStateException.class)
+  public void failIfTwoPluginsWithSameKey() {
+    jarsInstaller.install();
+  }
+}
diff --git a/sonar-server/src/test/java/org/sonar/server/plugins/ServerPluginRepositoryTest.java b/sonar-server/src/test/java/org/sonar/server/plugins/ServerPluginRepositoryTest.java
new file mode 100644 (file)
index 0000000..3e4898d
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * 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.server.plugins;
+
+import org.junit.After;
+import org.junit.Test;
+import org.sonar.api.platform.PluginMetadata;
+import org.sonar.core.plugins.DefaultPluginMetadata;
+import org.sonar.test.TestUtils;
+
+import java.io.File;
+import java.util.Arrays;
+
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.hamcrest.core.IsNot.not;
+import static org.junit.Assert.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class ServerPluginRepositoryTest {
+
+  ServerPluginRepository repository;
+
+  @After
+  public void stop() {
+    if (repository != null) {
+      repository.stop();
+    }
+  }
+
+  @Test
+  public void testStart() {
+    ServerPluginJarsInstaller deployer = mock(ServerPluginJarsInstaller.class);
+    File pluginFile = TestUtils.getResource("/org/sonar/server/plugins/ServerPluginRepositoryTest/sonar-artifact-size-plugin-0.2.jar");
+    PluginMetadata plugin = DefaultPluginMetadata.create(pluginFile)
+      .setKey("artifactsize")
+      .setMainClass("org.sonar.plugins.artifactsize.ArtifactSizePlugin")
+      .addDeployedFile(pluginFile);
+    when(deployer.getMetadata()).thenReturn(Arrays.asList(plugin));
+
+    repository = new ServerPluginRepository(deployer);
+    repository.start();
+
+    assertThat(repository.getPlugin("artifactsize"), not(nullValue()));
+    assertThat(repository.getClassLoader("artifactsize"), not(nullValue()));
+    assertThat(repository.getClass("artifactsize", "org.sonar.plugins.artifactsize.ArtifactSizeMetrics"), not(nullValue()));
+    assertThat(repository.getClass("artifactsize", "org.Unknown"), nullValue());
+    assertThat(repository.getClass("other", "org.sonar.plugins.artifactsize.ArtifactSizeMetrics"), nullValue());
+  }
+}
diff --git a/sonar-server/src/test/resources/org/sonar/server/plugins/DefaultServerPluginRepositoryTest/sonar-artifact-size-plugin-0.2.jar b/sonar-server/src/test/resources/org/sonar/server/plugins/DefaultServerPluginRepositoryTest/sonar-artifact-size-plugin-0.2.jar
deleted file mode 100644 (file)
index 1953323..0000000
Binary files a/sonar-server/src/test/resources/org/sonar/server/plugins/DefaultServerPluginRepositoryTest/sonar-artifact-size-plugin-0.2.jar and /dev/null differ
diff --git a/sonar-server/src/test/resources/org/sonar/server/plugins/PluginDeployerTest/deployBundledPluginsOnFreshInstall/extensions/plugins/foo-plugin.jar b/sonar-server/src/test/resources/org/sonar/server/plugins/PluginDeployerTest/deployBundledPluginsOnFreshInstall/extensions/plugins/foo-plugin.jar
deleted file mode 100644 (file)
index 22ced8f..0000000
Binary files a/sonar-server/src/test/resources/org/sonar/server/plugins/PluginDeployerTest/deployBundledPluginsOnFreshInstall/extensions/plugins/foo-plugin.jar and /dev/null differ
diff --git a/sonar-server/src/test/resources/org/sonar/server/plugins/PluginDeployerTest/deployBundledPluginsOnFreshInstall/lib/bundled-plugins/bar-plugin.jar b/sonar-server/src/test/resources/org/sonar/server/plugins/PluginDeployerTest/deployBundledPluginsOnFreshInstall/lib/bundled-plugins/bar-plugin.jar
deleted file mode 100644 (file)
index acf4fa4..0000000
Binary files a/sonar-server/src/test/resources/org/sonar/server/plugins/PluginDeployerTest/deployBundledPluginsOnFreshInstall/lib/bundled-plugins/bar-plugin.jar and /dev/null differ
diff --git a/sonar-server/src/test/resources/org/sonar/server/plugins/PluginDeployerTest/deployPlugin/extensions/plugins/foo-plugin.jar b/sonar-server/src/test/resources/org/sonar/server/plugins/PluginDeployerTest/deployPlugin/extensions/plugins/foo-plugin.jar
deleted file mode 100644 (file)
index 22ced8f..0000000
Binary files a/sonar-server/src/test/resources/org/sonar/server/plugins/PluginDeployerTest/deployPlugin/extensions/plugins/foo-plugin.jar and /dev/null differ
diff --git a/sonar-server/src/test/resources/org/sonar/server/plugins/PluginDeployerTest/deployPlugin/lib/bundled-plugins/bar-plugin.jar b/sonar-server/src/test/resources/org/sonar/server/plugins/PluginDeployerTest/deployPlugin/lib/bundled-plugins/bar-plugin.jar
deleted file mode 100644 (file)
index acf4fa4..0000000
Binary files a/sonar-server/src/test/resources/org/sonar/server/plugins/PluginDeployerTest/deployPlugin/lib/bundled-plugins/bar-plugin.jar and /dev/null differ
diff --git a/sonar-server/src/test/resources/org/sonar/server/plugins/PluginDeployerTest/deployPluginExtensions/extensions/plugins/foo-plugin.jar b/sonar-server/src/test/resources/org/sonar/server/plugins/PluginDeployerTest/deployPluginExtensions/extensions/plugins/foo-plugin.jar
deleted file mode 100644 (file)
index 7bcf027..0000000
Binary files a/sonar-server/src/test/resources/org/sonar/server/plugins/PluginDeployerTest/deployPluginExtensions/extensions/plugins/foo-plugin.jar and /dev/null differ
diff --git a/sonar-server/src/test/resources/org/sonar/server/plugins/PluginDeployerTest/deployPluginExtensions/extensions/rules/foo/foo-extension.txt b/sonar-server/src/test/resources/org/sonar/server/plugins/PluginDeployerTest/deployPluginExtensions/extensions/rules/foo/foo-extension.txt
deleted file mode 100644 (file)
index d84be83..0000000
+++ /dev/null
@@ -1 +0,0 @@
-this is an extension to the plugin foo
\ No newline at end of file
diff --git a/sonar-server/src/test/resources/org/sonar/server/plugins/PluginDeployerTest/failIfTwoPluginsWithSameKey/extensions/plugins/foo-plugin1.jar b/sonar-server/src/test/resources/org/sonar/server/plugins/PluginDeployerTest/failIfTwoPluginsWithSameKey/extensions/plugins/foo-plugin1.jar
deleted file mode 100644 (file)
index 22ced8f..0000000
Binary files a/sonar-server/src/test/resources/org/sonar/server/plugins/PluginDeployerTest/failIfTwoPluginsWithSameKey/extensions/plugins/foo-plugin1.jar and /dev/null differ
diff --git a/sonar-server/src/test/resources/org/sonar/server/plugins/PluginDeployerTest/failIfTwoPluginsWithSameKey/extensions/plugins/foo-plugin2.jar b/sonar-server/src/test/resources/org/sonar/server/plugins/PluginDeployerTest/failIfTwoPluginsWithSameKey/extensions/plugins/foo-plugin2.jar
deleted file mode 100644 (file)
index 22ced8f..0000000
Binary files a/sonar-server/src/test/resources/org/sonar/server/plugins/PluginDeployerTest/failIfTwoPluginsWithSameKey/extensions/plugins/foo-plugin2.jar and /dev/null differ
diff --git a/sonar-server/src/test/resources/org/sonar/server/plugins/PluginDeployerTest/ignoreJarsWhichAreNotPlugins/extensions/plugins/not-a-plugin.jar b/sonar-server/src/test/resources/org/sonar/server/plugins/PluginDeployerTest/ignoreJarsWhichAreNotPlugins/extensions/plugins/not-a-plugin.jar
deleted file mode 100644 (file)
index 11b72f4..0000000
Binary files a/sonar-server/src/test/resources/org/sonar/server/plugins/PluginDeployerTest/ignoreJarsWhichAreNotPlugins/extensions/plugins/not-a-plugin.jar and /dev/null differ
diff --git a/sonar-server/src/test/resources/org/sonar/server/plugins/PluginDeployerTest/should_fail_on_plugin_depending_on_more_recent_sonar/extensions/plugins/sonar-switch-off-violations-plugin-1.1.jar b/sonar-server/src/test/resources/org/sonar/server/plugins/PluginDeployerTest/should_fail_on_plugin_depending_on_more_recent_sonar/extensions/plugins/sonar-switch-off-violations-plugin-1.1.jar
deleted file mode 100644 (file)
index 8044dff..0000000
Binary files a/sonar-server/src/test/resources/org/sonar/server/plugins/PluginDeployerTest/should_fail_on_plugin_depending_on_more_recent_sonar/extensions/plugins/sonar-switch-off-violations-plugin-1.1.jar and /dev/null differ
diff --git a/sonar-server/src/test/resources/org/sonar/server/plugins/ServerPluginJarsInstallerTest/deployBundledPluginsOnFreshInstall/extensions/plugins/foo-plugin.jar b/sonar-server/src/test/resources/org/sonar/server/plugins/ServerPluginJarsInstallerTest/deployBundledPluginsOnFreshInstall/extensions/plugins/foo-plugin.jar
new file mode 100644 (file)
index 0000000..22ced8f
Binary files /dev/null and b/sonar-server/src/test/resources/org/sonar/server/plugins/ServerPluginJarsInstallerTest/deployBundledPluginsOnFreshInstall/extensions/plugins/foo-plugin.jar differ
diff --git a/sonar-server/src/test/resources/org/sonar/server/plugins/ServerPluginJarsInstallerTest/deployBundledPluginsOnFreshInstall/lib/bundled-plugins/bar-plugin.jar b/sonar-server/src/test/resources/org/sonar/server/plugins/ServerPluginJarsInstallerTest/deployBundledPluginsOnFreshInstall/lib/bundled-plugins/bar-plugin.jar
new file mode 100644 (file)
index 0000000..acf4fa4
Binary files /dev/null and b/sonar-server/src/test/resources/org/sonar/server/plugins/ServerPluginJarsInstallerTest/deployBundledPluginsOnFreshInstall/lib/bundled-plugins/bar-plugin.jar differ
diff --git a/sonar-server/src/test/resources/org/sonar/server/plugins/ServerPluginJarsInstallerTest/deployPlugin/extensions/plugins/foo-plugin.jar b/sonar-server/src/test/resources/org/sonar/server/plugins/ServerPluginJarsInstallerTest/deployPlugin/extensions/plugins/foo-plugin.jar
new file mode 100644 (file)
index 0000000..22ced8f
Binary files /dev/null and b/sonar-server/src/test/resources/org/sonar/server/plugins/ServerPluginJarsInstallerTest/deployPlugin/extensions/plugins/foo-plugin.jar differ
diff --git a/sonar-server/src/test/resources/org/sonar/server/plugins/ServerPluginJarsInstallerTest/deployPlugin/lib/bundled-plugins/bar-plugin.jar b/sonar-server/src/test/resources/org/sonar/server/plugins/ServerPluginJarsInstallerTest/deployPlugin/lib/bundled-plugins/bar-plugin.jar
new file mode 100644 (file)
index 0000000..acf4fa4
Binary files /dev/null and b/sonar-server/src/test/resources/org/sonar/server/plugins/ServerPluginJarsInstallerTest/deployPlugin/lib/bundled-plugins/bar-plugin.jar differ
diff --git a/sonar-server/src/test/resources/org/sonar/server/plugins/ServerPluginJarsInstallerTest/deployPluginExtensions/extensions/plugins/foo-plugin.jar b/sonar-server/src/test/resources/org/sonar/server/plugins/ServerPluginJarsInstallerTest/deployPluginExtensions/extensions/plugins/foo-plugin.jar
new file mode 100644 (file)
index 0000000..7bcf027
Binary files /dev/null and b/sonar-server/src/test/resources/org/sonar/server/plugins/ServerPluginJarsInstallerTest/deployPluginExtensions/extensions/plugins/foo-plugin.jar differ
diff --git a/sonar-server/src/test/resources/org/sonar/server/plugins/ServerPluginJarsInstallerTest/deployPluginExtensions/extensions/rules/foo/foo-extension.txt b/sonar-server/src/test/resources/org/sonar/server/plugins/ServerPluginJarsInstallerTest/deployPluginExtensions/extensions/rules/foo/foo-extension.txt
new file mode 100644 (file)
index 0000000..d84be83
--- /dev/null
@@ -0,0 +1 @@
+this is an extension to the plugin foo
\ No newline at end of file
diff --git a/sonar-server/src/test/resources/org/sonar/server/plugins/ServerPluginJarsInstallerTest/failIfTwoPluginsWithSameKey/extensions/plugins/foo-plugin1.jar b/sonar-server/src/test/resources/org/sonar/server/plugins/ServerPluginJarsInstallerTest/failIfTwoPluginsWithSameKey/extensions/plugins/foo-plugin1.jar
new file mode 100644 (file)
index 0000000..22ced8f
Binary files /dev/null and b/sonar-server/src/test/resources/org/sonar/server/plugins/ServerPluginJarsInstallerTest/failIfTwoPluginsWithSameKey/extensions/plugins/foo-plugin1.jar differ
diff --git a/sonar-server/src/test/resources/org/sonar/server/plugins/ServerPluginJarsInstallerTest/failIfTwoPluginsWithSameKey/extensions/plugins/foo-plugin2.jar b/sonar-server/src/test/resources/org/sonar/server/plugins/ServerPluginJarsInstallerTest/failIfTwoPluginsWithSameKey/extensions/plugins/foo-plugin2.jar
new file mode 100644 (file)
index 0000000..22ced8f
Binary files /dev/null and b/sonar-server/src/test/resources/org/sonar/server/plugins/ServerPluginJarsInstallerTest/failIfTwoPluginsWithSameKey/extensions/plugins/foo-plugin2.jar differ
diff --git a/sonar-server/src/test/resources/org/sonar/server/plugins/ServerPluginJarsInstallerTest/ignoreJarsWhichAreNotPlugins/extensions/plugins/not-a-plugin.jar b/sonar-server/src/test/resources/org/sonar/server/plugins/ServerPluginJarsInstallerTest/ignoreJarsWhichAreNotPlugins/extensions/plugins/not-a-plugin.jar
new file mode 100644 (file)
index 0000000..11b72f4
Binary files /dev/null and b/sonar-server/src/test/resources/org/sonar/server/plugins/ServerPluginJarsInstallerTest/ignoreJarsWhichAreNotPlugins/extensions/plugins/not-a-plugin.jar differ
diff --git a/sonar-server/src/test/resources/org/sonar/server/plugins/ServerPluginJarsInstallerTest/should_fail_on_plugin_depending_on_more_recent_sonar/extensions/plugins/sonar-switch-off-violations-plugin-1.1.jar b/sonar-server/src/test/resources/org/sonar/server/plugins/ServerPluginJarsInstallerTest/should_fail_on_plugin_depending_on_more_recent_sonar/extensions/plugins/sonar-switch-off-violations-plugin-1.1.jar
new file mode 100644 (file)
index 0000000..8044dff
Binary files /dev/null and b/sonar-server/src/test/resources/org/sonar/server/plugins/ServerPluginJarsInstallerTest/should_fail_on_plugin_depending_on_more_recent_sonar/extensions/plugins/sonar-switch-off-violations-plugin-1.1.jar differ
diff --git a/sonar-server/src/test/resources/org/sonar/server/plugins/ServerPluginRepositoryTest/sonar-artifact-size-plugin-0.2.jar b/sonar-server/src/test/resources/org/sonar/server/plugins/ServerPluginRepositoryTest/sonar-artifact-size-plugin-0.2.jar
new file mode 100644 (file)
index 0000000..1953323
Binary files /dev/null and b/sonar-server/src/test/resources/org/sonar/server/plugins/ServerPluginRepositoryTest/sonar-artifact-size-plugin-0.2.jar differ