// Path: src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/step/PostStartClusterSequence.java
// public class PostStartClusterSequence
//         extends DefaultClusterStepSequence
// {
// 
//     public PostStartClusterSequence()
//     {
//         add(new WaitToStartClusterStep());
//         add(new BootstrapClusterStep());
//         add(new BlockProcessExecutionStep());
//     }
// }
// 
// Path: src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/step/PostStartInstanceSequence.java
// public class PostStartInstanceSequence
//         extends DefaultInstanceStepSequence
// {
// 
//     public PostStartInstanceSequence()
//     {
//         add(new WaitToStartInstanceStep());
//     }
// }
// 
// Path: src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/step/PreStartClusterSequence.java
// public class PreStartClusterSequence
//         extends DefaultClusterStepSequence
// {
// 
//     public PreStartClusterSequence()
//     {
//         add(new ValidateInstanceCountStep());
//         add(new ValidateBaseDirectoryStep());
//         add(new ValidateFlavourStep());
//         add(new ValidateVersionStep());
//         add(new ValidateClusterNameStep());
//         add(new ValidateUniquePortsStep());
//         add(new ValidatePortsStep());
//         add(new ValidatePathConfStep());
//     }
// }


import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import com.github.alexcojocaru.mojo.elasticsearch.v2.step.PostStartClusterSequence;
import com.github.alexcojocaru.mojo.elasticsearch.v2.step.PostStartInstanceSequence;
import com.github.alexcojocaru.mojo.elasticsearch.v2.step.PreStartClusterSequence;
            getLog().info("Skipping plugin execution");
            return;
        }
        
        ClusterConfiguration clusterConfig = buildClusterConfiguration();
        new PreStartClusterSequence().execute(clusterConfig);

        for (InstanceConfiguration config : clusterConfig.getInstanceConfigurationList())
        {
            getLog().info(String.format(
                    "Using Elasticsearch [%d] configuration: %s",
                    config.getId(),
                    config));

            try
            {
                ForkedInstance instance = new ForkedInstance(config);
                instance.configureInstance();

                Thread thread = new Thread(instance);
                thread.start();

                new PostStartInstanceSequence().execute(config);
            }
            catch (Exception e)
            {
                throw new MojoExecutionException(e.getMessage(), e);
            }
        }

// Path: src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/step/PostStartClusterSequence.java
// public class PostStartClusterSequence
//         extends DefaultClusterStepSequence
// {
// 
//     public PostStartClusterSequence()
//     {
//         add(new WaitToStartClusterStep());
//         add(new BootstrapClusterStep());
//         add(new BlockProcessExecutionStep());
//     }
// }
// 
// Path: src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/step/PostStartInstanceSequence.java
// public class PostStartInstanceSequence
//         extends DefaultInstanceStepSequence
// {
// 
//     public PostStartInstanceSequence()
//     {
//         add(new WaitToStartInstanceStep());
//     }
// }
// 
// Path: src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/step/PreStartClusterSequence.java
// public class PreStartClusterSequence
//         extends DefaultClusterStepSequence
// {
// 
//     public PreStartClusterSequence()
//     {
//         add(new ValidateInstanceCountStep());
//         add(new ValidateBaseDirectoryStep());
//         add(new ValidateFlavourStep());
//         add(new ValidateVersionStep());
//         add(new ValidateClusterNameStep());
//         add(new ValidateUniquePortsStep());
//         add(new ValidatePortsStep());
//         add(new ValidatePathConfStep());
//     }
// }


// Path: src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/RunForkedMojo.java
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import com.github.alexcojocaru.mojo.elasticsearch.v2.step.PostStartClusterSequence;
import com.github.alexcojocaru.mojo.elasticsearch.v2.step.PostStartInstanceSequence;
import com.github.alexcojocaru.mojo.elasticsearch.v2.step.PreStartClusterSequence;

            getLog().info("Skipping plugin execution");
            return;
        }
        
        ClusterConfiguration clusterConfig = buildClusterConfiguration();
        new PreStartClusterSequence().execute(clusterConfig);

        for (InstanceConfiguration config : clusterConfig.getInstanceConfigurationList())
        {
            getLog().info(String.format(
                    "Using Elasticsearch [%d] configuration: %s",
                    config.getId(),
                    config));

            try
            {
                ForkedInstance instance = new ForkedInstance(config);
                instance.configureInstance();

                Thread thread = new Thread(instance);
                thread.start();

                new PostStartInstanceSequence().execute(config);
            }
            catch (Exception e)
            {
                throw new MojoExecutionException(e.getMessage(), e);
            }
        }

        new PostStartClusterSequence().execute(clusterConfig);