private void overrideAndRegisterPlugin(File sourceFile) {
    File destDir = fs.getInstalledPluginsDir();
    File destFile = new File(destDir, sourceFile.getName());
    if (destFile.exists()) {
      // plugin with same filename already installed
      deleteQuietly(destFile);
    }

    try {
      moveFile(sourceFile, destFile);

    } catch (IOException e) {
      throw new IllegalStateException(format("Fail to move plugin: %s to %s",
        sourceFile.getAbsolutePath(), destFile.getAbsolutePath()), e);
    }

    PluginInfo info = PluginInfo.create(destFile);
    PluginInfo existing = pluginInfosByKeys.put(info.getKey(), info);
    if (existing != null) {
      if (!existing.getNonNullJarFile().getName().equals(destFile.getName())) {
        deleteQuietly(existing.getNonNullJarFile());
      }
      LOG.info("Plugin {} [{}] updated to version {}", info.getName(), info.getKey(), info.getVersion());
    } else {
      LOG.info("Plugin {} [{}] installed", info.getName(), info.getKey());
    }
  }
private void overrideAndRegisterPlugin ( File sourceFile ) { File destDir = fs . getInstalledPluginsDir ( ) ; File destFile = new File ( destDir , sourceFile . getName ( ) ) ; if ( destFile . exists ( ) ) { deleteQuietly ( destFile ) ; } try { moveFile ( sourceFile , destFile ) ; } catch ( IOException e ) { throw new IllegalStateException ( format ( "Fail to move plugin: %s to %s" , sourceFile . getAbsolutePath ( ) , destFile . getAbsolutePath ( ) ) , e ) ; } PluginInfo info = PluginInfo . create ( destFile ) ; PluginInfo existing = pluginInfosByKeys . put ( info . getKey ( ) , info ) ; if ( existing != null ) { if ( ! existing . getNonNullJarFile ( ) . getName ( ) . equals ( destFile . getName ( ) ) ) { deleteQuietly ( existing . getNonNullJarFile ( ) ) ; } LOG . info ( "Plugin {} [{}] updated to version {}" , info . getName ( ) , info . getKey ( ) , info . getVersion ( ) ) ; } else { LOG . info ( "Plugin {} [{}] installed" , info . getName ( ) , info . getKey ( ) ) ; } }
Move or copy plugin to directory extensions/plugins. If a version of this plugin
already exists then it's deleted.