<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://maven.apache.org/POM/4.0.0"
         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>

    <groupId>com.github.pemistahl</groupId>
    <artifactId>lingua</artifactId>
    <version>0.2.2</version>

    <name>Lingua</name>
    <description>A language detection library for Kotlin and Java, suitable for long and short text alike</description>
    <url>https://github.com/pemistahl/lingua</url>
    <packaging>jar</packaging>

    <licenses>
        <license>
            <name>The Apache License, Version 2.0</name>
            <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
        </license>
    </licenses>

    <developers>
        <developer>
            <id>pemistahl</id>
            <name>Peter M. Stahl</name>
            <email>pemistahl@googlemail.com</email>
            <url>https://github.com/pemistahl</url>
        </developer>
    </developers>

    <scm>
        <connection>scm:git:git://github.com/pemistahl/lingua.git</connection>
        <developerConnection>scm:git:ssh://github.com:pemistahl/lingua.git</developerConnection>
        <url>http://github.com/pemistahl/lingua/tree/master</url>
    </scm>

    <properties>
        <!--
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.6</maven.compiler.target>
        -->
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <kotlin.compiler.jvmTarget>1.6</kotlin.compiler.jvmTarget>
        <kotlin.compiler.incremental>true</kotlin.compiler.incremental>
        <kotlin.code.style>official</kotlin.code.style>

        <kotlin.version>1.3.11</kotlin.version>
        <gson.version>2.8.5</gson.version>
        <junit.jupiter.version>5.3.2</junit.jupiter.version>
        <mockk.version>1.8.13.kotlin13</mockk.version>
        <dokka.version>0.9.17</dokka.version>
        <jacoco.version>0.8.3-SNAPSHOT</jacoco.version>

        <maven.compiler.plugin.version>3.8.0</maven.compiler.plugin.version>
        <maven.shade.plugin.version>3.2.1</maven.shade.plugin.version>
        <exec.maven.plugin.version>1.6.0</exec.maven.plugin.version>
        <maven.surefire.plugin.version>2.22.1</maven.surefire.plugin.version>
        <maven.source.plugin.version>3.0.1</maven.source.plugin.version>
        <maven.clean.plugin.version>3.1.0</maven.clean.plugin.version>

        <lingua.main.class>com.github.pemistahl.lingua.AppKt</lingua.main.class>

        <com.optimaize.languagedetector.version>0.6</com.optimaize.languagedetector.version>
        <org.apache.tika.version>1.19.1</org.apache.tika.version>
        <slf4j.api.version>1.7.25</slf4j.api.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-stdlib</artifactId>
            <version>${kotlin.version}</version>
        </dependency>
        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-reflect</artifactId>
            <version>${kotlin.version}</version>
        </dependency>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>${gson.version}</version>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>${junit.jupiter.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>${junit.jupiter.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-params</artifactId>
            <version>${junit.jupiter.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.mockk</groupId>
            <artifactId>mockk</artifactId>
            <version>${mockk.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.optimaize.languagedetector</groupId>
            <artifactId>language-detector</artifactId>
            <version>${com.optimaize.languagedetector.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.tika</groupId>
            <artifactId>tika-langdetect</artifactId>
            <version>${org.apache.tika.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${slf4j.api.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>${slf4j.api.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

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

        <plugins>
            <plugin>
                <groupId>org.jetbrains.kotlin</groupId>
                <artifactId>kotlin-maven-plugin</artifactId>
                <version>${kotlin.version}</version>
                <executions>
                    <execution>
                        <id>compile</id>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>test-compile</id>
                        <goals>
                            <goal>test-compile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven.compiler.plugin.version}</version>
                <executions>
                    <execution>
                        <id>default-compile</id>
                        <phase>none</phase>
                    </execution>
                    <execution>
                        <id>default-testCompile</id>
                        <phase>none</phase>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>${exec.maven.plugin.version}</version>
                <configuration>
                    <mainClass>${lingua.main.class}</mainClass>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${maven.surefire.plugin.version}</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-clean-plugin</artifactId>
                <version>${maven.clean.plugin.version}</version>
                <configuration>
                    <filesets>
                        <fileset>
                            <directory>accuracy-reports</directory>
                        </fileset>
                    </filesets>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>${jacoco.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>report</id>
                        <phase>test</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>accuracy-reports</id>
            <activation>
                <property>
                    <name>detector</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <includes>
                                <include>**/${detector}/*Report.java</include>
                            </includes>
                            <reportsDirectory>${project.build.directory}/../accuracy-reports/${detector}</reportsDirectory>
                            <redirectTestOutputToFile>true</redirectTestOutputToFile>
                            <disableXmlReport>true</disableXmlReport>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>with-dependencies</id>
            <activation>
                <property>
                    <name>profile.release</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-shade-plugin</artifactId>
                        <version>${maven.shade.plugin.version}</version>
                        <executions>
                            <execution>
                                <phase>package</phase>
                                <goals>
                                    <goal>shade</goal>
                                </goals>
                                <configuration>
                                    <shadedArtifactAttached>true</shadedArtifactAttached>
                                    <shadedClassifierName>with-dependencies</shadedClassifierName>
                                    <transformers>
                                        <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                            <mainClass>${lingua.main.class}</mainClass>
                                        </transformer>
                                    </transformers>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>release</id>
            <activation>
                <property>
                    <name>profile.release</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                        <version>${maven.source.plugin.version}</version>
                        <executions>
                            <execution>
                                <id>attach-sources</id>
                                <goals>
                                    <goal>jar-no-fork</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <excludeResources>true</excludeResources>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.jetbrains.dokka</groupId>
                        <artifactId>dokka-maven-plugin</artifactId>
                        <version>${dokka.version}</version>
                        <executions>
                            <execution>
                                <phase>prepare-package</phase>
                                <goals>
                                    <goal>dokka</goal>
                                    <goal>javadoc</goal>
                                    <goal>javadocJar</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <jdkVersion>6</jdkVersion>
                            <reportNotDocumented>false</reportNotDocumented>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
            <pluginRepositories>
                <pluginRepository>
                    <id>jcenter</id>
                    <name>JCenter</name>
                    <url>https://jcenter.bintray.com/</url>
                </pluginRepository>
            </pluginRepositories>
            <distributionManagement>
                <repository>
                    <id>bintray-pemistahl-nlp-libraries</id>
                    <name>pemistahl-nlp-libraries</name>
                    <url>https://api.bintray.com/maven/pemistahl/nlp-libraries/lingua/;publish=1</url>
                </repository>
            </distributionManagement>
        </profile>
    </profiles>

    <pluginRepositories>
        <pluginRepository>
            <id>sonatype</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        </pluginRepository>
    </pluginRepositories>
</project>
