<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>elasticsearch-qa</artifactId>
        <groupId>org.elasticsearch.qa</groupId>
        <version>2.0.0-beta2</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <!--
      This test unzips and starts elasticsearch.
      It then creates a Java Client and makes sure simple
      Java API calls works nicely

      It will also helps to better document the Java API reference guide
      and keep it up-to-date when API is changing.
    -->

    <artifactId>smoke-test-client</artifactId>
    <name>QA: Smoke Test Client</name>
    <description>Test the Java Client against a running cluster</description>

    <properties>
        <skip.unit.tests>true</skip.unit.tests>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.elasticsearch</groupId>
            <artifactId>elasticsearch</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <testResources>
            <testResource>
                <directory>src/test/resources</directory>
            </testResource>
            <!-- shared test resources like log4j.properties -->
            <testResource>
                <directory>${elasticsearch.tools.directory}/shared-test-resources</directory>
                <filtering>false</filtering>
            </testResource>
        </testResources>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-remote-resources-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>integ-setup-dependencies</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <skip>${skip.integ.tests}</skip>
                            <useBaseVersion>true</useBaseVersion>
                            <outputDirectory>${integ.deps}/plugins</outputDirectory>

                            <artifactItems>
                                <!-- elasticsearch distribution -->
                                <artifactItem>
                                    <groupId>org.elasticsearch.distribution.zip</groupId>
                                    <artifactId>elasticsearch</artifactId>
                                    <version>${elasticsearch.version}</version>
                                    <type>zip</type>
                                    <overWrite>true</overWrite>
                                    <outputDirectory>${integ.deps}</outputDirectory>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <!-- start up external cluster -->
                    <execution>
                        <id>integ-setup</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <skip>${skip.integ.tests}</skip>
                            <target>
                                <ant antfile="${elasticsearch.integ.antfile}" target="start-external-cluster">
                                    <property name="tests.jvm.argline" value="${tests.jvm.argline}"/>
                                </ant>
                            </target>
                        </configuration>
                    </execution>
                    <!-- shut down external cluster -->
                    <execution>
                        <id>integ-teardown</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <skip>${skip.integ.tests}</skip>
                            <target>
                                <ant antfile="${elasticsearch.integ.antfile}" target="stop-external-cluster"/>
                            </target>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>
