Skip to content

Commit

Permalink
Add logic to automatically pick up jar/aar library dependencies in th…
Browse files Browse the repository at this point in the history
…e `res://addons` directory
  • Loading branch information
m4gr3d committed Sep 26, 2024
1 parent b8ff2f1 commit 739ed91
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions platform/android/export/export_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3234,8 +3234,11 @@ Error EditorExportPlatformAndroid::export_project_helper(const Ref<EditorExportP
cmdline.push_back(apk_build_command);
}

String addons_directory = ProjectSettings::get_singleton()->globalize_path("res://addons");

cmdline.push_back("-p"); // argument to specify the start directory.
cmdline.push_back(build_path); // start directory.
cmdline.push_back("-Paddons_directory=" + addons_directory); // path to the addon directory as it may contain jar or aar dependencies
cmdline.push_back("-Pexport_package_name=" + package_name); // argument to specify the package name.
cmdline.push_back("-Pexport_version_code=" + version_code); // argument to specify the version code.
cmdline.push_back("-Pexport_version_name=" + version_name); // argument to specify the version name.
Expand Down
6 changes: 6 additions & 0 deletions platform/android/java/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ dependencies {
implementation files(pluginsBinaries)
}

// Automatically pick up local dependencies in res://addons
String addonsDirectory = getAddonsDirectory()
if (addonsDirectory != null && !addonsDirectory.isBlank()) {
implementation fileTree(dir: "$addonsDirectory", include: ['*.jar', '*.aar'])
}

// .NET dependencies
String jar = '../../../../modules/mono/thirdparty/libSystem.Security.Cryptography.Native.Android.jar'
if (file(jar).exists()) {
Expand Down
5 changes: 5 additions & 0 deletions platform/android/java/app/config.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -408,3 +408,8 @@ ext.shouldUseLegacyPackaging = { ->
// Default behavior for minSdk >= 23
return false
}

ext.getAddonsDirectory = { ->
String addonsDirectory = project.hasProperty("addons_directory") ? project.property("addons_directory") : ""
return addonsDirectory
}

0 comments on commit 739ed91

Please sign in to comment.