<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.janusgraph</groupId>
        <artifactId>janusgraph</artifactId>
        <version>0.5.1</version>
        <relativePath>../pom.xml</relativePath>
    </parent>
    <artifactId>janusgraph-solr</artifactId>
    <name>JanusGraph-Solr: Distributed Indexing Support</name>
    <url>https://janusgraph.org</url>
    <properties>
        <top.level.basedir>${basedir}/..</top.level.basedir>
        <solr7.test.version>7.0.0</solr7.test.version>
        <solr.test.version>${solr7.test.version}</solr.test.version>
        <skip.solr.test>${skipTests}</skip.solr.test>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.janusgraph</groupId>
            <artifactId>janusgraph-core</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.janusgraph</groupId>
            <artifactId>janusgraph-backend-testutils</artifactId>
            <version>${project.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.janusgraph</groupId>
            <artifactId>janusgraph-berkeleyje</artifactId>
            <version>${project.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.janusgraph</groupId>
            <artifactId>janusgraph-berkeleyje</artifactId>
            <version>${project.version}</version>
            <classifier>tests</classifier>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.janusgraph</groupId>
            <artifactId>janusgraph-cql</artifactId>
            <version>${project.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.janusgraph</groupId>
            <artifactId>janusgraph-cql</artifactId>
            <version>${project.version}</version>
            <classifier>tests</classifier>
            <scope>test</scope>
        </dependency>
        <!-- JNA is needed by Cassandra, but janusgraph-cassandra only defines it as an optional dependency. -->
        <dependency>
            <groupId>net.java.dev.jna</groupId>
            <artifactId>jna</artifactId>
            <version>${jna.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.solr</groupId>
            <artifactId>solr-solrj</artifactId>
            <version>${lucene-solr.version}</version>
            <exclusions>
                <!-- Use jcl-over-slf4j from gremlin-core -->
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>jcl-over-slf4j</artifactId>
                </exclusion>
                <!-- Use noggit from janusgraph-core -->
                <exclusion>
                    <groupId>org.noggit</groupId>
                    <artifactId>noggit</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.lucene</groupId>
            <artifactId>lucene-analyzers-common</artifactId>
            <version>${lucene-solr.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.solr</groupId>
            <artifactId>solr-test-framework</artifactId>
            <version>${lucene-solr.version}</version>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>info.ganglia.gmetric4j</groupId>
                    <artifactId>gmetric4j</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>jcl-over-slf4j</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.github.ben-manes.caffeine</groupId>
                    <artifactId>caffeine</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.noggit</groupId>
                    <artifactId>noggit</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>junit</groupId>
                    <artifactId>junit</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.ow2.asm</groupId>
                    <artifactId>asm</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.ow2.asm</groupId>
                    <artifactId>asm-commons</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.kerby</groupId>
            <artifactId>kerb-simplekdc</artifactId>
            <version>1.1.1</version>
            <scope>test</scope>
            <exclusions>
                <!-- Use asm from solr-test-framework -->
                <exclusion>
                    <groupId>org.ow2.asm</groupId>
                    <artifactId>asm</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
        </dependency>
        <dependency>
            <groupId>org.locationtech.spatial4j</groupId>
            <artifactId>spatial4j</artifactId>
        </dependency>
        <!-- This is here for solr testing -->
        <dependency>
            <groupId>com.vividsolutions</groupId>
            <artifactId>jts</artifactId>
            <version>1.13</version>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>testcontainers</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>cassandra</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>junit-jupiter</artifactId>
            <scope>test</scope>
        </dependency>
        <!-- Logging backends.
             Enforce a classpath ordering constraint to ensure slf4j-log4j12
             binding appears on the classpath before logback-classic.
             See comments in janusgraph-cassandra/pom.xml for more information. -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
        </dependency>
        <!-- End logging backends. -->
    </dependencies>
    <build>
        <directory>${basedir}/target</directory>
        <finalName>${project.artifactId}-${project.version}</finalName>
        <resources>
            <resource>
                <directory>${basedir}/src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
        <testResources>
            <testResource>
                <directory>${basedir}/src/test/resources</directory>
            </testResource>
        </testResources>
        <plugins>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <executions>
                    <execution>
                        <id>default-test</id>
                        <configuration>
                            <argLine>${default.test.jvm.opts}</argLine>
                            <skipTests>${skip.solr.test}</skipTests>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    <profiles>
        <profile>
            <id>solr7</id>
            <properties>
                <solr.test.version>${solr7.test.version}</solr.test.version>
            </properties>
        </profile>
        <profile>
            <!-- Run tests with Solr Docker container -->
            <id>docker</id>
            <properties>
                <skip.solr.test>true</skip.solr.test>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>copy-jts</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>copy</goal>
                                </goals>
                                <configuration>
                                    <artifactItems>
                                        <artifactItem>
                                            <groupId>com.vividsolutions</groupId>
                                            <artifactId>jts</artifactId>
                                            <destFileName>jts.jar</destFileName>
                                        </artifactItem>
                                    </artifactItems>
                                    <outputDirectory>${project.build.directory}/dependency</outputDirectory>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <configuration>
                            <skipITs>false</skipITs>
                            <argLine>${default.test.jvm.opts}</argLine>
                            <includes>
                                <include>**/org/janusgraph/diskstorage/solr/*.java</include>
                            </includes>
                            <excludes>
                                <exclude>**/org/janusgraph/diskstorage/solr/SolrIndexKerberosKeytabTest.java</exclude>
                            </excludes>
                            <systemProperties>
                                <property>
                                    <name>index.search.solr.zookeeper-url</name>
                                    <value>0.0.0.0:2181</value>
                                </property>
                                <property>
                                    <name>log4j.configuration</name>
                                    <value>file:${project.build.directory}/test-classes/log4j.properties</value>
                                </property>
                            </systemProperties>
                        </configuration>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>integration-test</goal>
                                    <goal>verify</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>io.fabric8</groupId>
                        <artifactId>docker-maven-plugin</artifactId>
                        <version>0.33.0</version>
                        <configuration>
                            <images>
                                <image>
                                    <alias>zookeeper</alias>
                                    <name>jplock/zookeeper</name>
                                    <run>
                                        <ports>
                                            <port>2181:2181</port>
                                        </ports>
                                        <wait>
                                            <tcp>
                                                <ports>
                                                    <port>2181</port>
                                                </ports>
                                            </tcp>
                                            <time>60000</time>
                                        </wait>
                                    </run>
                                </image>
                                <image>
                                    <alias>solr</alias>
                                    <name>solr:${solr.test.version}</name>
                                    <run>
                                        <volumes>
                                            <bind>
                                                <volume>${project.build.directory}/dependency/jts.jar:/opt/solr/server/lib/jts.jar</volume>
                                            </bind>
                                        </volumes>
                                        <ports>
                                            <port>8983:8983</port>
                                        </ports>
                                        <links>
                                            <link>zookeeper</link>
                                        </links>
                                        <cmd>/opt/solr/bin/solr start -f -z zookeeper:2181</cmd>
                                         <wait>
                                            <http>
                                                <url>http://localhost:8983</url>
                                                <method>GET</method>
                                                <status>200..399</status>
                                            </http>
                                        </wait>
                                    </run>
                                </image>
                                <image>
                                    <alias>solr-setup</alias>
                                    <name>solr:${solr.test.version}</name>
                                    <run>
                                        <volumes>
                                            <bind>
                                                <volume>${basedir}/src/test/resources/solr/core-template:/opt/solr/mydata</volume>
                                                <volume>${basedir}/src/test/resources/collections.txt:/tmp/collections.txt</volume>
                                                <volume>${basedir}/src/test/resources/import-collections.sh:/usr/bin/import-collections</volume>
                                            </bind>
                                        </volumes>
                                        <cmd>bash -c 'import-collections'</cmd>
                                        <links>
                                            <link>zookeeper</link>
                                            <link>solr</link>
                                        </links>
                                        <wait>
                                            <log>All collections imported</log>
                                            <time>600000</time>
                                        </wait>
                                    </run>
                                </image>
                            </images>
                        </configuration>
                        <executions>
                            <execution>
                                <id>docker-start</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>start</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>docker-stop</id>
                                <phase>post-integration-test</phase>
                                <goals>
                                    <goal>stop</goal>
                                    <goal>remove</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
