/**
 * Copyright 2013 Google Inc. All Rights Reserved.
 */
package com.google.appengine.endpoints;

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

import java.io.File;
import java.util.ArrayList;
import java.util.List;

/**
 * App Engine endpoints get-discovery-doc command.
 *
 * @author Ludovic Champenois ludo at google dot com
 * @goal endpoints_get_discovery_doc
 * @phase compile
 */
public class EndpointsGetDiscoveryDoc extends EndpointsMojo {

  @Override
  protected ArrayList<String> collectParameters(String command) {
    ArrayList<String> arguments = new ArrayList<String>();
    arguments.add(command);
    handleClassPath(arguments);
    if (outputDirectory != null && !outputDirectory.isEmpty()) {
      arguments.add("-o");
      arguments.add(outputDirectory + "/WEB-INF");
      new File(outputDirectory).mkdirs();
    }
    arguments.add("-w");
    arguments.add(outputDirectory);
    return arguments;
  }

  @Override
  public void execute() throws MojoExecutionException, MojoFailureException {
    getLog().info("");
    getLog().info("Google App Engine Java SDK - get endpoints discovery doc...");
    List<String> classNames = getAPIServicesClasses();
    if (classNames.isEmpty()) {
      getLog().info("No Endpoints classes detected.");
      return;
    }
    String rest[] = {"-f", "rest"};
    executeEndpointsCommand("get-discovery-doc", rest,
                    classNames.toArray(new String[classNames.size()]));
    String rpc[] = {"-f", "rpc"};
    executeEndpointsCommand("get-discovery-doc", rpc,
                    classNames.toArray(new String[classNames.size()]));
    getLog().info("Endpoints discovery doc generation done.");

  }
}

@@ -1366,23 +1366,11 @@
  = %7B
-%22-f%22, %22rest%22
 %7D;%0A
+
     
@@ -1496,168 +1496,8 @@
 ));%0A
-    String rpc%5B%5D = %7B%22-f%22, %22rpc%22%7D;%0A    executeEndpointsCommand(%22get-discovery-doc%22, rpc,%0A                    classNames.toArray(new String%5BclassNames.size()%5D));%0A
     
@@ -1534,16 +1534,29 @@
 very doc
+ (Rest style)
  generat

Fix for https://github.com/GoogleCloudPlatform/appengine-maven-plugin/issues/81.