public Collection getBundledToolVersions()

in sonar-plugin-server/src/main/java/jetbrains/buildserver/sonarplugin/tool/SonarQubeToolProvider.java [53:88]


    public Collection<InstalledToolVersion> getBundledToolVersions() {
        final Path bundledTools = mySimpleZipToolProvider.getBundledVersionsRoot();
        LOG.debug(" - getBundledToolVersions in " + bundledTools);

        final String error = checkDirectory(bundledTools, "Cannot get bundled " + mySimpleZipToolProvider.getName() + " version");
        if (error != null) {
            LOG.warn(error);
            return Collections.emptyList();
        }

        final List<InstalledToolVersion> res = new ArrayList<>();
        try (final DirectoryStream<Path> contents = Files.newDirectoryStream(bundledTools)) {
            for (Path path : contents) {
                LOG.debug(" - getBundledToolVersions found package " + path);
                final String errorFiles = checkFile(path, "Cannot parse SonarQube Scanner package");
                if (errorFiles != null) {
                    LOG.warn(errorFiles);
                } else {
                    final String fileName = path.getFileName().toString();

                    final Matcher matcher = myPackedSonarQubeScannerRootZipPattern.matcher(fileName);
                    if (!matcher.matches()) { // the folder contains some tools supported by different tool provider, the check is needed to avoid warnings
                        continue;
                    }
                    final GetPackageVersionResult result = mySimpleZipToolProvider.tryParsePackedPackage(path, matcher);
                    if (result.getToolVersion() != null) {
                        res.add(new SimpleInstalledToolVersion(result.getToolVersion(), null, null, path.toFile()));
                    }
                }
            }
        } catch (IOException e) {
            LOG.warnAndDebugDetails("Cannot get bundled " + mySimpleZipToolProvider.getName() + " version due to an error", e);
        }

        return res;
    }