diff options
author | Fredia Huya-Kouadio <fhuya@meta.com> | 2023-08-17 14:23:04 -0700 |
---|---|---|
committer | Fredia Huya-Kouadio <fhuya@meta.com> | 2023-08-17 14:35:56 -0700 |
commit | f42745b1d88e7ad563f1fd9668c04ed8b261189b (patch) | |
tree | 98032a8f560ec51d0a5a8cd58f820d0df02eda17 | |
parent | 49ef8e3d93b335967361640e77c97a220e4339f3 (diff) | |
download | godot-android-samples-f42745b1d88e7ad563f1fd9668c04ed8b261189b.tar.gz godot-android-samples-f42745b1d88e7ad563f1fd9668c04ed8b261189b.tar.bz2 godot-android-samples-f42745b1d88e7ad563f1fd9668c04ed8b261189b.zip |
Update the 'Hello World' plugin sample to match updates to the addon's folder structure
14 files changed, 50 insertions, 16 deletions
diff --git a/plugins/hello_world/README.md b/plugins/hello_world/README.md index 5cfb640..19b0dff 100644 --- a/plugins/hello_world/README.md +++ b/plugins/hello_world/README.md @@ -1,3 +1,18 @@ ## Hello World plugin Showcase how to build a simple Godot Android plugin which is invoked from gdscript + +### Building the Hello World plugin + +Use the following commands to build the plugin: + +``` +cd Godot-Android-Samples +./gradlew :plugins:hello_world:assemble +``` + +The generated artifact can be found under [`demo/addons`](demo/addons). + +### Usage + +Open the [`demo`](demo) project in the Godot Editor diff --git a/plugins/hello_world/build.gradle b/plugins/hello_world/build.gradle index 4c12e93..b948b11 100644 --- a/plugins/hello_world/build.gradle +++ b/plugins/hello_world/build.gradle @@ -13,9 +13,11 @@ android { versionName "1.0" } + namespace = "fhuyakou.godot.plugin.android.helloworld" + // Used to customize the name of generated AAR file. - libraryVariants.all { variant -> - variant.outputs.all { output -> + libraryVariants.configureEach { variant -> + variant.outputs.configureEach { output -> output.outputFileName = "HelloWorld.${variant.name}.aar" } } @@ -23,21 +25,34 @@ android { } dependencies { - compileOnly "org.godotengine:godot:$versions.godotLibVersion" + // TODO: Update the godot dep when 4.2 is stable + compileOnly "io.github.m4gr3d:godot:4.2.0.dev-SNAPSHOT" implementation "org.jetbrains.kotlin:kotlin-stdlib:$versions.kotlinVersion" } -task copyDebugAARToAddons(type: Copy) { +tasks.register('copyDebugAARToAddons', Copy) { from 'build/outputs/aar' include 'HelloWorld.debug.aar' - into 'demo/addons/hello_world_plugin/export' + into 'src/main/assets/addons/hello_world_plugin/.bin/debug' } -task copyReleaseAARToAddons(type: Copy) { +tasks.register('copyReleaseAARToAddons', Copy) { from 'build/outputs/aar' include 'HelloWorld.release.aar' - into 'demo/addons/hello_world_plugin/export' + into 'src/main/assets/addons/hello_world_plugin/.bin/release' +} + +tasks.register('copyAddonsToDemo', Copy) { + dependsOn(copyDebugAARToAddons) + dependsOn(copyReleaseAARToAddons) + + doFirst { + delete('demo/addons/hello_world_plugin') + } + from 'src/main/assets/addons/hello_world_plugin' + into 'demo/addons/hello_world_plugin' } assemble.finalizedBy(copyDebugAARToAddons) assemble.finalizedBy(copyReleaseAARToAddons) +assemble.finalizedBy(copyAddonsToDemo) diff --git a/plugins/hello_world/demo/addons/.gitignore b/plugins/hello_world/demo/addons/.gitignore new file mode 100644 index 0000000..d6b7ef3 --- /dev/null +++ b/plugins/hello_world/demo/addons/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/plugins/hello_world/demo/addons/hello_world_plugin/export/HelloWorld.debug.aar b/plugins/hello_world/demo/addons/hello_world_plugin/export/HelloWorld.debug.aar Binary files differdeleted file mode 100644 index 4d59e06..0000000 --- a/plugins/hello_world/demo/addons/hello_world_plugin/export/HelloWorld.debug.aar +++ /dev/null diff --git a/plugins/hello_world/demo/addons/hello_world_plugin/export/HelloWorld.release.aar b/plugins/hello_world/demo/addons/hello_world_plugin/export/HelloWorld.release.aar Binary files differdeleted file mode 100644 index 6b112c5..0000000 --- a/plugins/hello_world/demo/addons/hello_world_plugin/export/HelloWorld.release.aar +++ /dev/null diff --git a/plugins/hello_world/demo/export_presets.cfg b/plugins/hello_world/demo/export_presets.cfg index 6356705..ab3d98a 100644 --- a/plugins/hello_world/demo/export_presets.cfg +++ b/plugins/hello_world/demo/export_presets.cfg @@ -8,7 +8,7 @@ custom_features="" export_filter="all_resources" include_filter="" exclude_filter="" -export_path="android/Hello World Plugin Demo.apk" +export_path="" encryption_include_filters="" encryption_exclude_filters="" encrypt_pck=false diff --git a/plugins/hello_world/src/main/AndroidManifest.xml b/plugins/hello_world/src/main/AndroidManifest.xml index 8bb5fa4..ef98274 100644 --- a/plugins/hello_world/src/main/AndroidManifest.xml +++ b/plugins/hello_world/src/main/AndroidManifest.xml @@ -1,11 +1,10 @@ -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="fhuyakou.godot.plugin.android.helloworld"> +<manifest xmlns:android="http://schemas.android.com/apk/res/android"> <application> <!-- Plugin metadata: - - In the `android:name` attribute, the `org.godotengine.plugin.v1` prefix + - In the `android:name` attribute, the `org.godotengine.plugin.v2` prefix is required so Godot can recognize the project as a valid Godot Android plugin. The plugin name following the prefix should match the value of the plugin name returned by the plugin initializer. @@ -14,7 +13,7 @@ initializer. --> <meta-data - android:name="org.godotengine.plugin.v1.HelloWorld" + android:name="org.godotengine.plugin.v2.HelloWorld" android:value="fhuyakou.godot.plugin.android.helloworld.HelloWorldPlugin" /> </application> </manifest> diff --git a/plugins/hello_world/src/main/assets/addons/hello_world_plugin/.bin/.gdignore b/plugins/hello_world/src/main/assets/addons/hello_world_plugin/.bin/.gdignore new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/plugins/hello_world/src/main/assets/addons/hello_world_plugin/.bin/.gdignore @@ -0,0 +1 @@ + diff --git a/plugins/hello_world/src/main/assets/addons/hello_world_plugin/.bin/.gitignore b/plugins/hello_world/src/main/assets/addons/hello_world_plugin/.bin/.gitignore new file mode 100644 index 0000000..375ed0d --- /dev/null +++ b/plugins/hello_world/src/main/assets/addons/hello_world_plugin/.bin/.gitignore @@ -0,0 +1,3 @@ +* +!.gitignore +!.gdignore diff --git a/plugins/hello_world/demo/addons/hello_world_plugin/export/.gdignore b/plugins/hello_world/src/main/assets/addons/hello_world_plugin/.export/.gdignore index e69de29..e69de29 100644 --- a/plugins/hello_world/demo/addons/hello_world_plugin/export/.gdignore +++ b/plugins/hello_world/src/main/assets/addons/hello_world_plugin/.export/.gdignore diff --git a/plugins/hello_world/demo/addons/hello_world_plugin/export/hello_world_editor_export_plugin.gd b/plugins/hello_world/src/main/assets/addons/hello_world_plugin/.export/hello_world_editor_export_plugin.gd index 46a8a3b..8137718 100644 --- a/plugins/hello_world/demo/addons/hello_world_plugin/export/hello_world_editor_export_plugin.gd +++ b/plugins/hello_world/src/main/assets/addons/hello_world_plugin/.export/hello_world_editor_export_plugin.gd @@ -8,9 +8,9 @@ func _supports_platform(platform): func _get_android_libraries(platform, debug): if debug: - return PackedStringArray(["hello_world_plugin/export/HelloWorld.debug.aar"]) + return PackedStringArray(["hello_world_plugin/.bin/debug/HelloWorld.debug.aar"]) else: - return PackedStringArray(["hello_world_plugin/export/HelloWorld.release.aar"]) + return PackedStringArray(["hello_world_plugin/.bin/release/HelloWorld.release.aar"]) func _get_name(): return "HelloWorldPlugin" diff --git a/plugins/hello_world/demo/addons/hello_world_plugin/export/hello_world_editor_plugin.gd b/plugins/hello_world/src/main/assets/addons/hello_world_plugin/.export/hello_world_editor_plugin.gd index 3865634..85be8ad 100644 --- a/plugins/hello_world/demo/addons/hello_world_plugin/export/hello_world_editor_plugin.gd +++ b/plugins/hello_world/src/main/assets/addons/hello_world_plugin/.export/hello_world_editor_plugin.gd @@ -8,7 +8,6 @@ func _enter_tree(): # Initialization of the plugin goes here. export_plugin = preload("hello_world_editor_export_plugin.gd").new() add_export_plugin(export_plugin) - pass func _exit_tree(): diff --git a/plugins/hello_world/demo/addons/hello_world_plugin/interface/hello_world_plugin.gd b/plugins/hello_world/src/main/assets/addons/hello_world_plugin/interface/hello_world_plugin.gd index ed84ef3..ed84ef3 100644 --- a/plugins/hello_world/demo/addons/hello_world_plugin/interface/hello_world_plugin.gd +++ b/plugins/hello_world/src/main/assets/addons/hello_world_plugin/interface/hello_world_plugin.gd diff --git a/plugins/hello_world/demo/addons/hello_world_plugin/plugin.cfg b/plugins/hello_world/src/main/assets/addons/hello_world_plugin/plugin.cfg index bc8575e..9428d75 100644 --- a/plugins/hello_world/demo/addons/hello_world_plugin/plugin.cfg +++ b/plugins/hello_world/src/main/assets/addons/hello_world_plugin/plugin.cfg @@ -4,4 +4,4 @@ name="HelloWorldPlugin" description="Sample to showcase how to package a Godot Android plugin " author="Fredia Huya-Kouadio (m4gr3d)" version="" -script="export/hello_world_editor_plugin.gd" +script=".export/hello_world_editor_plugin.gd" |