1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-26 08:27:12 -07:00

Merge pull request #225 from DevCharly/plugins-from-directories

support using plugins from directories
This commit is contained in:
Cedric Beust 2016-06-02 09:04:33 -07:00
commit e8f5ca1684

View file

@ -12,6 +12,7 @@ import com.beust.kobalt.misc.KFiles
import com.beust.kobalt.misc.KobaltExecutors import com.beust.kobalt.misc.KobaltExecutors
import com.beust.kobalt.misc.log import com.beust.kobalt.misc.log
import com.google.inject.Provider import com.google.inject.Provider
import java.io.File
import java.lang.reflect.Method import java.lang.reflect.Method
import java.lang.reflect.Modifier import java.lang.reflect.Modifier
import java.net.URLClassLoader import java.net.URLClassLoader
@ -160,9 +161,14 @@ class Plugins @Inject constructor (val taskManagerProvider : Provider<TaskManage
// //
// Open the jar, parse its kobalt-plugin.xml and add the resulting PluginInfo to pluginInfo // Open the jar, parse its kobalt-plugin.xml and add the resulting PluginInfo to pluginInfo
// //
val pluginXml = JarUtils.extractTextFile(JarFile(it.jarFile.get()), PluginInfo.PLUGIN_XML) val file = it.jarFile.get();
val pluginXml = if (file.isDirectory()) {
File(file, PluginInfo.PLUGIN_XML).readText()
} else {
JarUtils.extractTextFile(JarFile(file), PluginInfo.PLUGIN_XML)
}
if (pluginXml != null) { if (pluginXml != null) {
val pluginClassLoader = URLClassLoader(arrayOf(it.jarFile.get().toURI().toURL())) val pluginClassLoader = URLClassLoader(arrayOf(file.toURI().toURL()))
val thisPluginInfo = PluginInfo.readPluginXml(pluginXml, pluginClassLoader, scriptClassLoader) val thisPluginInfo = PluginInfo.readPluginXml(pluginXml, pluginClassLoader, scriptClassLoader)
pluginInfo.addPluginInfo(thisPluginInfo) pluginInfo.addPluginInfo(thisPluginInfo)
thisPluginInfo.plugins.forEach { thisPluginInfo.plugins.forEach {