// Path: heroku-deploy/src/main/java/com/heroku/sdk/deploy/lib/OutputAdapter.java
// public interface OutputAdapter {
//     void logInfo(String message);
//     void logDebug(String message);
//     void logWarn(String message);
//     void logError(String message);
//     void logUploadProgress(long uploaded, long contentLength);
// 
//     default void logError(String message, Throwable t) {
//         logError(message);
//         logDebug(Arrays.stream(t.getStackTrace()).map(StackTraceElement::toString).collect(Collectors.joining("\n")));
//     }
// }
// 
// Path: heroku-deploy/src/main/java/com/heroku/sdk/deploy/lib/running/RunWebApp.java
// public class RunWebApp {
// 
//     public static void run(Path warFile, List<String> javaOptions, List<String> webappRunnerOptions, String webappRunnerVersion, OutputAdapter outputAdapter) throws IOException, InterruptedException {
//         outputAdapter.logInfo("Downloading webapp-runner...");
//         Path webappRunnerJarPath = null;
//         try {
//              webappRunnerJarPath = FileDownloader.download(WebappRunnerResolver.getUrlForVersion(webappRunnerVersion));
//         } catch (FileNotFoundException e) {
//             outputAdapter.logDebug(String.format("Could not download webapp-runner %s. Please check if this is a valid version.", webappRunnerVersion));
//             System.exit(-1);
//         }
// 
//         ArrayList<String> command = new ArrayList<>();
//         command.add(System.getProperty("java.home") + File.separator + "bin" + File.separator + "java");
//         command.addAll(javaOptions);
//         command.add("-jar");
//         command.add(webappRunnerJarPath.toString());
//         command.addAll(webappRunnerOptions);
//         command.add(warFile.toString());
// 
//         ProcessBuilder processBuilder = new ProcessBuilder(command.toArray(new String[0]));
//         Process process = processBuilder.start();
// 
//         StreamGobbler stdOutStreamGobbler = new StreamGobbler(process.getInputStream(), outputAdapter);
//         StreamGobbler stdErrStreamGobbler = new StreamGobbler(process.getErrorStream(), outputAdapter);
// 
//         stdOutStreamGobbler.start();
//         stdErrStreamGobbler.start();
// 
//         process.waitFor();
//     }
// 
//     private static class StreamGobbler extends Thread {
//         private InputStream inputStream;
//         private OutputAdapter outputAdapter;
// 
//         public StreamGobbler(InputStream inputStream, OutputAdapter outputAdapter) {
//             super("StreamGobbler");
//             this.inputStream = inputStream;
//             this.outputAdapter = outputAdapter;
//         }
// 
//         public void run() {
//             try {
//                 BufferedReader br = new BufferedReader(new InputStreamReader(inputStream));
//                 String line;
// 
//                 while ((line = br.readLine()) != null) {
//                     outputAdapter.logInfo(line);
//                 }
//             } catch (IOException e) {
//                 outputAdapter.logError(e.getMessage(), e);
//                 throw new RuntimeException(e);
//             }
//         }
//     }
// }
// 
// Path: heroku-deploy-standalone/src/main/java/com/heroku/sdk/deploy/standalone/StdOutOutputAdapter.java
// public class StdOutOutputAdapter implements OutputAdapter {
//     private boolean suppressUploadProgress;
// 
//     public StdOutOutputAdapter(boolean suppressUploadProgress) {
//         this.suppressUploadProgress = suppressUploadProgress;
//     }
// 
//     @Override
//     public void logInfo(String message) {
//         System.out.println("INFO: " + message);
//     }
// 
//     @Override
//     public void logDebug(String message) {
//         System.out.println("DEBUG: " + message);
//     }
// 
//     @Override
//     public void logWarn(String message) {
//         System.out.println("WARN: " + message);
//     }
// 
//     @Override
//     public void logError(String message) {
//         System.out.println("ERROR: " + message);
//     }
// 
//     @Override
//     public void logUploadProgress(long uploaded, long contentLength) {
//         if (!suppressUploadProgress) {
//             System.out.printf("Upload progress: %.0f%%\n", ((double) uploaded / (double) contentLength) * 100);
//         }
//     }
// }


import com.heroku.sdk.deploy.lib.OutputAdapter;
import com.heroku.sdk.deploy.lib.running.RunWebApp;
import com.heroku.sdk.deploy.standalone.StdOutOutputAdapter;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Collections;
import java.util.List;
package com.heroku.sdk.deploy;



