View Javadoc
1   package com.simpligility.maven.plugins.android.standalonemojos;
2   
3   import com.android.ddmlib.IDevice;
4   import com.simpligility.maven.plugins.android.AbstractAndroidMojo;
5   import com.simpligility.maven.plugins.android.DeviceCallback;
6   import com.simpligility.maven.plugins.android.common.DeviceHelper;
7   
8   import org.apache.maven.plugin.MojoExecutionException;
9   import org.apache.maven.plugin.MojoFailureException;
10  import org.apache.maven.plugins.annotations.Mojo;
11  
12  /**
13   * DevicesMojo lists all attached devices and emulators found with the android debug bridge. It uses the same
14   * naming convention for the emulator as used in other places in the Android Maven Plugin and adds the status
15   * of the device in the list.
16   * 
17   * TODO The goal is very simple and could be enhanced for better display, a verbose option to display and to take the
18   * android.device paramter into account.
19   *
20   * @author Manfred Moser - manfred@simpligility.com
21   */
22  @Mojo( name = "devices", requiresProject = false )
23  public class DevicesMojo extends AbstractAndroidMojo
24  {
25      /**
26       * Display a list of attached devices.
27       *
28       * @throws MojoExecutionException
29       * @throws MojoFailureException
30       */
31      public void execute() throws MojoExecutionException, MojoFailureException
32      {
33          doWithDevices( new DeviceCallback()
34          {
35              public void doWithDevice( final IDevice device ) throws MojoExecutionException
36              {
37                  getLog().info( DeviceHelper.getDescriptiveNameWithStatus( device ) );
38              }
39          } );
40      }
41  }