// Path: api/src/main/java/com/github/chrisprice/phonegapbuild/api/data/HasResourceIdAndPath.java
// public interface HasResourceIdAndPath<T extends AbstractResource> extends HasResourceId<T>,
//  HasResourcePath<T> {
// 
// }
// 
// Path: api/src/main/java/com/github/chrisprice/phonegapbuild/api/data/me/MeResponse.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class MeResponse implements HasResourceIdAndPath<Me> {
// 
//   private String username;
//   private String email;
//   private MeAppsResponse apps;
//   private MeKeysResponse keys;
//   @JsonProperty("id")
//   private ResourceId<Me> resourceId;
//   @JsonProperty("link")
//   private ResourcePath<Me> resourcePath;
// 
//   @Override
//   public ResourceId<Me> getResourceId() {
//     return resourceId;
//   }
// 
//   public void setResourceId(ResourceId<Me> resourceId) {
//     this.resourceId = resourceId;
//   }
// 
//   @Override
//   public ResourcePath<Me> getResourcePath() {
//     return resourcePath;
//   }
// 
//   public void setResourcePath(ResourcePath<Me> resourcePath) {
//     this.resourcePath = resourcePath;
//   }
// 
//   public String getUsername() {
//     return username;
//   }
// 
//   public void setUsername(String username) {
//     this.username = username;
//   }
// 
//   public String getEmail() {
//     return email;
//   }
// 
//   public void setEmail(String email) {
//     this.email = email;
//   }
// 
//   public MeAppsResponse getApps() {
//     return apps;
//   }
// 
//   public void setApps(MeAppsResponse apps) {
//     this.apps = apps;
//   }
// 
//   public MeKeysResponse getKeys() {
//     return keys;
//   }
// 
//   public void setKeys(MeKeysResponse keys) {
//     this.keys = keys;
//   }
// 
// }
// 
// Path: api/src/main/java/com/github/chrisprice/phonegapbuild/api/data/resources/App.java
// public class App extends AbstractResource {
// 
// }
// 
// Path: api/src/main/java/com/github/chrisprice/phonegapbuild/api/data/resources/Key.java
// public class Key extends AbstractResource {
// 
// }
// 
// Path: plugin/src/main/java/com/github/chrisprice/phonegapbuild/plugin/utils/ResourceIdStore.java
// public interface ResourceIdStore<T extends AbstractResource> {
// 
//   public HasResourceIdAndPath<T> load(HasResourceIdAndPath<T>[] remoteResources);
// 
//   public void save(ResourceId<T> resourceId);
// 
//   public void clear();
// 
//   public void setAlias(String alias);
// 
//   public void setWorkingDirectory(File workingDirectory);
// 
//   public void setIdOverride(Integer overrideId);
// 
// }


import java.io.File;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import com.github.chrisprice.phonegapbuild.api.data.HasResourceIdAndPath;
import com.github.chrisprice.phonegapbuild.api.data.me.MeResponse;
import com.github.chrisprice.phonegapbuild.api.data.resources.App;
import com.github.chrisprice.phonegapbuild.api.data.resources.Key;
import com.github.chrisprice.phonegapbuild.plugin.utils.ResourceIdStore;
import com.sun.jersey.api.client.WebResource;
package com.github.chrisprice.phonegapbuild.plugin;




/**
 * Delete the cloud app and keys if found.
 * 
 * @goal clean
 * @phase pre-clean
 */
public class CleanMojo extends AbstractPhoneGapBuildMojo {
  /**
   * Working directory.
   * 
   * @parameter expression="${project.build.directory}/phonegap-build"
   * @readonly
   */
  private File workingDirectory;

  /**
   * @component role="com.github.chrisprice.phonegapbuild.plugin.utils.ResourceIdStore"
   */
  private ResourceIdStore<App> appIdStore;

  /**
   * @component role="com.github.chrisprice.phonegapbuild.plugin.utils.ResourceIdStore"
   */
  private ResourceIdStore<Key> keyIdStore;

