Package org.sonar.api.platform

Examples of org.sonar.api.platform.PluginMetadata


    }
    return new URLClassLoader(urls);
  }

  private PluginMetadata newPlugin(String key) {
    PluginMetadata plugin = mock(PluginMetadata.class);
    when(plugin.getKey()).thenReturn(key);
    return plugin;
  }
View Full Code Here


  }

  @Test
  public void shouldEquals() {
    DefaultPluginMetadata checkstyle = DefaultPluginMetadata.create(new File("sonar-checkstyle-plugin.jar")).setKey("checkstyle");
    PluginMetadata pmd = DefaultPluginMetadata.create(new File("sonar-pmd-plugin.jar")).setKey("pmd");

    assertThat(checkstyle).isEqualTo(checkstyle);
    assertThat(checkstyle).isEqualTo(DefaultPluginMetadata.create(new File("sonar-checkstyle-plugin.jar")).setKey("checkstyle"));
    assertThat(checkstyle).isNotEqualTo(pmd);
  }
View Full Code Here

          container.declareExtension(pluginMetadata, extension);
        }
      }
    }
    for (Map.Entry<PluginMetadata, Object> entry : installedExtensionsByPlugin.entries()) {
      PluginMetadata plugin = entry.getKey();
      Object extension = entry.getValue();
      if (isExtensionProvider(extension)) {
        ExtensionProvider provider = (ExtensionProvider) container.getComponentByKey(extension);
        installProvider(container, plugin, provider);
      }
View Full Code Here

    FileUtils.copyFile(jar("foo-plugin-2.0.jar"), new File(downloadsDir, "foo-plugin-1.0.jar"));
    when(upgradeStatus.isFreshInstall()).thenReturn(false);

    jarsInstaller.install();

    PluginMetadata plugin = jarsInstaller.getMetadata("foo");
    assertThat(plugin).isNotNull();
    assertThat(plugin.getVersion()).isEqualTo("2.0");
    assertThat(FileUtils.listFiles(pluginsDir, new String[] {"jar"}, false)).hasSize(1);
    assertThat(FileUtils.listFiles(downloadsDir, new String[] {"jar"}, false)).isEmpty();
    File installed = new File(pluginsDir, "foo-plugin-1.0.jar");
    assertThat(installed).exists().isFile();
  }
View Full Code Here

    assertThat(FileUtils.listFiles(pluginsDir, new String[] {"jar"}, false)).hasSize(0);

    // do not remove from lib/core-plugins
    assertThat(FileUtils.listFiles(coreDir, new String[] {"jar"}, false)).hasSize(1);

    PluginMetadata plugin = jarsInstaller.getMetadata("foo");
    assertThat(plugin).isNotNull();
    assertThat(plugin.isCore()).isTrue();
  }
View Full Code Here

  private DebtModelPluginRepository modelFinder;

  @Test
  public void test_component_initialization() throws Exception {
    // we do have the "csharp-model.xml" file in src/test/resources
    PluginMetadata csharpPluginMetadata = mock(PluginMetadata.class);
    when(csharpPluginMetadata.getKey()).thenReturn("csharp");

    // but we don' have the "php-model.xml" one
    PluginMetadata phpPluginMetadata = mock(PluginMetadata.class);
    when(phpPluginMetadata.getKey()).thenReturn("php");

    PluginRepository repository = mock(PluginRepository.class);
    when(repository.getMetadata()).thenReturn(Lists.newArrayList(csharpPluginMetadata, phpPluginMetadata));
    FakePlugin fakePlugin = new FakePlugin();
    when(repository.getPlugin(anyString())).thenReturn(fakePlugin);
View Full Code Here

  private void loadInstalledPlugin(DefaultPluginMetadata metadata) {
    if (BLACKLISTED_PLUGINS.contains(metadata.getKey())) {
      LOG.warn("Plugin {} is blacklisted. Please uninstall it.", metadata.getName());
    } else {
      PluginMetadata existing = pluginByKeys.put(metadata.getKey(), metadata);
      if (existing != null) {
        throw MessageException.of(String.format("Found two files for the same plugin '%s': %s and %s",
          metadata.getKey(), metadata.getFile().getName(), existing.getFile().getName()));
      }
    }
  }
View Full Code Here

        sourceFile.getAbsolutePath(), destFile.getAbsolutePath()), e);
    }

    DefaultPluginMetadata metadata = installer.extractMetadata(destFile, false);
    if (StringUtils.isNotBlank(metadata.getKey())) {
      PluginMetadata existing = pluginByKeys.put(metadata.getKey(), metadata);
      if (existing != null) {
        if (!existing.getFile().getName().equals(destFile.getName())) {
          FileUtils.deleteQuietly(existing.getFile());
        }
        LOG.info("Plugin " + metadata.getKey() + " replaced by new version");
      }
    }
  }
View Full Code Here

  }

  private void loadCorePlugins() {
    for (File file : fs.getCorePlugins()) {
      DefaultPluginMetadata metadata = installer.extractMetadata(file, true);
      PluginMetadata existing = pluginByKeys.put(metadata.getKey(), metadata);
      if (existing != null) {
        throw new IllegalStateException("Found two plugins with the same key '" + metadata.getKey() + "': " + metadata.getFile().getName() + " and "
          + existing.getFile().getName());
      }
    }
  }
View Full Code Here

      uninstallPlugin(key);
    }
  }

  private void uninstallPlugin(String pluginKey) {
    PluginMetadata metadata = pluginByKeys.get(pluginKey);
    if (metadata != null && !metadata.isCore()) {
      try {
        File masterFile = new File(fs.getUserPluginsDir(), metadata.getFile().getName());
        FileUtils.moveFileToDirectory(masterFile, fs.getTrashPluginsDir(), true);
      } catch (IOException e) {
        throw new IllegalStateException("Fail to uninstall plugin: " + pluginKey, e);
      }
    }
View Full Code Here

TOP

Related Classes of org.sonar.api.platform.PluginMetadata

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.