]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-21025 remove deprecated plugins/index.txt file
authorPierre <pierre.guillot@sonarsource.com>
Mon, 13 Nov 2023 08:30:15 +0000 (09:30 +0100)
committersonartech <sonartech@sonarsource.com>
Wed, 20 Mar 2024 20:02:31 +0000 (20:02 +0000)
server/sonar-ce/src/test/java/org/sonar/ce/container/CePluginJarExploderTest.java
server/sonar-server-common/src/main/java/org/sonar/server/platform/ServerFileSystem.java
server/sonar-server-common/src/main/java/org/sonar/server/platform/ServerFileSystemImpl.java
server/sonar-server-common/src/test/java/org/sonar/server/platform/ServerFileSystemImplTest.java
server/sonar-webserver-core/src/main/java/org/sonar/server/startup/GeneratePluginIndex.java [deleted file]
server/sonar-webserver-core/src/test/java/org/sonar/server/startup/GeneratePluginIndexTest.java [deleted file]
server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevelStartup.java

index c935eda71528afd2d75d68d38ef5a9f66fa7876e..7016c20762e7986d2481e582c36021e37082744d 100644 (file)
@@ -134,11 +134,6 @@ public class CePluginJarExploderTest {
       throw new UnsupportedOperationException();
     }
 
