Skip to content

Commit 35e4d8a

Browse files
riccardoblCopilot
andcommitted
support examples autorun
Co-authored-by: Copilot <copilot@github.com>
1 parent ed94043 commit 35e4d8a

3 files changed

Lines changed: 28 additions & 4 deletions

File tree

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,18 @@ You can optionally use the `-Pexample` property to specify an example to start w
125125
./gradlew runExamples -Pexample=jme3test.light.pbr.TestPBRSimple
126126
```
127127

128+
### Android examples
129+
130+
You can run the Android examples on a local android emulator with:
131+
132+
```bash
133+
./gradlew -PbuildAndroidExamples=true -PbuildNativeProjects=true runAndroidExamples
134+
# or for a specific example:
135+
# ./gradlew -PbuildAndroidExamples=true -PbuildNativeProjects=true runAndroidExamples -Pexample=jme3test.post.TestBloom
136+
```
137+
138+
*Make sure to have the SDK and NDK installed and configured properly, and the emulator running before executing the command.*
139+
128140

129141
## Running Tests
130142

jme3-android-examples/build.gradle

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ tasks.register('installAndroidExamples', Exec) {
110110

111111
tasks.register('runAndroidExamples', Exec) {
112112
group = 'application'
113-
description = 'Install and launch the Android examples selector on a connected emulator or device.'
113+
description = 'Install and launch Android examples on a connected emulator or device. Use -Pexample=<class> to run a specific test directly.'
114114

115115
dependsOn tasks.named('installAndroidExamples')
116116

@@ -120,10 +120,21 @@ tasks.register('runAndroidExamples', Exec) {
120120
throw new GradleException("ADB not found. Set -Pandroid.sdk.path, ANDROID_HOME, or ANDROID_SDK_ROOT.")
121121
}
122122
executable adbExecutable.absolutePath
123-
}
124123

125-
args 'shell', 'am', 'start',
126-
'-n', 'org.jmonkeyengine.jme3androidexamples/.MainActivity'
124+
def exampleClass = project.findProperty('example')?.toString()?.trim()
125+
if (exampleClass) {
126+
args 'shell', 'am', 'start',
127+
'-n', 'org.jmonkeyengine.jme3androidexamples/.TestActivity',
128+
'--es', 'Selected_App_Class', exampleClass,
129+
'--ez', 'Enable_Mouse_Events', 'true',
130+
'--ez', 'Enable_Joystick_Events', 'false',
131+
'--ez', 'Enable_Key_Events', 'true',
132+
'--ez', 'Verbose_Logging', 'false'
133+
} else {
134+
args 'shell', 'am', 'start',
135+
'-n', 'org.jmonkeyengine.jme3androidexamples/.MainActivity'
136+
}
137+
}
127138
}
128139

129140
def findAdbExecutable() {

jme3-android-examples/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
</activity>
2121
<activity
2222
android:name=".TestActivity"
23+
android:exported="true"
2324
android:label="@string/app_name"
2425
android:launchMode="singleTask"
2526
android:screenOrientation="landscape">

0 commit comments

Comments
 (0)