@Test public void loadPlugins() throws IOException, URISyntaxException { Path plugin = temp.getRoot().toPath().resolve("plugins").resolve("test.jar"); Files.createFile(plugin); URL[] plugins = SonarLintFactory.loadPlugins(); assertThat(plugins).hasSize(1); assertThat(Paths.get(plugins[0].toURI())).isEqualTo(plugin); }
@VisibleForTesting static URL[] loadPlugins() throws IOException { String sonarlintHome = System.getProperty(SonarProperties.SONARLINT_HOME); if (sonarlintHome == null) { throw new IllegalStateException("Can't find SonarLint home. System property not set: " + SonarProperties.SONARLINT_HOME); } Path sonarLintHomePath = Paths.get(sonarlintHome); Path pluginDir = sonarLintHomePath.resolve("plugins"); List<URL> pluginsUrls = new ArrayList<>(); try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(pluginDir)) { for (Path path : directoryStream) { pluginsUrls.add(path.toUri().toURL()); } } return pluginsUrls.toArray(new URL[pluginsUrls.size()]); }
SonarLintFactory { @VisibleForTesting static URL[] loadPlugins() throws IOException { String sonarlintHome = System.getProperty(SonarProperties.SONARLINT_HOME); if (sonarlintHome == null) { throw new IllegalStateException("Can't find SonarLint home. System property not set: " + SonarProperties.SONARLINT_HOME); } Path sonarLintHomePath = Paths.get(sonarlintHome); Path pluginDir = sonarLintHomePath.resolve("plugins"); List<URL> pluginsUrls = new ArrayList<>(); try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(pluginDir)) { for (Path path : directoryStream) { pluginsUrls.add(path.toUri().toURL()); } } return pluginsUrls.toArray(new URL[pluginsUrls.size()]); } }
SonarLintFactory { @VisibleForTesting static URL[] loadPlugins() throws IOException { String sonarlintHome = System.getProperty(SonarProperties.SONARLINT_HOME); if (sonarlintHome == null) { throw new IllegalStateException("Can't find SonarLint home. System property not set: " + SonarProperties.SONARLINT_HOME); } Path sonarLintHomePath = Paths.get(sonarlintHome); Path pluginDir = sonarLintHomePath.resolve("plugins"); List<URL> pluginsUrls = new ArrayList<>(); try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(pluginDir)) { for (Path path : directoryStream) { pluginsUrls.add(path.toUri().toURL()); } } return pluginsUrls.toArray(new URL[pluginsUrls.size()]); }  }
SonarLintFactory { @VisibleForTesting static URL[] loadPlugins() throws IOException { String sonarlintHome = System.getProperty(SonarProperties.SONARLINT_HOME); if (sonarlintHome == null) { throw new IllegalStateException("Can't find SonarLint home. System property not set: " + SonarProperties.SONARLINT_HOME); } Path sonarLintHomePath = Paths.get(sonarlintHome); Path pluginDir = sonarLintHomePath.resolve("plugins"); List<URL> pluginsUrls = new ArrayList<>(); try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(pluginDir)) { for (Path path : directoryStream) { pluginsUrls.add(path.toUri().toURL()); } } return pluginsUrls.toArray(new URL[pluginsUrls.size()]); }  StandaloneSonarLint createSonarLint(); }
SonarLintFactory { @VisibleForTesting static URL[] loadPlugins() throws IOException { String sonarlintHome = System.getProperty(SonarProperties.SONARLINT_HOME); if (sonarlintHome == null) { throw new IllegalStateException("Can't find SonarLint home. System property not set: " + SonarProperties.SONARLINT_HOME); } Path sonarLintHomePath = Paths.get(sonarlintHome); Path pluginDir = sonarLintHomePath.resolve("plugins"); List<URL> pluginsUrls = new ArrayList<>(); try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(pluginDir)) { for (Path path : directoryStream) { pluginsUrls.add(path.toUri().toURL()); } } return pluginsUrls.toArray(new URL[pluginsUrls.size()]); }  StandaloneSonarLint createSonarLint();  }