<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>
        <groupId>com.github.jelmerk</groupId>
        <artifactId>hnswlib-parent-pom</artifactId>
        <version>0.0.28</version>
        <relativePath>..</relativePath>
    </parent>

    <modelVersion>4.0.0</modelVersion>

    <artifactId>hnswlib-scala_2.12</artifactId>

    <description>Scala integration</description>

    <dependencies>

        <dependency>
            <groupId>org.scala-lang</groupId>
            <artifactId>scala-library</artifactId>
            <version>${scala.version}</version>
        </dependency>

        <dependency>
            <groupId>com.github.jelmerk</groupId>
            <artifactId>hnswlib-core</artifactId>
            <version>${project.version}</version>
        </dependency>

        <dependency>
            <groupId>com.github.jelmerk</groupId>
            <artifactId>hnswlib-metrics-dropwizard</artifactId>
            <version>${project.version}</version>
            <optional>true</optional>
        </dependency>

    </dependencies>

    <build>
        <sourceDirectory>src/main/scala</sourceDirectory>
        <testSourceDirectory>src/test/scala</testSourceDirectory>

        <plugins>
            <plugin>
                <groupId>net.alchim31.maven</groupId>
                <artifactId>scala-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>scala-compile-first</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>add-source</goal>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>scala-test-compile</id>
                        <phase>process-test-resources</phase>
                        <goals>
                            <goal>testCompile</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>attach-javadocs</id>
                        <goals>
                            <goal>doc-jar</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <scalaVersion>${scala.version}</scalaVersion>
                    <sendJavaToScalac>false</sendJavaToScalac>
                    <jvmArgs>
                        <jvmArg>-Xmx512m</jvmArg>
                    </jvmArgs>
                    <args>
                        <arg>-nobootcp</arg>
                        <arg>-target:jvm-1.8</arg>
                        <arg>-deprecation</arg>
                        <arg>-optimise</arg>
                        <arg>-unchecked</arg>
                        <arg>-encoding</arg>
                        <arg>UTF-8</arg>
                        <arg>-feature</arg>
                        <arg>-Xlog-reflective-calls</arg>
                        <arg>-Ywarn-adapted-args</arg>
                    </args>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <skipTests>true</skipTests>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.scalatest</groupId>
                <artifactId>scalatest-maven-plugin</artifactId>
                <version>1.0</version>
                <configuration>
                    <reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
                    <junitxml>.</junitxml>
                    <filereports>WDF TestSuite.txt</filereports>
                </configuration>
                <executions>
                    <execution>
                        <id>test</id>
                        <goals>
                            <goal>test</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>compile</phase>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>

        <profile>
            <id>scala-2.11</id>
            <activation>
                <property>
                    <name>!scala-2.12</name>
                </property>
            </activation>

            <properties>
                <scala.version>2.11.12</scala.version>
                <scala.binary.version>2.11</scala.binary.version>
            </properties>

            <dependencies>
                <dependency>
                    <groupId>org.scalatest</groupId>
                    <artifactId>scalatest_2.11</artifactId>
                    <version>3.0.1</version>
                    <scope>test</scope>
                </dependency>
            </dependencies>

        </profile>

        <profile>
            <id>scala-2.12</id>
            <activation>
                <property>
                    <name>scala-2.12</name>
                </property>
            </activation>

            <properties>
                <scala.version>2.12.7</scala.version>
                <scala.binary.version>2.12</scala.binary.version>
            </properties>

            <dependencies>
                <dependency>
                    <groupId>org.scalatest</groupId>
                    <artifactId>scalatest_2.12</artifactId>
                    <version>3.0.1</version>
                    <scope>test</scope>
                </dependency>
            </dependencies>

        </profile>

    </profiles>

</project>