// Entry point for running a WAR locally. Located in this package to be consistent with DeployJar and DeployWar.
public class RunWar {
    public static void main(String[] args) throws IOException, InterruptedException {
        final OutputAdapter outputAdapter = new StdOutOutputAdapter(false);

        final String herokuWarFileSystemProperty = System.getProperty("heroku.warFile");
        if (herokuWarFileSystemProperty == null ) {
// Path: heroku-deploy/src/main/java/com/heroku/sdk/deploy/lib/OutputAdapter.java
// public interface OutputAdapter {
//     void logInfo(String message);
//     void logDebug(String message);
//     void logWarn(String message);
//     void logError(String message);
//     void logUploadProgress(long uploaded, long contentLength);
// 
//     default void logError(String message, Throwable t) {
//         logError(message);
//         logDebug(Arrays.stream(t.getStackTrace()).map(StackTraceElement::toString).collect(Collectors.joining("\n")));
//     }
// }
// 
// Path: heroku-deploy/src/main/java/com/heroku/sdk/deploy/lib/running/RunWebApp.java
// public class RunWebApp {
// 
//     public static void run(Path warFile, List<String> javaOptions, List<String> webappRunnerOptions, String webappRunnerVersion, OutputAdapter outputAdapter) throws IOException, InterruptedException {
//         outputAdapter.logInfo("Downloading webapp-runner...");
//         Path webappRunnerJarPath = null;
//         try {
//              webappRunnerJarPath = FileDownloader.download(WebappRunnerResolver.getUrlForVersion(webappRunnerVersion));
//         } catch (FileNotFoundException e) {
//             outputAdapter.logDebug(String.format("Could not download webapp-runner %s. Please check if this is a valid version.", webappRunnerVersion));
//             System.exit(-1);
//         }
// 
//         ArrayList<String> command = new ArrayList<>();
//         command.add(System.getProperty("java.home") + File.separator + "bin" + File.separator + "java");
//         command.addAll(javaOptions);
//         command.add("-jar");
//         command.add(webappRunnerJarPath.toString());
//         command.addAll(webappRunnerOptions);
//         command.add(warFile.toString());
// 
//         ProcessBuilder processBuilder = new ProcessBuilder(command.toArray(new String[0]));
//         Process process = processBuilder.start();
// 
//         StreamGobbler stdOutStreamGobbler = new StreamGobbler(process.getInputStream(), outputAdapter);
//         StreamGobbler stdErrStreamGobbler = new StreamGobbler(process.getErrorStream(), outputAdapter);
// 
//         stdOutStreamGobbler.start();
//         stdErrStreamGobbler.start();
// 
//         process.waitFor();
//     }
// 
//     private static class StreamGobbler extends Thread {
//         private InputStream inputStream;
//         private OutputAdapter outputAdapter;
// 
//         public StreamGobbler(InputStream inputStream, OutputAdapter outputAdapter) {
//             super("StreamGobbler");
//             this.inputStream = inputStream;
//             this.outputAdapter = outputAdapter;
//         }
// 
//         public void run() {
//             try {
//                 BufferedReader br = new BufferedReader(new InputStreamReader(inputStream));
//                 String line;
// 
//                 while ((line = br.readLine()) != null) {
//                     outputAdapter.logInfo(line);
//                 }
//             } catch (IOException e) {
//                 outputAdapter.logError(e.getMessage(), e);
//                 throw new RuntimeException(e);
//             }
//         }
//     }
// }
// 
// Path: heroku-deploy-standalone/src/main/java/com/heroku/sdk/deploy/standalone/StdOutOutputAdapter.java
// public class StdOutOutputAdapter implements OutputAdapter {
//     private boolean suppressUploadProgress;
// 
//     public StdOutOutputAdapter(boolean suppressUploadProgress) {
//         this.suppressUploadProgress = suppressUploadProgress;
//     }
// 
//     @Override
//     public void logInfo(String message) {
//         System.out.println("INFO: " + message);
//     }
// 
//     @Override
//     public void logDebug(String message) {
//         System.out.println("DEBUG: " + message);
//     }
// 
//     @Override
//     public void logWarn(String message) {
//         System.out.println("WARN: " + message);
//     }
// 
//     @Override
//     public void logError(String message) {
//         System.out.println("ERROR: " + message);
//     }
// 
//     @Override
//     public void logUploadProgress(long uploaded, long contentLength) {
//         if (!suppressUploadProgress) {
//             System.out.printf("Upload progress: %.0f%%\n", ((double) uploaded / (double) contentLength) * 100);
//         }
//     }
// }


// Path: heroku-deploy-standalone/src/main/java/com/heroku/sdk/deploy/RunWar.java
import com.heroku.sdk.deploy.lib.OutputAdapter;
import com.heroku.sdk.deploy.lib.running.RunWebApp;
import com.heroku.sdk.deploy.standalone.StdOutOutputAdapter;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Collections;
import java.util.List;

package com.heroku.sdk.deploy;



// Entry point for running a WAR locally. Located in this package to be consistent with DeployJar and DeployWar.
public class RunWar {
    public static void main(String[] args) throws IOException, InterruptedException {
        final OutputAdapter outputAdapter = new StdOutOutputAdapter(false);

        final String herokuWarFileSystemProperty = System.getProperty("heroku.warFile");
        if (herokuWarFileSystemProperty == null ) {
            outputAdapter.logError("Path to WAR file must be provided with heroku.warFile system property!");