@Override
  public ExplodedPlugin explode(PluginInfo plugin) {
    File toDir = new File(fs.getDeployedPluginsDir(), plugin.getKey());
    try {
      forceMkdir(toDir);
      org.sonar.core.util.FileUtils.cleanDirectory(toDir);

      File jarTarget = new File(toDir, plugin.getNonNullJarFile().getName());

      FileUtils.copyFile(plugin.getNonNullJarFile(), jarTarget);
      ZipUtils.unzip(plugin.getNonNullJarFile(), toDir, newLibFilter());
      return explodeFromUnzippedDir(plugin, jarTarget, toDir);
    } catch (Exception e) {
      throw new IllegalStateException(String.format(
        "Fail to unzip plugin [%s] %s to %s", plugin.getKey(), plugin.getNonNullJarFile().getAbsolutePath(), toDir.getAbsolutePath()), e);
    }
  }
@Test
  public void copy_all_classloader_files_to_dedicated_directory() throws Exception {
    File deployDir = temp.newFolder();
    when(fs.getDeployedPluginsDir()).thenReturn(deployDir);
    File sourceJar = TestProjectUtils.jarOf("test-libs-plugin");
    PluginInfo info = PluginInfo.create(sourceJar);

    ExplodedPlugin exploded = underTest.explode(info);

    // all the files loaded by classloaders (JAR + META-INF/libs/*.jar) are copied to the dedicated directory
    // web/deploy/{pluginKey}
    File pluginDeployDir = new File(deployDir, "testlibs");

    assertThat(exploded.getKey()).isEqualTo("testlibs");
    assertThat(exploded.getMain()).isFile().exists().hasParent(pluginDeployDir);
    assertThat(exploded.getLibs()).extracting("name").containsOnly("commons-daemon-1.0.15.jar", "commons-email-20030310.165926.jar");
    for (File lib : exploded.getLibs()) {
      assertThat(lib).exists().isFile();
      assertThat(lib.getCanonicalPath()).startsWith(pluginDeployDir.getCanonicalPath());
    }
    File targetJar = new File(fs.getDeployedPluginsDir(), "testlibs/test-libs-plugin-0.1-SNAPSHOT.jar");
  }