<?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>

    <groupId>com.expedia</groupId>
    <artifactId>graphql-kotlin</artifactId>
    <version>0.2.8</version>
    <name>graphql-kotlin</name>
    <description>Code-only GraphQL schema generation for Kotlin</description>
    <url>https://github.com/ExpediaDotCom/graphql-kotlin</url>

    <packaging>jar</packaging>

    <distributionManagement>
        <snapshotRepository>
            <id>ossrh</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        </snapshotRepository>
        <repository>
            <id>ossrh</id>
            <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
        </repository>
    </distributionManagement>

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

    <developers>
        <developer>
            <name>Rick Fast</name>
            <email>rfast@expedia.com</email>
            <organization>Expedia Group</organization>
            <organizationUrl>https://www.expediagroup.com</organizationUrl>
        </developer>
        <developer>
            <name>Brennan Taylor</name>
            <email>brentaylor@expedia.com</email>
            <organization>Expedia Group</organization>
            <organizationUrl>https://www.expediagroup.com</organizationUrl>
        </developer>
        <developer>
            <name>Dariusz Kuc</name>
            <email>dkuc@expedia.com</email>
            <organization>Expedia Group</organization>
            <organizationUrl>https://www.expediagroup.com</organizationUrl>
        </developer>
        <developer>
            <name>Shane Myrick</name>
            <email>smyrick@expedia.com</email>
            <organization>Expedia Group</organization>
            <organizationUrl>https://www.expediagroup.com</organizationUrl>
        </developer>
        <developer>
            <name>Amanda Ducrou</name>
            <email>aducrou@expedia.com</email>
            <organization>Expedia Group</organization>
            <organizationUrl>https://www.expediagroup.com</organizationUrl>
        </developer>
    </developers>

    <scm>
        <connection>scm:git:git://github.com/ExpediaDotCom/graphql-kotlin.git</connection>
        <developerConnection>scm:git:git://github.com/ExpediaDotCom/graphql-kotlin.git</developerConnection>
        <url>https://github.com/ExpediaDotCom/graphql-kotlin</url>
    </scm>

    <properties>
        <!-- Project Versions -->
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

        <!-- Dependency Versions -->
        <graphql-java.version>11.0</graphql-java.version>
        <jackson-module-kotlin.version>2.9.8</jackson-module-kotlin.version>
        <kotlin.version>1.3.21</kotlin.version>
        <kotlin-coroutines.version>1.1.1</kotlin-coroutines.version>
        <reflections.version>0.9.11</reflections.version>

        <!-- Test Dependency Versions -->
        <junit-jupiter.version>5.4.0</junit-jupiter.version>
        <mockk.version>1.9.1</mockk.version>
        <rxjava2.version>2.2.7</rxjava2.version>

        <!-- Build Plugin Versions -->
        <dokka-maven-plugin.version>0.9.17</dokka-maven-plugin.version>
        <detekt-cli.version>1.0.0-RC14</detekt-cli.version>
        <ktlint.version>0.30.0</ktlint.version>
        <jacoco-maven-plugin.version>0.8.3</jacoco-maven-plugin.version>
        <maven-surefire-plugin.version>2.22.1</maven-surefire-plugin.version>
    </properties>

    <pluginRepositories>
        <pluginRepository>
            <id>jcenter</id>
            <name>JCenter</name>
            <url>https://jcenter.bintray.com/</url>
        </pluginRepository>
    </pluginRepositories>

    <build>
        <sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
        <testSourceDirectory>${project.basedir}/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>
                        <phase>compile</phase>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>test-compile</id>
                        <phase>test-compile</phase>
                        <goals>
                            <goal>test-compile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>${maven-surefire-plugin.version}</version>
            <configuration>
              <failIfNoTests>true</failIfNoTests>
              <includes>
                <include>**/*Test.java</include>
                <include>**/*Test.kt</include>
                <include>**/*Tests.java</include>
                <include>**/*Tests.kt</include>
              </includes>
              <properties>
                <excludeTags>integration-test</excludeTags>
              </properties>
            </configuration>
            <dependencies>
              <dependency>
                <groupId>org.junit.jupiter</groupId>
                <artifactId>junit-jupiter-api</artifactId>
                <version>${junit-jupiter.version}</version>
                <scope>runtime</scope>
              </dependency>
              <dependency>
                <groupId>org.junit.jupiter</groupId>
                <artifactId>junit-jupiter-engine</artifactId>
                <version>${junit-jupiter.version}</version>
                <scope>runtime</scope>
              </dependency>
            </dependencies>
          </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.8</version>
                <executions>
                    <!-- those can be run separately with mvn clean antrun:run@<target_id> -->
                    <execution>
                        <id>detekt</id>
                        <phase>validate</phase>
                        <configuration>
                            <target name="detekt">
                                <java taskname="detekt" dir="${project.basedir}" fork="true" failonerror="true" classname="io.gitlab.arturbosch.detekt.cli.Main" classpathref="maven.plugin.classpath">
                                    <arg value="--fail-fast" />
                                    <arg value="--input" />
                                    <arg value="${project.basedir}${file.separator}src" />
                                    <arg value="--config" />
                                    <arg value="${project.basedir}${file.separator}detekt.yml" />
                                    <arg value="--report" />
                                    <arg value="html:${project.basedir}${file.separator}target${file.separator}site${file.separator}detekt.html" />
                                    <arg value="--report" />
                                    <arg value="xml:${project.basedir}${file.separator}target${file.separator}site${file.separator}detekt.xml" />
                                </java>
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>ktlint</id>
                        <phase>validate</phase>
                        <configuration>
                            <target name="ktlint">
                                <java taskname="ktlint" dir="${project.basedir}" fork="true" failonerror="true" classname="com.github.shyiko.ktlint.Main" classpathref="maven.plugin.classpath">
                                    <arg value="src/**/*.kt" />
                                    <arg value="--reporter=plain" />
                                    <arg value="--reporter=checkstyle,output=${project.build.directory}/ktlint.xml" />
                                </java>
                            </target>
                        </configuration>
                        <goals><goal>run</goal></goals>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>io.gitlab.arturbosch.detekt</groupId>
                        <artifactId>detekt-cli</artifactId>
                        <version>${detekt-cli.version}</version>
                    </dependency>
                    <dependency>
                        <groupId>com.github.shyiko</groupId>
                        <artifactId>ktlint</artifactId>
                        <version>${ktlint.version}</version>
                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>${jacoco-maven-plugin.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>

    <dependencies>
        <dependency>
            <groupId>com.graphql-java</groupId>
            <artifactId>graphql-java</artifactId>
            <version>${graphql-java.version}</version>
        </dependency>
        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-stdlib</artifactId>
            <version>${kotlin.version}</version>
        </dependency>
        <dependency>
            <groupId>org.jetbrains.kotlinx</groupId>
            <artifactId>kotlinx-coroutines-core</artifactId>
            <version>${kotlin-coroutines.version}</version>
        </dependency>
        <dependency>
            <groupId>org.jetbrains.kotlinx</groupId>
            <artifactId>kotlinx-coroutines-jdk8</artifactId>
            <version>${kotlin-coroutines.version}</version>
        </dependency>
        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-reflect</artifactId>
            <version>${kotlin.version}</version>
        </dependency>
        <dependency>
            <groupId>org.reflections</groupId>
            <artifactId>reflections</artifactId>
            <version>${reflections.version}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.module</groupId>
            <artifactId>jackson-module-kotlin</artifactId>
            <version>${jackson-module-kotlin.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>org.jetbrains.kotlin</groupId>
                    <artifactId>kotlin-reflect</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-test-junit5</artifactId>
            <version>${kotlin.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.mockk</groupId>
            <artifactId>mockk</artifactId>
            <version>${mockk.version}</version>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.jetbrains.kotlin</groupId>
                    <artifactId>kotlin-reflect</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>io.reactivex.rxjava2</groupId>
            <artifactId>rxjava</artifactId>
            <version>${rxjava2.version}</version>
            <scope>test</scope>
        </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>
    </dependencies>

    <profiles>
        <!-- Activate using the release property: mvn clean install -Prelease -->
        <profile>
            <id>release</id>
            <activation>
                <property>
                    <name>release</name>
                </property>
            </activation>

            <build>
                <plugins>
                    <!-- Release to Maven central -->
                    <plugin>
                        <groupId>org.sonatype.plugins</groupId>
                        <artifactId>nexus-staging-maven-plugin</artifactId>
                        <version>1.6.8</version>
                        <extensions>true</extensions>
                        <executions>
                           <execution>
                               <id>default-deploy</id>
                               <phase>deploy</phase>
                               <goals>
                                  <goal>deploy</goal>
                               </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <serverId>ossrh</serverId>
                            <nexusUrl>https://oss.sonatype.org/</nexusUrl>
                            <autoReleaseAfterClose>true</autoReleaseAfterClose>
                        </configuration>
                    </plugin>

                    <!-- Generate javadoc -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                        <version>3.0.1</version>
                        <executions>
                            <execution>
                                <id>attach-sources</id>
                                <goals>
                                    <goal>jar-no-fork</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>

                    <!-- Attach javadocs to jar -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>3.0.1</version>
                        <executions>
                            <execution>
                                <id>attach-javadocs</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>

                    <!-- Sign the artifacts -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>1.6</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
          <id>jdk8</id>
          <activation>
            <jdk>1.8</jdk>
          </activation>
          <build>
            <plugins>
              <plugin>
                <groupId>org.jetbrains.dokka</groupId>
                <artifactId>dokka-maven-plugin</artifactId>
                <version>${dokka-maven-plugin.version}</version>
                <executions>
                  <execution>
                    <phase>prepare-package</phase>
                    <goals>
                      <goal>javadocJar</goal>
                    </goals>
                  </execution>
                </executions>
              </plugin>
            </plugins>
          </build>
        </profile>
    </profiles>
</project>
