<?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>com.atlassian.pom</groupId>
        <artifactId>closedsource-pom</artifactId>
        <version>5.0.9</version>
    </parent>

    <!-- NOTE: This groupId and artifactID is fixed because AMPS contains "embedded-elasticsearch-plugin" as a hard-coded string-->
    <!-- See https://bitbucket.org/atlassian/amps/src/f38e44eceeb03ed65a1497c061077631826c05eb/maven-amps-plugin/src/main/java/com/atlassian/maven/plugins/amps/product/BitbucketProductHandler.java?at=master&fileviewer=file-view-default#BitbucketProductHandler.java-74 -->
    <groupId>com.atlassian.bitbucket.search</groupId>
    <artifactId>embedded-elasticsearch-plugin</artifactId>
    <!-- It is only coincidental that this plugin hit verison 6.0.0 around the same time as we released BbS 6.0.0. There is no need to version this plugin with BbS. -->
    <version>6.0.1</version>
    <packaging>atlassian-plugin</packaging>

    <name>Bitbucket Search - Embedded Elasticsearch plugin</name>
    <description>Plugin that starts an embedded Elasticsearch node to be used for development purposes only (e.g. in AMPS)</description>

    <scm>
        <connection>scm:git:ssh://git@stash.dev.internal.atlassian.com:7999/STASH/embedded-elasticsearch-plugin.git</connection>
        <developerConnection>scm:git:ssh://git@stash.dev.internal.atlassian.com:7999/STASH/embedded-elasticsearch-plugin.git</developerConnection>
        <url>scm:git:http://stash.dev.internal.atlassian.com/git/STASH/embedded-elasticsearch-plugin.git</url>
        <tag>embedded-elasticsearch-plugin-6.0.1</tag>
    </scm>

    <properties>
        <bitbucket.version>5.13.0</bitbucket.version>

        <amps.version>6.3.11</amps.version>
        <elasticsearch.version>5.5.3</elasticsearch.version>
        <java.version>1.8</java.version>
        <skipIntegrationTests>true</skipIntegrationTests>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.atlassian.bitbucket.server</groupId>
                <artifactId>bitbucket-parent</artifactId>
                <version>${bitbucket.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

            <dependency>
                <groupId>com.jayway.awaitility</groupId>
                <artifactId>awaitility</artifactId>
                <version>1.7.0</version>
            </dependency>

            <dependency>
                <groupId>com.jayway.restassured</groupId>
                <artifactId>rest-assured</artifactId>
                <version>2.9.0</version>
                <exclusions>
                    <exclusion>
                        <groupId>org.codehaus.groovy</groupId>
                        <artifactId>groovy</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>

            <dependency>
                <groupId>org.elasticsearch.distribution.zip</groupId>
                <artifactId>elasticsearch</artifactId>
                <version>${elasticsearch.version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.elasticsearch.distribution.zip</groupId>
            <artifactId>elasticsearch</artifactId>
            <type>zip</type>
        </dependency>

        <!-- Dependencies provided by BbS -->
        <dependency>
            <groupId>com.atlassian.bitbucket.server</groupId>
            <artifactId>bitbucket-api</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.atlassian.sal</groupId>
            <artifactId>sal-api</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.atlassian.util.concurrent</groupId>
            <artifactId>atlassian-util-concurrent</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <scope>provided</scope>
        </dependency>

        <!--Test dependencies-->
        <dependency>
            <groupId>com.atlassian.bitbucket.server</groupId>
            <artifactId>bitbucket-it-common</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.jayway.awaitility</groupId>
            <artifactId>awaitility</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.jayway.restassured</groupId>
            <artifactId>rest-assured</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-bundled-elasticsearch</id>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <phase>generate-resources</phase>
                        <configuration>
                            <excludeTransitive>true</excludeTransitive>
                            <includeGroupIds>org.elasticsearch.distribution.zip</includeGroupIds>
                            <stripVersion>true</stripVersion>
                            <outputDirectory>${project.build.outputDirectory}/bundle</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <!-- There are no unit tests below this module, only integration tests. Surefire is used to run
                         the unit tests, and Failsafe is used to run the integration tests. So we can fully disable
                         the Surefire plugin below here; it's not necessary. -->
                    <excludes>
                        <exclude>it/**/*.java</exclude>
                    </excludes>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <configuration>
                    <skipITs>${skipIntegrationTests}</skipITs>
                    <skipTests>${skipIntegrationTests}</skipTests>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.atlassian.maven.plugins</groupId>
                <artifactId>bitbucket-maven-plugin</artifactId>
                <version>${amps.version}</version>
                <extensions>true</extensions>
                <configuration>
                    <skipITs>${skipIntegrationTests}</skipITs>
                    <skipTests>${skipIntegrationTests}</skipTests>
                    <extractDependencies>false</extractDependencies>
                    <products>
                        <product>
                            <id>bitbucket</id>
                            <instanceId>bitbucket</instanceId>
                            <version>${bitbucket.version}</version>
                            <dataVersion>${bitbucket.version}</dataVersion>
                        </product>
                    </products>
                    <instructions>
                        <Atlassian-Plugin-Key>${project.groupId}.${project.artifactId}</Atlassian-Plugin-Key>
                        <Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
                        <Private-Package>
                            com.atlassian.bitbucket.search.internal*
                        </Private-Package>
                        <Export-Package>
                            com.atlassian.bitbucket.search.elasticsearch.embedded
                        </Export-Package>
                        <Spring-Context>*</Spring-Context>
                        <Import-Package>
                            com.atlassian.bitbucket.server,
                            org.slf4j.*,
                            org.springframework.beans.factory,
                            org.springframework.core.io,
                            com.atlassian.*,
                            com.google.common.base,
                            com.google.common.collect,
                            javax.*
                        </Import-Package>
                    </instructions>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>it</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <properties>
                <skipIntegrationTests>false</skipIntegrationTests>
            </properties>
        </profile>
    </profiles>
</project>
