<?xml version="1.0"?>
<!--
  ~ Copyright (C) 2017 Julien Viet
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~ http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  ~
  -->
<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>io.vertx</groupId>
    <artifactId>vertx-parent</artifactId>
    <version>12</version>
  </parent>

  <groupId>io.reactiverse</groupId>
  <artifactId>reactive-pg-client</artifactId>
  <version>0.11.4</version>

  <name>Reactive Postgres Client</name>
  <url>https://github.com/reactiverse/reactive-pg-client</url>
  <description>The reactive Postgres client</description>

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

  <scm>
    <connection>scm:git:git@github.com:vietj/reactive-pg-client.git</connection>
    <developerConnection>scm:git:git@github.com:vietj/reactive-pg-client.git</developerConnection>
    <url>git@github.com:vietj/reactive-pg-client.git</url>
  </scm>

  <developers>
    <developer>
      <name>Julien Viet</name>
      <email>julien@julienviet.com</email>
    </developer>
    <developer>
      <name>Emad Alblueshi</name>
      <email>emad.albloushi@gmail.com</email>
    </developer>
  </developers>

  <properties>
    <stack.version>3.7.1</stack.version>
    <jmh.version>1.19</jmh.version>
    <docs.dir>${project.basedir}/src/main/docs</docs.dir>
    <generated.dir>${project.basedir}/src/main/generated</generated.dir>
    <!-- Set to a value for testing with a specific database -->
    <embedded.postgres.version />
    <connection.uri />
    <tls.connection.uri />
    <unix.socket.directory />
    <unix.socket.port />
    <!-- We skip sources jar generation as we do it with the assembly plugin to have greater control over the content -->
    <source.skip>true</source.skip>
    <kotlin.version>1.3.0</kotlin.version>
  </properties>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>io.vertx</groupId>
        <artifactId>vertx-dependencies</artifactId>
        <version>${stack.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>
    <dependency>
      <groupId>io.vertx</groupId>
      <artifactId>vertx-core</artifactId>
    </dependency>
    <dependency>
      <groupId>io.vertx</groupId>
      <artifactId>vertx-codegen</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>io.vertx</groupId>
      <artifactId>vertx-docgen</artifactId>
      <version>0.9.0</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>io.vertx</groupId>
      <artifactId>vertx-codetrans</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>io.vertx</groupId>
      <artifactId>vertx-rx-java</artifactId>
      <optional>true</optional>
    </dependency>
    <dependency>
      <groupId>io.vertx</groupId>
      <artifactId>vertx-rx-java-gen</artifactId>
      <version>${stack.version}</version>
      <optional>true</optional>
    </dependency>
    <dependency>
      <groupId>io.vertx</groupId>
      <artifactId>vertx-rx-java2</artifactId>
      <optional>true</optional>
    </dependency>
    <dependency>
      <groupId>io.vertx</groupId>
      <artifactId>vertx-rx-java2-gen</artifactId>
      <version>${stack.version}</version>
      <optional>true</optional>
    </dependency>
    <dependency>
      <groupId>io.vertx</groupId>
      <artifactId>vertx-lang-js</artifactId>
      <optional>true</optional>
    </dependency>
    <dependency>
      <groupId>io.vertx</groupId>
      <artifactId>vertx-lang-ruby</artifactId>
      <optional>true</optional>
    </dependency>
    <dependency>
      <groupId>io.vertx</groupId>
      <artifactId>vertx-lang-groovy</artifactId>
      <optional>true</optional>
    </dependency>
    <dependency>
      <groupId>io.vertx</groupId>
      <artifactId>vertx-lang-kotlin</artifactId>
      <optional>true</optional>
    </dependency>
    <dependency>
      <groupId>io.vertx</groupId>
      <artifactId>vertx-lang-kotlin-coroutines</artifactId>
      <optional>true</optional>
    </dependency>
    <dependency>
      <groupId>io.vertx</groupId>
      <artifactId>vertx-lang-kotlin-gen</artifactId>
      <version>${stack.version}</version>
      <optional>true</optional>
    </dependency>
    <!--
    <dependency>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-classic</artifactId>
      <version>1.2.3</version>
      <scope>test</scope>
    </dependency>
    -->
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.12</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>io.vertx</groupId>
      <artifactId>vertx-unit</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>io.netty</groupId>
      <artifactId>netty-transport-native-epoll</artifactId>
      <classifier>linux-x86_64</classifier>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>io.netty</groupId>
      <artifactId>netty-transport-native-kqueue</artifactId>
      <classifier>osx-x86_64</classifier>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>ru.yandex.qatools.embed</groupId>
      <artifactId>postgresql-embedded</artifactId>
      <version>2.10</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.postgresql</groupId>
      <artifactId>postgresql</artifactId>
      <version>42.1.1</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.openjdk.jmh</groupId>
      <artifactId>jmh-core</artifactId>
      <version>${jmh.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.openjdk.jmh</groupId>
      <artifactId>jmh-generator-annprocess</artifactId>
      <version>${jmh.version}</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <artifactId>maven-clean-plugin</artifactId>
          <executions>
            <execution>
              <id>default-clean</id>
              <configuration>
                <filesets>
                  <fileset>
                    <directory>${generated.dir}</directory>
                  </fileset>
                </filesets>
              </configuration>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <artifactId>maven-compiler-plugin</artifactId>
          <executions>
            <execution>
              <id>default-compile</id>
              <configuration>
                <annotationProcessors>
                  <annotationProcessor>io.vertx.codegen.CodeGenProcessor</annotationProcessor>
                  <annotationProcessor>io.vertx.docgen.JavaDocGenProcessor</annotationProcessor>
                  <annotationProcessor>io.vertx.docgen.DocGenProcessor</annotationProcessor>
                </annotationProcessors>
                <compilerArgs>
                  <arg>-Acodegen.output=${project.basedir}/src/main</arg>
                  <arg>-Adocgen.source=${docs.dir}/*.md</arg>
                  <arg>-Adocgen.output=${project.basedir}/jekyll/guide/$lang</arg>
                  <arg>-Adocgen.syntax=markdown</arg>
                  <arg>-Amaven.groupId=${project.groupId}</arg>
                  <arg>-Amaven.artifactId=${project.artifactId}</arg>
                  <arg>-Amaven.version=${project.version}</arg>
                </compilerArgs>
              </configuration>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <artifactId>maven-surefire-plugin</artifactId>
          <configuration>
            <argLine>-Xmx1024M</argLine>
            <systemPropertyVariables>
              <target.dir>${project.build.directory}</target.dir>
              <embedded.postgres.version>${embedded.postgres.version}</embedded.postgres.version>
              <connection.uri>${connection.uri}</connection.uri>
              <tls.connection.uri>${tls.connection.uri}</tls.connection.uri>
              <unix.socket.directory>${unix.socket.directory}</unix.socket.directory>
              <unix.socket.port>${unix.socket.port}</unix.socket.port>
            </systemPropertyVariables>
            <excludes>
              <exclude>io/reactiverse/pgclient/it/**</exclude>
            </excludes>
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <version>3.0.0</version>
        <executions>
          <execution>
            <id>add-source</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>add-source</goal>
            </goals>
            <configuration>
              <sources>
                <source>${generated.dir}</source>
              </sources>
            </configuration>
          </execution>
          <execution>
            <id>add-test-source</id>
            <goals>
              <goal>add-test-source</goal>
            </goals>
            <configuration>
              <sources>
                <source>${project.basedir}/src/benchmark/java</source>
              </sources>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-failsafe-plugin</artifactId>
        <version>2.21.0</version>
        <executions>
          <execution>
            <id>env-test</id>
            <goals>
              <goal>integration-test</goal>
            </goals>
            <phase>integration-test</phase>
            <configuration>
              <includes>
                <include>io/reactiverse/pgclient/it/EnvTest.java</include>
              </includes>
              <environmentVariables>
                <PGHOSTADDR>test_host</PGHOSTADDR>
                <PGDATABASE>test_database</PGDATABASE>
                <PGPORT>1234</PGPORT>
                <PGUSER>test_user</PGUSER>
                <PGPASSWORD>test_password</PGPASSWORD>
                <PGSSLMODE>require</PGSSLMODE>
              </environmentVariables>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-javadoc-plugin</artifactId>
        <configuration>
          <sourcepath>${project.build.sourceDirectory};${project.build.directory}/generated-sources/annotations</sourcepath>
          <sourceFileIncludes>
            <sourceFileInclude>io/reactiverse/**/*.java</sourceFileInclude>
          </sourceFileIncludes>
          <sourceFileExcludes>
            <sourceFileExclude>io/reactiverse/groovy/**/*.java</sourceFileExclude>
            <sourceFileExclude>**/package-info.java</sourceFileExclude>
            <sourceFileExclude>**/impl/**</sourceFileExclude>
          </sourceFileExcludes>
          <detectLinks />
          <detectJavaApiLink />
          <links>
            <link>http://vertx.io/docs/apidocs/</link>
            <link>http://reactivex.io/RxJava/1.x/javadoc/</link>
            <link>http://reactivex.io/RxJava/javadoc/</link>
            <link>http://fasterxml.github.com/jackson-annotations/javadoc/2.9/</link>
            <link>http://fasterxml.github.io/jackson-core/javadoc/2.9/</link>
            <link>http://fasterxml.github.io/jackson-databind/javadoc/2.9/</link>
          </links>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>kotlin-maven-plugin</artifactId>
        <groupId>org.jetbrains.kotlin</groupId>
        <version>${kotlin.version}</version>
        <executions>
          <execution>
            <configuration>
              <jvmTarget>1.8</jvmTarget>
              <sourceDirs>
                <sourceDir>${basedir}/src/main/kotlin</sourceDir>
              </sourceDirs>
            </configuration>
            <goals>
              <goal>compile</goal>
            </goals>
            <phase>compile</phase>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <executions>
          <execution>
            <id>package-sources</id>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
            <configuration>
              <attach>true</attach>
              <archive>
                <!-- Need a manifest to avoid empty archive -->
                <manifest>
                </manifest>
              </archive>
              <descriptors>
                <descriptor>src/assembly/sources.xml</descriptor>
              </descriptors>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <profiles>

    <profile>
      <id>benchmark</id>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <executions>
              <execution>
                <id>package-benchmark</id>
                <phase>package</phase>
                <goals>
                  <goal>single</goal>
                </goals>
                <configuration>
                  <archive>
                    <manifest>
                      <mainClass>io.reactiverse.pgclient.RawBenchmark</mainClass>
                    </manifest>
                  </archive>
                  <descriptors>
                    <descriptor>src/assembly/benchmark.xml</descriptor>
                  </descriptors>
                  <attach>false</attach>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>jitwatch</id>
      <dependencies>
        <dependency>
          <groupId>com.chrisnewland</groupId>
          <artifactId>jitwatch</artifactId>
          <version>1.0.0</version>
        </dependency>
      </dependencies>
      <build>
        <plugins>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>default-cli</id>
                <goals>
                  <goal>java</goal>
                </goals>
                <configuration>
                  <mainClass>org.adoptopenjdk.jitwatch.launch.LaunchUI</mainClass>
                  <cleanupDaemonThreads>false</cleanupDaemonThreads>
                  <classpathScope>compile</classpathScope>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

    <!-- Site gen -->
    <profile>
      <id>site-gen</id>
      <activation>
        <property>
          <name>!skipSite</name>
        </property>
      </activation>
      <pluginRepositories>
        <pluginRepository>
          <id>rubygems-releases</id>
          <url>http://rubygems-proxy.torquebox.org/releases</url>
        </pluginRepository>
      </pluginRepositories>
      <repositories>
        <repository>
          <id>rubygems-releases</id>
          <url>http://rubygems-proxy.torquebox.org/releases</url>
        </repository>
      </repositories>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-site-plugin</artifactId>
            <version>3.4</version>
            <configuration>
              <skip>true</skip>
              <skipDeploy>true</skipDeploy>
            </configuration>
          </plugin>
          <plugin>
            <artifactId>maven-javadoc-plugin</artifactId>
            <executions>
              <execution>
                <phase>site</phase>
                <configuration>
                  <skip>false</skip>
                  <reportOutputDirectory>${project.basedir}/jekyll</reportOutputDirectory>
                </configuration>
                <goals>
                  <goal>javadoc</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>de.saumya.mojo</groupId>
            <artifactId>gem-maven-plugin</artifactId>
            <version>1.1.4</version>
            <executions>
              <execution>
                <goals>
                  <goal>exec</goal>
                </goals>
                <phase>site</phase>
                <configuration>
                  <execArgs>${project.build.directory}/rubygems/bin/yardoc --no-private -m html -o ${project.basedir}/jekyll/yardoc ${project.build.outputDirectory}/**/*.rb</execArgs>
                </configuration>
              </execution>
            </executions>
            <dependencies>
              <dependency>
                <groupId>rubygems</groupId>
                <artifactId>yard</artifactId>
                <version>0.8.7.6</version>
                <type>gem</type>
              </dependency>
              <dependency>
                <groupId>rubygems</groupId>
                <artifactId>asciidoctor</artifactId>
                <version>1.5.6</version>
                <type>gem</type>
              </dependency>
            </dependencies>
          </plugin>
          <plugin>
            <groupId>com.phasebash.jsdoc</groupId>
            <artifactId>jsdoc3-maven-plugin</artifactId>
            <executions>
              <execution>
                <phase>site</phase>
                <goals>
                  <goal>jsdoc3</goal>
                </goals>
                <configuration>
                  <recursive>true</recursive>
                  <directoryRoots>
                    <directoryRoot>${project.build.outputDirectory}</directoryRoot>
                  </directoryRoots>
                  <outputDirectory>${project.basedir}/jekyll/jsdoc</outputDirectory>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

</project>
