<?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">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.testcontainers</groupId>
        <artifactId>testcontainers-parent</artifactId>
        <version>1.6.0</version>
    </parent>

    <groupId>fr.pilato.elasticsearch.testcontainers</groupId>
    <artifactId>testcontainers-elasticsearch</artifactId>
    <version>0.1</version>

    <name>TestContainers :: elasticsearch</name>
    <description>Dockerized Elasticsearch container for testing under Testcontainers.</description>
    <url>https://github.com/testcontainers/testcontainers-java-module-elasticsearch</url>
    <licenses>
        <license>
            <name>The Apache Software License, Version 2.0</name>
            <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <properties>
        <!-- WARN: anytime you change the version, change profiles copy-plugin and fake-elastic-maven-repository -->
        <elasticsearch.version>6.2.1</elasticsearch.version>
        <!-- WARN: anytime you change the version, change profiles copy-old-plugin and fake-elastic-maven-repository-for-old-plugin -->
        <elasticsearch.version.old>5.6.6</elasticsearch.version.old>
        <elasticsearch.client.version>${elasticsearch.version}</elasticsearch.client.version>
        <integ.http.port>9400</integ.http.port>
        <plugin.dir>${project.build.directory}/plugins</plugin.dir>
        <xpack.password>changeme</xpack.password>
        <skipTests>false</skipTests>
    </properties>

    <issueManagement>
        <system>GitHub</system>
        <url>https://github.com/dadoonet/testcontainers-java-module-elasticsearch/issues/</url>
    </issueManagement>

    <dependencies>
        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>testcontainers</artifactId>
            <version>${project.parent.version}</version>
        </dependency>
        <dependency>
            <groupId>org.elasticsearch.client</groupId>
            <artifactId>elasticsearch-rest-client</artifactId>
            <version>${elasticsearch.client.version}</version>
        </dependency>
    </dependencies>

    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
        <testResources>
            <testResource>
                <directory>src/test/resources</directory>
                <filtering>true</filtering>
            </testResource>
        </testResources>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.7.0</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.10</version>
                <executions>
                    <execution>
                        <!-- Copy some plugins for integration testing -->
                        <id>integ-setup-dependencies-plugins</id>
                        <phase>generate-test-resources</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <skip>${skipTests}</skip>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>org.elasticsearch.plugin</groupId>
                                    <artifactId>ingest-attachment</artifactId>
                                    <version>${elasticsearch.version}</version>
                                    <type>zip</type>
                                </artifactItem>
                            </artifactItems>
                            <useBaseVersion>true</useBaseVersion>
                            <outputDirectory>${plugin.dir}/${elasticsearch.version}</outputDirectory>
                        </configuration>
                    </execution>
                    <execution>
                        <!-- Copy some old plugins for integration testing -->
                        <id>integ-setup-dependencies-plugins-old</id>
                        <phase>generate-test-resources</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <skip>${skipTests}</skip>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>org.elasticsearch.plugin</groupId>
                                    <artifactId>ingest-attachment</artifactId>
                                    <version>${elasticsearch.version.old}</version>
                                    <type>zip</type>
                                </artifactItem>
                            </artifactItems>
                            <useBaseVersion>true</useBaseVersion>
                            <outputDirectory>${plugin.dir}/${elasticsearch.version.old}</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.sonatype.plugins</groupId>
                <artifactId>nexus-staging-maven-plugin</artifactId>
                <version>1.6.8</version>
                <extensions>true</extensions>
                <configuration>
                    <serverId>sonatype-nexus-staging</serverId>
                    <nexusUrl>https://oss.sonatype.org/</nexusUrl>
                    <autoReleaseAfterClose>false</autoReleaseAfterClose>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-changes-plugin</artifactId>
                <version>2.12.1</version>
                <configuration>
                    <smtpHost>auth.smtp.1and1.fr</smtpHost>
                    <smtpPort implementation="java.lang.Integer">465</smtpPort>
                    <sslMode>true</sslMode>
                    <fromDeveloperId>dadoonet</fromDeveloperId>
                    <toAddresses>
                        <toAddress implementation="java.lang.String">discuss+community-plugins@elastic.co</toAddress>
                    </toAddresses>
                    <issueManagementSystems>
                        <issueManagementSystem>GitHub</issueManagementSystem>
                    </issueManagementSystems>
                    <issueTypes>
                        <add>new,doc</add>
                        <fix>bug</fix>
                        <update>update</update>
                        <remove>remove</remove>
                    </issueTypes>
                    <announceParameters>
                        <elasticsearch>${elasticsearch.version}</elasticsearch>
                    </announceParameters>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-release-plugin</artifactId>
                <version>2.5.3</version>
                <configuration>
                    <pushChanges>false</pushChanges>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <scm>
        <connection>scm:git:https://github.com/dadoonet/testcontainers-java-module-elasticsearch.git</connection>
        <developerConnection>scm:git:git@github.com:dadoonet/testcontainers-java-module-elasticsearch.git</developerConnection>
        <url>https://github.com/dadoonet/testcontainers-java-module-elasticsearch</url>
      <tag>testcontainers-elasticsearch-0.1</tag>
  </scm>

    <distributionManagement>
        <snapshotRepository>
            <id>sonatype-nexus-snapshots</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        </snapshotRepository>
        <repository>
            <id>sonatype-nexus-staging</id>
            <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
        </repository>
    </distributionManagement>

    <repositories>
        <!-- This repository is used to test with x-pack -->
        <repository>
            <id>elastic-download-service</id>
            <name>Elastic Download Service</name>
            <url>https://artifacts.elastic.co/maven/</url>
            <releases><enabled>true</enabled></releases>
            <snapshots><enabled>false</enabled></snapshots>
        </repository>

        <repository>
            <id>oss-snapshots</id>
            <name>Sonatype OSS Snapshots</name>
            <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
            <releases><enabled>false</enabled></releases>
            <snapshots><enabled>true</enabled></snapshots>
        </repository>
    </repositories>

    <profiles>
        <profile>
            <id>fake-elastic-maven-repository</id>
            <activation>
                <file>
                    <!-- WARN: change this if you change the the elasticsearch.version -->
                    <missing>${user.home}/.m2/repository/org/elasticsearch/plugin/ingest-attachment/6.2.1/ingest-attachment-6.2.1.zip</missing>
                </file>
            </activation>
            <build>
                <plugins>
                    <!-- Annoying we need to fake elastic maven repository -->
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>wagon-maven-plugin</artifactId>
                        <version>1.0</version>
                        <executions>
                            <execution>
                                <id>download-ingest-attachment</id>
                                <phase>generate-test-resources</phase>
                                <goals>
                                    <goal>download-single</goal>
                                </goals>
                                <configuration>
                                    <url>https://artifacts.elastic.co</url>
                                    <fromFile>downloads/elasticsearch-plugins/ingest-attachment/ingest-attachment-${elasticsearch.version}.zip</fromFile>
                                    <toDir>${plugin.dir}/${elasticsearch.version}</toDir>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-install-plugin</artifactId>
                        <version>2.5.2</version>
                        <executions>
                            <execution>
                                <id>fake-elasticsearch-repository</id>
                                <phase>generate-test-resources</phase>
                                <goals>
                                    <goal>install-file</goal>
                                </goals>
                                <configuration>
                                    <file>${plugin.dir}/${elasticsearch.version}/ingest-attachment-${elasticsearch.version}.zip</file>
                                    <groupId>org.elasticsearch.plugin</groupId>
                                    <artifactId>ingest-attachment</artifactId>
                                    <version>${elasticsearch.version}</version>
                                    <packaging>zip</packaging>
                                    <generatePom>true</generatePom>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>fake-elastic-maven-repository-for-old-plugin</id>
            <activation>
                <file>
                    <!-- WARN: change this if you change the the elasticsearch.version.old -->
                    <missing>${user.home}/.m2/repository/org/elasticsearch/plugin/ingest-attachment/5.6.6/ingest-attachment-5.6.6.zip</missing>
                </file>
            </activation>
            <build>
                <plugins>
                    <!-- Annoying we need to fake elastic maven repository -->
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>wagon-maven-plugin</artifactId>
                        <version>1.0</version>
                        <executions>
                            <execution>
                                <id>download-ingest-attachment-old</id>
                                <phase>generate-test-resources</phase>
                                <goals>
                                    <goal>download-single</goal>
                                </goals>
                                <configuration>
                                    <url>https://artifacts.elastic.co</url>
                                    <fromFile>downloads/elasticsearch-plugins/ingest-attachment/ingest-attachment-${elasticsearch.version.old}.zip</fromFile>
                                    <toDir>${plugin.dir}/${elasticsearch.version.old}</toDir>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-install-plugin</artifactId>
                        <version>2.5.2</version>
                        <executions>
                            <execution>
                                <id>fake-elasticsearch-repository-old</id>
                                <phase>generate-test-resources</phase>
                                <goals>
                                    <goal>install-file</goal>
                                </goals>
                                <configuration>
                                    <file>${plugin.dir}/${elasticsearch.version.old}/ingest-attachment-${elasticsearch.version.old}.zip</file>
                                    <groupId>org.elasticsearch.plugin</groupId>
                                    <artifactId>ingest-attachment</artifactId>
                                    <version>${elasticsearch.version.old}</version>
                                    <packaging>zip</packaging>
                                    <generatePom>true</generatePom>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>release</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>2.10.4</version>
                        <executions>
                            <execution>
                                <id>attach-javadocs</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                        <version>3.0.1</version>
                        <executions>
                            <execution>
                                <id>attach-sources</id>
                                <goals>
                                    <goal>jar-no-fork</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>1.6</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
