Skip to content

Commit 4587d14

Browse files
committed
Add logic to automatically pick up jar/aar library dependencies in the res://addons directory
1 parent 5e0805a commit 4587d14

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

platform/android/export/export_plugin.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3263,8 +3263,11 @@ Error EditorExportPlatformAndroid::export_project_helper(const Ref<EditorExportP
32633263
cmdline.push_back(apk_build_command);
32643264
}
32653265

3266+
String addons_directory = ProjectSettings::get_singleton()->globalize_path("res://addons");
3267+
32663268
cmdline.push_back("-p"); // argument to specify the start directory.
32673269
cmdline.push_back(build_path); // start directory.
3270+
cmdline.push_back("-Paddons_directory=" + addons_directory); // path to the addon directory as it may contain jar or aar dependencies
32683271
cmdline.push_back("-Pexport_package_name=" + package_name); // argument to specify the package name.
32693272
cmdline.push_back("-Pexport_version_code=" + version_code); // argument to specify the version code.
32703273
cmdline.push_back("-Pexport_version_name=" + version_name); // argument to specify the version name.

platform/android/java/app/build.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ dependencies {
6363
implementation files(pluginsBinaries)
6464
}
6565

66+
// Automatically pick up local dependencies in res://addons
67+
String addonsDirectory = getAddonsDirectory()
68+
if (addonsDirectory != null && !addonsDirectory.isBlank()) {
69+
implementation fileTree(dir: "$addonsDirectory", include: ['*.jar', '*.aar'])
70+
}
71+
6672
// .NET dependencies
6773
String jar = '../../../../modules/mono/thirdparty/libSystem.Security.Cryptography.Native.Android.jar'
6874
if (file(jar).exists()) {

platform/android/java/app/config.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,3 +408,8 @@ ext.shouldUseLegacyPackaging = { ->
408408
// Default behavior for minSdk >= 23
409409
return false
410410
}
411+
412+
ext.getAddonsDirectory = { ->
413+
String addonsDirectory = project.hasProperty("addons_directory") ? project.property("addons_directory") : ""
414+
return addonsDirectory
415+
}

0 commit comments

Comments
 (0)