<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Licensed to the Apache Software Foundation (ASF) under one
  ~ or more contributor license agreements.  See the NOTICE file
  ~ distributed with this work for additional information
  ~ regarding copyright ownership.  The ASF licenses this file
  ~ to you under the Apache License, Version 2.0 (the
  ~ "License"); you may not use this file except in compliance
  ~
  ~   http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing,
  ~ software distributed under the License is distributed on an
  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  ~ KIND, either express or implied.  See the License for the
  ~ specific language governing permissions and limitations
  ~ under the License.
  -->
<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>streams-contrib</artifactId>
        <groupId>org.apache.streams</groupId>
        <version>0.6.0</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>streams-persist-elasticsearch</artifactId>
    <name>${project.artifactId}</name>

    <description>Elasticsearch Module</description>

    <properties>
        <elasticsearch.version>2.4.6</elasticsearch.version>
        <lucene.version>5.5.4</lucene.version>
    </properties>

    <dependencies>
        <!-- Test includes -->
        <dependency>
            <groupId>org.apache.lucene</groupId>
            <artifactId>lucene-test-framework</artifactId>
            <version>${lucene.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.lucene</groupId>
            <artifactId>lucene-codecs</artifactId>
            <version>${lucene.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.elasticsearch</groupId>
            <artifactId>elasticsearch</artifactId>
            <type>test-jar</type>
            <scope>test</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-all</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.streams</groupId>
            <artifactId>streams-config</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.streams</groupId>
            <artifactId>streams-core</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.streams</groupId>
            <artifactId>streams-pojo</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.streams</groupId>
            <artifactId>streams-pojo-extensions</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.streams</groupId>
            <artifactId>streams-util</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.streams</groupId>
            <artifactId>streams-schema-activitystreams</artifactId>
            <version>${project.version}</version>
            <type>zip</type>
            <classifier>testdata</classifier>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.elasticsearch</groupId>
            <artifactId>elasticsearch</artifactId>
            <scope>compile</scope>
            <type>jar</type>
        </dependency>
        <dependency>
            <groupId>org.apache.streams</groupId>
            <artifactId>streams-testing</artifactId>
            <version>${project.version}</version>
            <scope>test</scope>
            <type>test-jar</type>
        </dependency>
    </dependencies>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.elasticsearch</groupId>
                <artifactId>elasticsearch</artifactId>
                <version>${elasticsearch.version}</version>
            </dependency>
            <dependency>
                <groupId>org.elasticsearch</groupId>
                <artifactId>elasticsearch</artifactId>
                <type>test-jar</type>
                <version>${elasticsearch.version}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.lucene</groupId>
                <artifactId>lucene-test-framework</artifactId>
                <version>${lucene.version}</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.apache.lucene</groupId>
                <artifactId>lucene-codecs</artifactId>
                <version>${lucene.version}</version>
                <scope>test</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.streams.plugins</groupId>
                <artifactId>streams-plugin-pojo</artifactId>
                <version>${project.version}</version>
                <configuration>
                    <sourcePaths>
                        <sourcePath>${project.basedir}/src/main/jsonschema</sourcePath>
                    </sourcePaths>
                    <targetDirectory>${project.basedir}/target/generated-sources/pojo</targetDirectory>
                    <targetPackage>org.apache.streams.elasticsearch.pojo</targetPackage>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>add-source</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>add-source</goal>
                        </goals>
                        <configuration>
                            <sources>
                                <source>target/generated-sources/pojo</source>
                            </sources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>${failsafe.plugin.version}</version>
                <configuration>
                    <!-- Run integration test suite rather than individual tests. -->
                    <suiteXmlFiles>
                        <suiteXmlFile>target/test-classes/testng.xml</suiteXmlFile>
                    </suiteXmlFiles>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <includes>
                        <include>**/*.conf</include>
                        <include>**/*.json</include>
                        <include>**/*.class</include>
                    </includes>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>test-jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

        </plugins>
    </build>

    <profiles>
        <profile>
            <id>dockerITs</id>
            <activation>
                <activeByDefault>false</activeByDefault>
                <property>
                    <name>skipITs</name>
                    <value>false</value>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>io.fabric8</groupId>
                        <artifactId>docker-maven-plugin</artifactId>
                        <configuration combine.self="override">
                            <watchInterval>500</watchInterval>
                            <logDate>default</logDate>
                            <verbose>true</verbose>
                            <autoPull>on</autoPull>
                            <images>
                                <image>
                                    <name>elasticsearch:2.3.5</name>
                                    <alias>elasticsearch</alias>
                                    <run>
                                        <namingStrategy>none</namingStrategy>
                                        <ports>
                                            <port>${http.host}:${http.port}:9200</port>
                                            <port>${tcp.host}:${tcp.port}:9300</port>
                                        </ports>
                                        <portPropertyFile>elasticsearch.properties</portPropertyFile>
                                        <wait>
                                            <http>
                                                <url>http://${http.host}:${http.port}</url>
                                                <method>GET</method>
                                                <status>200</status>
                                            </http>
                                            <time>30000</time>
                                            <kill>1000</kill>
                                            <shutdown>500</shutdown>
                                        </wait>
                                        <log>
                                            <enabled>true</enabled>
                                            <date>default</date>
                                            <color>cyan</color>
                                        </log>
                                    </run>
                                    <watch>
                                        <mode>none</mode>
                                    </watch>
                                </image>

                            </images>
                        </configuration>
                        <executions>
                            <execution>
                                <id>start</id>
                                <goals>
                                    <goal>start</goal>
                                </goals>
                                <phase>
                                    pre-integration-test
                                </phase>
                            </execution>
                            <execution>
                                <id>stop</id>
                                <goals>
                                    <goal>stop</goal>
                                </goals>
                                <phase>
                                    post-integration-test
                                </phase>
                            </execution>
                        </executions>

                    </plugin>

                </plugins>
            </build>

        </profile>
    </profiles>

</project>
