Implementation of the Godot Android Plugin configuration file

This commit is contained in:
Fredia Huya-Kouadio 2020-04-24 00:45:14 -07:00
parent 163687d17a
commit 14e6696c8e
11 changed files with 534 additions and 54 deletions

View file

@ -58,7 +58,9 @@ public final class GodotPluginRegistry {
/**
* Name for the metadata containing the list of Godot plugins to enable.
*/
private static final String GODOT_ENABLED_PLUGINS_LABEL = "custom_template_plugins";
private static final String GODOT_ENABLED_PLUGINS_LABEL = "plugins";
private static final String PLUGIN_VALUE_SEPARATOR_REGEX = "\\|";
private static GodotPluginRegistry instance;
private final ConcurrentHashMap<String, GodotPlugin> registry;
@ -128,13 +130,13 @@ public final class GodotPluginRegistry {
}
// When using the Godot editor for building and exporting the apk, this is used to check
// which plugins to enable since the custom build template may contain prebuilt plugins.
// which plugins to enable.
// When using a custom process to generate the apk, the metadata is not needed since
// it's assumed that the developer is aware of the dependencies included in the apk.
final Set<String> enabledPluginsSet;
if (metaData.containsKey(GODOT_ENABLED_PLUGINS_LABEL)) {
String enabledPlugins = metaData.getString(GODOT_ENABLED_PLUGINS_LABEL, "");
String[] enabledPluginsList = enabledPlugins.split(",");
String[] enabledPluginsList = enabledPlugins.split(PLUGIN_VALUE_SEPARATOR_REGEX);
if (enabledPluginsList.length == 0) {
// No plugins to enable. Aborting early.
return;
@ -158,6 +160,8 @@ public final class GodotPluginRegistry {
continue;
}
Log.i(TAG, "Initializing Godot plugin " + pluginName);
// Retrieve the plugin class full name.
String pluginHandleClassFullName = metaData.getString(metaDataName);
if (!TextUtils.isEmpty(pluginHandleClassFullName)) {
@ -177,6 +181,7 @@ public final class GodotPluginRegistry {
"Meta-data plugin name does not match the value returned by the plugin handle: " + pluginName + " =/= " + pluginHandle.getPluginName());
}
registry.put(pluginName, pluginHandle);
Log.i(TAG, "Completed initialization for Godot plugin " + pluginHandle.getPluginName());
} catch (ClassNotFoundException e) {
Log.w(TAG, "Unable to load Godot plugin " + pluginName, e);
} catch (IllegalAccessException e) {