  public void execute() throws MojoExecutionException, MojoFailureException {
    getLog().debug("Authenticating.");

    WebResource webResource = getRootWebResource();

    getLog().debug("Requesting summary from cloud.");

    MeResponse me = meManager.requestMe(webResource);

    getLog().debug("Checking for existing app.");

    appIdStore.setAlias("app");
    appIdStore.setWorkingDirectory(workingDirectory);
    HasResourceIdAndPath<App> appSummary = appIdStore.load(me.getApps().getAll());

// Path: api/src/main/java/com/github/chrisprice/phonegapbuild/api/data/HasResourceIdAndPath.java
// public interface HasResourceIdAndPath<T extends AbstractResource> extends HasResourceId<T>,
//  HasResourcePath<T> {
// 
// }
// 
// Path: api/src/main/java/com/github/chrisprice/phonegapbuild/api/data/me/MeResponse.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class MeResponse implements HasResourceIdAndPath<Me> {
// 
//   private String username;
//   private String email;
//   private MeAppsResponse apps;
//   private MeKeysResponse keys;
//   @JsonProperty("id")
//   private ResourceId<Me> resourceId;
//   @JsonProperty("link")
//   private ResourcePath<Me> resourcePath;
// 
//   @Override
//   public ResourceId<Me> getResourceId() {
//     return resourceId;
//   }
// 
//   public void setResourceId(ResourceId<Me> resourceId) {
//     this.resourceId = resourceId;
//   }
// 
//   @Override
//   public ResourcePath<Me> getResourcePath() {
//     return resourcePath;
//   }
// 
//   public void setResourcePath(ResourcePath<Me> resourcePath) {
//     this.resourcePath = resourcePath;
//   }
// 
//   public String getUsername() {
//     return username;
//   }
// 
//   public void setUsername(String username) {
//     this.username = username;
//   }
// 
//   public String getEmail() {
//     return email;
//   }
// 
//   public void setEmail(String email) {
//     this.email = email;
//   }
// 
//   public MeAppsResponse getApps() {
//     return apps;
//   }
// 
//   public void setApps(MeAppsResponse apps) {
//     this.apps = apps;
//   }
// 
//   public MeKeysResponse getKeys() {
//     return keys;
//   }
// 
//   public void setKeys(MeKeysResponse keys) {
//     this.keys = keys;
//   }
// 
// }
// 
// Path: api/src/main/java/com/github/chrisprice/phonegapbuild/api/data/resources/App.java
// public class App extends AbstractResource {
// 
// }
// 
// Path: api/src/main/java/com/github/chrisprice/phonegapbuild/api/data/resources/Key.java
// public class Key extends AbstractResource {
// 
// }
// 
// Path: plugin/src/main/java/com/github/chrisprice/phonegapbuild/plugin/utils/ResourceIdStore.java
// public interface ResourceIdStore<T extends AbstractResource> {
// 
//   public HasResourceIdAndPath<T> load(HasResourceIdAndPath<T>[] remoteResources);
// 
//   public void save(ResourceId<T> resourceId);
// 
//   public void clear();
// 
//   public void setAlias(String alias);
// 
//   public void setWorkingDirectory(File workingDirectory);
// 
//   public void setIdOverride(Integer overrideId);
// 
// }


// Path: plugin/src/main/java/com/github/chrisprice/phonegapbuild/plugin/CleanMojo.java
import java.io.File;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import com.github.chrisprice.phonegapbuild.api.data.HasResourceIdAndPath;
import com.github.chrisprice.phonegapbuild.api.data.me.MeResponse;
import com.github.chrisprice.phonegapbuild.api.data.resources.App;
import com.github.chrisprice.phonegapbuild.api.data.resources.Key;
import com.github.chrisprice.phonegapbuild.plugin.utils.ResourceIdStore;
import com.sun.jersey.api.client.WebResource;

package com.github.chrisprice.phonegapbuild.plugin;




/**
 * Delete the cloud app and keys if found.
 * 
 * @goal clean
 * @phase pre-clean
 */
public class CleanMojo extends AbstractPhoneGapBuildMojo {
  /**
   * Working directory.
   * 
   * @parameter expression="${project.build.directory}/phonegap-build"
   * @readonly
   */
  private File workingDirectory;

  /**
   * @component role="com.github.chrisprice.phonegapbuild.plugin.utils.ResourceIdStore"
   */
  private ResourceIdStore<App> appIdStore;

  /**
   * @component role="com.github.chrisprice.phonegapbuild.plugin.utils.ResourceIdStore"
   */
  private ResourceIdStore<Key> keyIdStore;

  public void execute() throws MojoExecutionException, MojoFailureException {
    getLog().debug("Authenticating.");

    WebResource webResource = getRootWebResource();

    getLog().debug("Requesting summary from cloud.");

    MeResponse me = meManager.requestMe(webResource);

    getLog().debug("Checking for existing app.");

    appIdStore.setAlias("app");
    appIdStore.setWorkingDirectory(workingDirectory);
    HasResourceIdAndPath<App> appSummary = appIdStore.load(me.getApps().getAll());

    if (appSummary != null) {