Updated Plugin-API version as it has recived updates since 0.1.0, but yet dine to be in 1.0 release
build / build (push) Has been cancelled
build / build (push) Has been cancelled
Updeaded the RPCP loader to use JarFile instead of a virtual FS Signed-off-by: zacharias <alienfromdia@proton.me>
This commit is contained in:
@@ -849,7 +849,7 @@ public class Core {
|
|||||||
pluginJsonData.append(tmp);
|
pluginJsonData.append(tmp);
|
||||||
}
|
}
|
||||||
JSONObject pluginJson = new JSONObject(pluginJsonData.toString());
|
JSONObject pluginJson = new JSONObject(pluginJsonData.toString());
|
||||||
LoadedPlugin plugin = loader.loadPlugin(pluginJson, file.toPath(), data);
|
LoadedPlugin plugin = loader.loadPlugin(pluginJson, jar, file.toPath(), data);
|
||||||
|
|
||||||
data.addPlugin(plugin);
|
data.addPlugin(plugin);
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ import java.nio.file.Files;
|
|||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.jar.JarEntry;
|
||||||
|
import java.util.jar.JarFile;
|
||||||
|
|
||||||
import static me.neurodock.plugin.Plugin.UNKNOWN_PLUGIN;
|
import static me.neurodock.plugin.Plugin.UNKNOWN_PLUGIN;
|
||||||
|
|
||||||
@@ -79,7 +81,9 @@ public class Loader {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
// Replaces the toString which is used thru out the Core and OllamaObject to get the JSON representation of a Function Tool
|
// Replaces the toString which is used throughout the Core and OllamaObject to get the JSON representation of a Function Tool
|
||||||
|
// Ideally the toString method SHULD NOT be used like this, while yes a JSON representation is better than a Java Hash representation
|
||||||
|
// the toString should not be utilized or overwritten in this manner
|
||||||
return tool.getToolJSON();
|
return tool.getToolJSON();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -89,13 +93,13 @@ public class Loader {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public LoadedPlugin loadPlugin(JSONObject pluginJson, Path pluginJar, Data data) {
|
public LoadedPlugin loadPlugin(JSONObject pluginJson, JarFile jar, Path pluginJar, Data data) {
|
||||||
if(!pluginJson.has("name") || !(pluginJson.get("name") instanceof String pluginName))
|
if(!pluginJson.has("name") || !(pluginJson.get("name") instanceof String pluginName))
|
||||||
throw new PluginLoadingException("Malformed plugin json", UNKNOWN_PLUGIN);
|
throw new PluginLoadingException("Malformed plugin json", UNKNOWN_PLUGIN);
|
||||||
if(!pluginJson.has("entryPoint") || !(pluginJson.get("entryPoint") instanceof String pluginEntryPoint))
|
if(!pluginJson.has("entryPoint") || !(pluginJson.get("entryPoint") instanceof String pluginEntryPoint))
|
||||||
throw new PluginLoadingException("Malformed plugin json", pluginName);
|
throw new PluginLoadingException("Malformed plugin json", pluginName);
|
||||||
Path pluginEntryPointFile = fs.getPath("/"+pluginEntryPoint.replaceAll("\\.", "/")+".class");
|
JarEntry entry = jar.getJarEntry(pluginEntryPoint.replaceAll("\\.", "/"));
|
||||||
if(!Files.exists(pluginEntryPointFile)) throw new PluginLoadingException("Missing plugin entrypoint", pluginName);
|
if(entry == null) throw new PluginLoadingException("Missing plugin entrypoint", pluginName);
|
||||||
|
|
||||||
Plugin plugin = null;
|
Plugin plugin = null;
|
||||||
URLClassLoader classLoader;
|
URLClassLoader classLoader;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ plugins {
|
|||||||
id 'java-library'
|
id 'java-library'
|
||||||
}
|
}
|
||||||
|
|
||||||
version = '0.1.0'
|
version = '0.1.2'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
@@ -12,6 +12,7 @@ dependencies {
|
|||||||
|
|
||||||
implementation 'io.github.classgraph:classgraph:4.8.184'
|
implementation 'io.github.classgraph:classgraph:4.8.184'
|
||||||
api "org.json:json:20250107"
|
api "org.json:json:20250107"
|
||||||
|
api "org.jetbrains:annotations:23.1.0"
|
||||||
|
|
||||||
|
|
||||||
testImplementation platform('org.junit:junit-bom:6.0.0')
|
testImplementation platform('org.junit:junit-bom:6.0.0')
|
||||||
|
|||||||
Reference in New Issue
Block a user