-    @Override
-    public File getPluginIndex() {
-      throw new UnsupportedOperationException();
-    }
-
     @Override
     public File getUninstalledPluginsDir() {
       throw new UnsupportedOperationException();
index 15fc6f0aadf215f7296f8b64a3eb3cafa6f53685..5a9c905b1d9a596e77f2cc8937f7e3770c13d46e 100644 (file)
@@ -64,14 +64,6 @@ public interface ServerFileSystem {
    */
   File getInstalledBundledPluginsDir();
 
-  /**
-   * The file listing all the installed plugins. Used by scanner only.
-   * @return an existing file
-   * @deprecated see {@link org.sonar.server.startup.GeneratePluginIndex}
-   */
-  @Deprecated
-  File getPluginIndex();
-
   /**
    * Directory where plugins to be uninstalled are moved to.
    * @return a directory which may or not exist
index 6c03e0c3d1f0ffba94aae8fd76a12dbdbed31578..97c312370fc2c15703f17afd4cd7bd5225fb6313 100644 (file)
@@ -22,10 +22,10 @@ package org.sonar.server.platform;
 import java.io.File;
 import java.io.IOException;
 import org.apache.commons.io.FileUtils;
-import org.sonar.api.Startable;
-import org.sonar.api.config.Configuration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.sonar.api.Startable;
+import org.sonar.api.config.Configuration;
 
 import static org.sonar.process.ProcessProperties.Property.PATH_DATA;
 import static org.sonar.process.ProcessProperties.Property.PATH_HOME;
@@ -88,11 +88,6 @@ public class ServerFileSystemImpl implements ServerFileSystem, org.sonar.api.pla
     return new File(getHomeDir(), "lib/extensions");
   }
 
-  @Override
-  public File getPluginIndex() {
-    return new File(deployDir, "plugins/index.txt");
-  }
-
   @Override
   public File getUninstalledPluginsDir() {
     return uninstallDir;
index 94e97505d570db0d471aae0fbbfdebfb8c2d9c92..4d24630fd0652dca01ed617ea43fb5aad1da0f9a 100644 (file)
@@ -76,8 +76,6 @@ public class ServerFileSystemImplTest {
     assertThat(underTest.getInstalledBundledPluginsDir()).isEqualTo(new File(homeDir.getAbsolutePath() + "/lib/extensions"));
     assertThat(underTest.getInstalledExternalPluginsDir()).isEqualTo(new File(homeDir.getAbsolutePath() + "/extensions/plugins"));
 
-    assertThat(underTest.getPluginIndex()).isEqualTo(new File(dataDir.getAbsolutePath() + "/web/deploy/plugins/index.txt"));
-
     assertThat(underTest.getUninstalledPluginsDir()).isEqualTo(new File(tempDir.getAbsolutePath() + "/uninstalled-plugins"));
   }
 
diff --git a/server/sonar-webserver-core/src/main/java/org/sonar/server/startup/GeneratePluginIndex.java b/server/sonar-webserver-core/src/main/java/org/sonar/server/startup/GeneratePluginIndex.java
deleted file mode 100644 (file)
index 91ec660..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2024 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program 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.
- *
- * This program 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.startup;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-import java.nio.charset.StandardCharsets;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.lang3.CharUtils;
-import org.sonar.api.Startable;
-import org.sonar.api.server.ServerSide;
-import org.sonar.api.utils.log.Logger;
-import org.sonar.api.utils.log.Loggers;
-import org.sonar.api.utils.log.Profiler;
-import org.sonar.server.platform.ServerFileSystem;
-import org.sonar.server.plugins.ServerPlugin;
-import org.sonar.server.plugins.ServerPluginRepository;
-
-/**
- * The file deploy/plugins/index.txt is required for old versions of SonarLint.
- * They don't use the web service api/plugins/installed to get the list
- * of installed plugins.
- * https://jira.sonarsource.com/browse/SLCORE-146
- */
-@ServerSide
-public final class GeneratePluginIndex implements Startable {
-
-  private static final Logger LOG = Loggers.get(GeneratePluginIndex.class);
-
-  private final ServerFileSystem serverFs;
-  private final ServerPluginRepository serverPluginRepository;
-
-  public GeneratePluginIndex(ServerFileSystem serverFs, ServerPluginRepository serverPluginRepository) {
-    this.serverFs = serverFs;
-    this.serverPluginRepository = serverPluginRepository;
-  }
-
-  @Override
-  public void start() {
-    Profiler profiler = Profiler.create(LOG).startInfo("Generate scanner plugin index");
-    writeIndex(serverFs.getPluginIndex());
-    profiler.stopDebug();
-  }
-
-  @Override
-  public void stop() {
-    // Nothing to do
-  }
-
-  private void writeIndex(File indexFile) {
-    try {
-      FileUtils.forceMkdir(indexFile.getParentFile());
-      try (Writer writer = new OutputStreamWriter(new FileOutputStream(indexFile), StandardCharsets.UTF_8)) {
-        for (ServerPlugin plugin : serverPluginRepository.getPlugins()) {
-          writer.append(toRow(plugin));
-          writer.append(CharUtils.LF);
-        }
-        writer.flush();
-      }
-    } catch (IOException e) {
-      throw new IllegalStateException("Unable to generate plugin index at " + indexFile, e);
-    }
-  }
-
-  private static String toRow(ServerPlugin file) {
-    return new StringBuilder().append(file.getPluginInfo().getKey())
-      .append(",")
-      .append(file.getPluginInfo().isSonarLintSupported())
-      .append(",")
-      .append(file.getJar().getFile().getName())
-      .append("|")
-      .append(file.getJar().getMd5())
-      .toString();
-  }
-
-}
diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/startup/GeneratePluginIndexTest.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/startup/GeneratePluginIndexTest.java
deleted file mode 100644 (file)
index eadb398..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2024 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program 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.
- *
- * This program 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.startup;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.List;
-import org.apache.commons.io.FileUtils;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
-import org.sonar.core.platform.PluginInfo;
-import org.sonar.server.platform.ServerFileSystem;
-import org.sonar.server.plugins.PluginFilesAndMd5.FileAndMd5;
-import org.sonar.server.plugins.ServerPlugin;
-import org.sonar.server.plugins.ServerPluginRepository;
-
-import static java.util.Arrays.asList;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-import static org.sonar.core.plugin.PluginType.BUNDLED;
-
-public class GeneratePluginIndexTest {
-
-  @Rule
-  public TemporaryFolder temp = new TemporaryFolder();
-
-  private ServerFileSystem serverFileSystem = mock(ServerFileSystem.class);
-  private ServerPluginRepository serverPluginRepository = mock(ServerPluginRepository.class);
-  private File index;
-
-  @Before
-  public void createIndexFile() throws IOException {
-    index = temp.newFile();
-    when(serverFileSystem.getPluginIndex()).thenReturn(index);
-  }
-
-  @Test
-  public void shouldWriteIndex() throws IOException {
-    ServerPlugin javaPlugin = newInstalledPlugin("java", true);
-    ServerPlugin gitPlugin = newInstalledPlugin("scmgit", false);
-    when(serverPluginRepository.getPlugins()).thenReturn(asList(javaPlugin, gitPlugin));
-
-    GeneratePluginIndex underTest = new GeneratePluginIndex(serverFileSystem, serverPluginRepository);
-    underTest.start();
-
-    List<String> lines = FileUtils.readLines(index);
-    assertThat(lines).containsExactly(
-      "java,true," + javaPlugin.getJar().getFile().getName() + "|" + javaPlugin.getJar().getMd5(),
-      "scmgit,false," + gitPlugin.getJar().getFile().getName() + "|" + gitPlugin.getJar().getMd5());
-
-    underTest.stop();
-  }
-
-  @Test
-  public void shouldThrowWhenUnableToWrite() throws IOException {
-    File wrongParent = temp.newFile();
-    wrongParent.createNewFile();
-    File wrongIndex = new File(wrongParent, "index.txt");
-    when(serverFileSystem.getPluginIndex()).thenReturn(wrongIndex);
-
-    assertThatThrownBy(() -> new GeneratePluginIndex(serverFileSystem, serverPluginRepository).start())
-      .isInstanceOf(IllegalStateException.class);
-  }
-
-  private ServerPlugin newInstalledPlugin(String key, boolean supportSonarLint) throws IOException {
-    FileAndMd5 jar = new FileAndMd5(temp.newFile());
-    PluginInfo pluginInfo = new PluginInfo(key).setJarFile(jar.getFile()).setSonarLintSupported(supportSonarLint);
-    return new ServerPlugin(pluginInfo, BUNDLED, null, jar, null);
-  }
-}
index 0d910e4c4e7de03d3ade9a0849bc00be2f883fae..eb016d45ba21c0cff4ed6c19e16527b103c2a7e5 100644 (file)
@@ -39,14 +39,13 @@ import org.sonar.server.qualityprofile.builtin.BuiltInQualityProfilesUpdateListe
 import org.sonar.server.rule.AdvancedRuleDescriptionSectionsGenerator;
 import org.sonar.server.rule.LegacyHotspotRuleDescriptionSectionsGenerator;
 import org.sonar.server.rule.LegacyIssueRuleDescriptionSectionsGenerator;
+import org.sonar.server.rule.RuleDescriptionSectionsGeneratorResolver;
+import org.sonar.server.rule.WebServerRuleFinder;
 import org.sonar.server.rule.registration.NewRuleCreator;
 import org.sonar.server.rule.registration.QualityProfileChangesUpdater;
 import org.sonar.server.rule.registration.RulesKeyVerifier;
 import org.sonar.server.rule.registration.RulesRegistrant;
-import org.sonar.server.rule.RuleDescriptionSectionsGeneratorResolver;
-import org.sonar.server.rule.WebServerRuleFinder;
 import org.sonar.server.rule.registration.StartupRuleUpdater;
-import org.sonar.server.startup.GeneratePluginIndex;
 import org.sonar.server.startup.RegisterMetrics;
 import org.sonar.server.startup.RegisterPermissionTemplates;
 import org.sonar.server.startup.RegisterPlugins;
@@ -64,8 +63,7 @@ public class PlatformLevelStartup extends PlatformLevel {
 
   @Override
   protected void configureLevel() {
-    add(GeneratePluginIndex.class,
-      ServerLifecycleNotifier.class);
+    add(ServerLifecycleNotifier.class);
 
     addIfStartupLeader(
       IndexerStartupTask.class);