Plugins: If a plugin has a bin directory, move it under the main bin location under the plugin name, closes #1584.

This commit is contained in:
Shay Banon 2012-01-03 14:03:27 +02:00
parent ed1d1249fc
commit 38e8727a89
2 changed files with 21 additions and 1 deletions

View File

@ -208,6 +208,14 @@ public class PluginManager {
pluginFile.delete();
}
File binFile = new File(extractLocation, "bin");
if (binFile.exists() && binFile.isDirectory()) {
File toLocation = new File(new File(environment.homeFile(), "bin"), name);
System.out.println("Found bin, moving to " + toLocation.getAbsolutePath());
FileSystemUtils.deleteRecursively(toLocation);
binFile.renameTo(toLocation);
}
// try and identify the plugin type, see if it has no .class or .jar files in it
// so its probably a _site, and it it does not have a _site in it, move everything to _site
if (!new File(extractLocation, "_site").exists()) {
@ -233,6 +241,10 @@ public class PluginManager {
if (pluginToDelete.exists()) {
pluginToDelete.delete();
}
File binLocation = new File(new File(environment.homeFile(), "bin"), name);
if (binLocation.exists()) {
FileSystemUtils.deleteRecursively(binLocation);
}
}
public static void main(String[] args) {

View File

@ -192,8 +192,16 @@ public class PluginsService extends AbstractComponent {
try {
// add the root
addURL.invoke(classLoader, pluginFile.toURI().toURL());
// gather files to add
List<File> libFiles = Lists.newArrayList();
libFiles.addAll(Arrays.asList(pluginsFile.listFiles()));
File libLocation = new File(pluginFile, "lib");
if (libLocation.exists() && libLocation.isDirectory()) {
libFiles.addAll(Arrays.asList(libLocation.listFiles()));
}
// if there are jars in it, add it as well
for (File jarToAdd : pluginFile.listFiles()) {
for (File jarToAdd : libFiles) {
if (!(jarToAdd.getName().endsWith(".jar") || jarToAdd.getName().endsWith(".zip"))) {
continue;
}