/**
 * Copyright 2012 Google Inc. All Rights Reserved.
 */
package com.google.appengine.appcfg;

import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;

/**
 * Rollback an in-progress update.
 *
 * @author Matt Stephenson <mattstep@google.com>
 * @goal rollback
 * @execute phase="package"
 */
public class Rollback extends AbstractAppCfgMojo {

  @Override
  public void execute() throws MojoExecutionException, MojoFailureException {

    getLog().info("");
    getLog().info("Google App Engine Java SDK - Rolling Back Application");
    getLog().info("");

    getLog().info("Retrieving Google App Engine Java SDK from Maven");
    resolveAndSetSdkRoot();

    String appDir = project.getBuild().getDirectory() + "/" + project.getBuild().getFinalName();

    getLog().info("Rolling Back Google App Engine Application");

    executeAppCfgCommand("rollback", appDir);
  }

}

@@ -90,16 +90,334 @@
 ppcfg;%0A%0A
+import com.google.appengine.tools.admin.Application;%0Aimport com.google.apphosting.utils.config.AppEngineApplicationXml;%0Aimport com.google.apphosting.utils.config.AppEngineApplicationXmlReader;%0Aimport com.google.apphosting.utils.config.EarHelper;%0Aimport com.google.apphosting.utils.config.EarInfo;%0Aimport java.io.File;%0A
 import o
@@ -459,24 +459,24 @@
 nException;%0A
-
 import org.a
@@ -1184,24 +1184,739 @@
 ication%22);%0A%0A
+    if (EarHelper.isEar(appDir, false)) %7B%0A      EarInfo earInfo = EarHelper.readEarInfo(appDir,%0A              new File(Application.getSdkDocsDir(), %22appengine-application.xsd%22));%0A      if (appId == null) %7B%0A        appId = earInfo.getAppengineApplicationXml().getApplicationId();%0A      %7D%0A      File ear = new File(appDir);%0A      for (File w : ear.listFiles()) %7B%0A        if (new File(w, %22WEB-INF/appengine-web.xml%22).exists()) %7B%0A          getLog().info(%22Rolling Back Google App Engine module: %22 + w.getAbsolutePath());%0A          executeAppCfgCommand(%22rollback%22, w.getAbsolutePath());%0A        %7D%0A      %7D%0A    %7D else %7B%0A      // rollback the application%0A      getLog().info(%22Rolling Back Google App Engine Application%22);%0A  
     executeA
@@ -1949,15 +1949,21 @@
 ppDir);%0A
+    %7D%0A
   %7D%0A%0A%7D%0A

support rollback for EAR projects.