Skip to content

Commit

Permalink
first really simple implementatation of a devices mojo
Browse files Browse the repository at this point in the history
  • Loading branch information
mosabua committed May 11, 2012
1 parent 4654bfe commit 5930241
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
Expand Up @@ -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;
}
}
@@ -0,0 +1,34 @@
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.
*
* @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));
}
}
);
}

}

0 comments on commit 5930241

Please sign in to comment.