Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Devices #117

Merged
merged 2 commits into from

1 participant

Manfred Moser
Manfred Moser
Owner

an new simple mojo to display the list of attached devices using the same naming convention as used in the rest of the plugin to make it easier to know which device is which.

Manfred Moser mosabua merged commit 7883d7a into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 11, 2012
  1. Manfred Moser
Commits on May 22, 2012
  1. Manfred Moser

    minor documentation added

    mosabua authored
This page is out of date. Refresh to see the latest.
14 src/main/java/com/jayway/maven/plugins/android/common/DeviceHelper.java
View
@@ -54,4 +54,18 @@ public static String getModel(IDevice device) {
return StringUtils.deleteWhitespace(device.getProperty(MODEL_PROPERTY));
}
+ /**
+ * @return the descriptive name with online/offline/unknown status string appended.
+ */
+ public static String getDescriptiveNameWithStatus(IDevice device) {
+ String status;
+ if (device.isOnline()) {
+ status = "Online";
+ } else if (device.isOffline()) {
+ status = "Offline";
+ } else {
+ status = "Unknown";
+ }
+ return getDescriptiveName(device) + " " + status;
+ }
}
38 src/main/java/com/jayway/maven/plugins/android/standalonemojos/DevicesMojo.java
View
@@ -0,0 +1,38 @@
+package com.jayway.maven.plugins.android.standalonemojos;
+
+import com.android.ddmlib.IDevice;
+import com.jayway.maven.plugins.android.AbstractAndroidMojo;
+import com.jayway.maven.plugins.android.DeviceCallback;
+import com.jayway.maven.plugins.android.common.DeviceHelper;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+
+/**
+ * DevicesMojo lists all attached devices and emulators found with the android debug bridge. It uses the same
+ * naming convention for the emulator as used in other places in the Android Maven Plugin and adds the status
+ * of the device in the list.
+ *
+ * TODO The goal is very simple and could be enhanced for better display, a verbose option to display and to take the
+ * android.device paramter into account.
+ *
+ * @author Manfred Moser <manfred@simpligility.com>
+ * @goal devices
+ * @requiresProject false
+ */
+public class DevicesMojo extends AbstractAndroidMojo {
+ /**
+ * Display a list of attached devices.
+ *
+ * @throws org.apache.maven.plugin.MojoExecutionException
+ * @throws org.apache.maven.plugin.MojoFailureException
+ */
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ doWithDevices(
+ new DeviceCallback() {
+ public void doWithDevice(final IDevice device) throws MojoExecutionException {
+ getLog().info(DeviceHelper.getDescriptiveNameWithStatus(device));
+ }
+ }
+ );
+ }
+}
Something went wrong with that request. Please try again.