<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.querqy</groupId>
        <artifactId>querqy-for-lucene</artifactId>
        <version>5.5.lucene811.0</version>
        <relativePath>../pom.xml</relativePath>
    </parent>

    <artifactId>querqy-solr</artifactId>

    <name>${project.groupId}:${project.artifactId}</name>
    <description>Querqy library for query rewriting for Solr</description>

    <properties>
        <minidev.json-smart.version>2.3</minidev.json-smart.version>
        <slf4j.version>1.7.26</slf4j.version>
        <testcontainers.version>1.17.2</testcontainers.version>
    </properties>

    <dependencies>
        <!--
            The Solr test framework needs to be loaded before Lucene core,
            otherwise we run into trouble loading the codec for testing
        -->
        <dependency>
            <groupId>org.apache.solr</groupId>
            <artifactId>solr-test-framework</artifactId>
            <version>${lucene.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>${commons.io.version}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>querqy-lucene</artifactId>
            <version>${project.version}</version>
            <exclusions>
                <!--
                    This is provided by Solr - we don't want to package it
                -->
                <exclusion>
                    <groupId>com.fasterxml.jackson.core</groupId>
                    <artifactId>jackson-databind</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.fasterxml.jackson.core</groupId>
                    <artifactId>jackson-annotations</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.jayway.jsonpath</groupId>
                    <artifactId>json-path</artifactId>
                </exclusion>

            </exclusions>
        </dependency>

        <dependency>
            <!--
            Solr provides com.jayway.jsonpath:json-path but not net.minidev:json-smart
            on which some classes of json-path depend
            -->
            <groupId>net.minidev</groupId>
            <artifactId>json-smart</artifactId>
            <version>${minidev.json-smart.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.solr</groupId>
            <artifactId>solr-core</artifactId>
            <version>${lucene.version}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <!--
                needed by solr-test-framework (with scope=provided, not scope=test)
             -->
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${slf4j.version}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <!-- needed by solr-test-framework -->
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>${slf4j.version}</version>
            <scope>test</scope>
        </dependency>

        <!-- testcontainers integration tests -->
        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>testcontainers</artifactId>
            <version>${testcontainers.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>solr</artifactId>
            <version>${testcontainers.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${maven-surefire-plugin.version}</version>
                <configuration>
                    <excludedGroups>querqy.solr.it.IntegrationTest</excludedGroups>
                    <!-- Use narrow US-ASCII as default Java character set (via file.encoding system property)
                         to increase the chance of catching code that relies on the JDK default encoding -->
                    <argLine>-Dfile.encoding=US-ASCII</argLine>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>${maven-assembly-plugin.version}</version>
                <configuration>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!-- Downloads and unzips test product data for integration-tests -->
            <plugin>
                <groupId>com.googlecode.maven-download-plugin</groupId>
                <artifactId>download-maven-plugin</artifactId>
                <version>1.6.8</version>
                <executions>
                    <execution>
                        <id>download-test-product-data</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>wget</goal>
                        </goals>
                        <configuration>
                            <url>https://querqy.org/datasets/icecat/icecat-products-w_price-19k-20201127.tgz</url>
                            <unpack>true</unpack>
                            <outputDirectory>${project.build.directory}/integration-test-data</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!-- Execute Docker integration tests -->
            <plugin>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>${maven-failsafe-plugin.version}</version>
                <configuration>
                    <includes>
                        <include>**/*</include>
                    </includes>
                    <groups>querqy.solr.it.IntegrationTest</groups>
                    <systemPropertyVariables>
                        <project.build.directory>${project.build.directory}</project.build.directory>
                        <project.build.finalName>${project.build.finalName}</project.build.finalName>
                        <project.version>${project.version}</project.version>
                        <solr.test.versions>solr:8.11,solr:8.10,solr:8.9,solr:8.8,solr:8.7,solr:8.6,solr:8.5,solr:8.4,solr:8.3,solr:8.2,solr:8.1</solr.test.versions>
                    </systemPropertyVariables>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

        </plugins>
    </build>
</project>
