package nl.jpoint.maven.vertx.utils;

import nl.jpoint.maven.vertx.mojo.DeployConfiguration;
import nl.jpoint.maven.vertx.request.Request;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.BasicHttpEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.logging.Log;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.List;

public class RequestExecutor {

    private final Log log;

    public RequestExecutor(Log log) {

        this.log = log;
    }

    public void executeDeployRequests(DeployConfiguration activeConfiguration, List<Request> requestList) throws MojoExecutionException {

        for (String host : activeConfiguration.getHosts()) {

            try (CloseableHttpClient httpClient = HttpClients.createDefault()) {

                for (Request request : requestList) {
                    HttpPost post = new HttpPost(host + request.getEndpoint());

                    ByteArrayInputStream bos = new ByteArrayInputStream(request.toJson().getBytes());
                    BasicHttpEntity entity = new BasicHttpEntity();
                    entity.setContent(bos);
                    entity.setContentLength(request.toJson().getBytes().length);
                    post.setEntity(entity);

                    try (CloseableHttpResponse response = httpClient.execute(post)) {
                        log.info("DeployModuleCommand : Post response status " + response.getStatusLine().getStatusCode());
                        if (response.getStatusLine().getStatusCode() != 200) {
                            throw new MojoExecutionException("Error deploying module. ");
                        }
                    } catch (IOException e) {
                        log.error("testDeployModuleCommand ", e);
                    }
                }
            } catch (IOException e) {
                log.error("testDeployModuleCommand ", e);
                throw new MojoExecutionException("Error deploying module.", e);
            }

        }
    }
}

@@ -1631,16 +1631,24 @@
 e status
+ code -%3E
  %22 + res
@@ -1683,24 +1683,25 @@
 tusCode());%0A
+%0A
             
@@ -1763,24 +1763,158 @@
 ) != 200) %7B%0A
+                            log.error(%22DeployModuleCommand : Post response status -%3E %22 + response.getStatusLine().getReasonPhrase());%0A
             

Add reason logging on failed deploy