Skip to content

Commit 4f58015

Browse files
author
Jakob Fahrner
committed
JENKINS-308 add property to set emulator start verbose
1 parent d6258f6 commit 4f58015

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ This plugin allows to manage Android emulators via gradle:
2121
### Gradle Commands
2222
| Command | Description |
2323
| --- | --- |
24-
| `./gradlew startEmulator [-Pemulator=EMULATOR_NAME] [-PlogcatFile=LOGCAT_NAME] [-Pci]` | Creates the emulator if necessary, then starts it, and disables animations globally. If you configured multiple emulators you need to select which via `-Pemulator`. The logcat file is automatically stored as logcat.txt. An emulator window will be shown by default, unless this runs on Jenkins or `-Pci` is used. |
25-
| `./gradlew startEmulatorWithAnimations [-Pemulator=EMULATOR_NAME] [-PlogcatFile=LOGCAT_NAME] [-Pci]` | Like `startEmulator` but enables global animations. |
24+
| `./gradlew startEmulator [-Pemulator=EMULATOR_NAME] [-PlogcatFile=LOGCAT_NAME] [-Pverbose=boolean] [-Pci]` | Creates the emulator if necessary, then starts it, and disables animations globally. If you configured multiple emulators you need to select which via `-Pemulator`. The logcat file is automatically stored as logcat.txt. An emulator window will be shown by default, unless this runs on Jenkins or `-Pci` is used. |
25+
| `./gradlew startEmulatorWithAnimations [-Pemulator=EMULATOR_NAME] [-PlogcatFile=LOGCAT_NAME] [-Pverbose=boolean] [-Pci]` | Like `startEmulator` but enables global animations. |
2626
| `./gradlew stopEmulator` | Stops the first emulator it finds. Running multiple emulators at the same time is not supported. |
2727
| `./gradlew adbDisableAnimationsGlobally` | Turns-off animations of the first running emulator it finds. |
2828
| `./gradlew adbResetAnimationsGlobally` | Turns-on animations of the first running emulator it finds. |

android-emulators-gradle/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ dependencies {
2929
}
3030

3131
group 'org.catrobat.gradle.androidemulators'
32-
version '1.6.1'
32+
version '1.6.2'
3333

3434
task sourcesJar(type: Jar) {
3535
classifier = 'sources'

android-emulators-gradle/src/main/groovy/org/catrobat/gradle/androidemulators/EmulatorStarter.groovy

+2-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class EmulatorStarter {
4141
* Starts the emulator asynchronously without checking for success.
4242
* @return EmulatorStarter process
4343
*/
44-
Process start(String avdName, File sdkDirectory, Map environment, boolean showWindow, File logcat) {
44+
Process start(String avdName, File sdkDirectory, Map environment, boolean showWindow, File logcat, boolean verbose) {
4545
def emulator = new CommandBuilder(Utils.joinPaths(sdkDirectory, 'emulator', 'emulator'), '.exe')
4646

4747
emulator.addArguments(['-avd', avdName])
@@ -51,6 +51,7 @@ class EmulatorStarter {
5151
emulator.addOptionalArguments(!showWindow, ['-no-window'])
5252
emulator.addOptionalArguments(!keepUserData, ['-wipe-data'])
5353
emulator.addOptionalArguments(logcat, ['-logcat-output', logcat.absolutePath])
54+
emulator.addOptionalArguments(verbose, ['-verbose'])
5455
emulator.addArguments(additionalParameters)
5556

5657
emulator.environment(environment).verbose().executeAsynchronously()

android-emulators-gradle/src/main/groovy/org/catrobat/gradle/androidemulators/EmulatorsPluginTasks.groovy

+8-6
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@ class EmulatorsPluginTasks {
4848
private void registerStartEmulatorTask(String name, boolean withAnimations) {
4949
registerTask(name, {
5050
description = 'Starts the android emulator. Use -Pemulator or EMULATOR_OVERRIDE to specify the emulator to use, ' +
51-
'and use -PlogcatFile to override the default logcat file logcat.txt.' +
52-
(withAnimations ? ' Global animations are enabled automatically.' : ' Global animations are disabled automatically.')
51+
'and use -PlogcatFile to override the default logcat file logcat.txt. ' +
52+
'For verbose mode use -Pverbose=true.' +
53+
(withAnimations ? ' Global animations are enabled automatically.' : ' Global animations are disabled automatically.')
5354
group = 'android'
5455

5556
doLast {
@@ -168,7 +169,7 @@ class EmulatorsPluginTasks {
168169
private Map<String, String> determineEnvironment() {
169170
def env = new HashMap(System.getenv())
170171

171-
def fallbackEnv = {k, v ->
172+
def fallbackEnv = { k, v ->
172173
if (!env.containsKey(k)) {
173174
println("ENV: Setting unspecified $k to [$v]")
174175
env[k.toString()] = v.toString()
@@ -190,7 +191,7 @@ class EmulatorsPluginTasks {
190191

191192
@TypeChecked(TypeCheckingMode.SKIP)
192193
private String propertyValue(String name, String defaultValue = null) {
193-
project.properties.get(name, defaultValue)
194+
project.properties.getOrDefault(name, defaultValue)
194195
}
195196

196197
private boolean showWindow() {
@@ -217,11 +218,12 @@ class EmulatorsPluginTasks {
217218

218219
def emulatorStarter = lookupEmulator(emulatorName).emulatorParameters
219220
def logcat = new File(propertyValue('logcatFile', 'logcat.txt'))
220-
proc = emulatorStarter.start(emulatorName, sdkDirectory(), determineEnvironment(), showWindow(), logcat)
221+
def verbose = (boolean) project.properties.getOrDefault('verbose', false)
222+
proc = emulatorStarter.start(emulatorName, sdkDirectory(), determineEnvironment(), showWindow(), logcat, verbose)
221223

222224
try {
223225
device = androidDevice(adb().waitForSerial())
224-
} catch(NoDeviceException e) {
226+
} catch (NoDeviceException e) {
225227
proc.waitForOrKill(1)
226228
throw e
227229
}

0 commit comments

Comments
 (0)