<?xml version="1.0" encoding="UTF-8"?>
<!--
  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. See accompanying LICENSE file.
-->
<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.github.housepower</groupId>
    <artifactId>clickhouse-native-jdbc-parent</artifactId>
    <version>2.4.0</version>
    <packaging>pom</packaging>

    <name>ClickHouse Native JDBC POM</name>
    <description>ClickHouse Native Protocol JDBC implementation</description>
    <url>https://github.com/housepower/ClickHouse-Native-JDBC</url>

    <scm>
        <url>https://github.com/housepower/ClickHouse-Native-JDBC</url>
        <connection>scm:git:git@github.com:housepower/ClickHouse-Native-JDBC.git</connection>
        <developerConnection>scm:git:git@github.com:housepower/ClickHouse-Native-JDBC.git</developerConnection>
        <tag>HEAD</tag>
    </scm>
    <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>
    <developers>
        <developer>
            <id>sundy-li</id>
            <name>Sundy Li</name>
            <email>543950155@qq.com</email>
            <timezone>8</timezone>
        </developer>
        <developer>
            <id>zhang2014</id>
            <name>Winter Zhang</name>
            <email>coswde@gmail.com</email>
            <timezone>8</timezone>
        </developer>
        <developer>
            <id>pan3793</id>
            <name>Cheng Pan</name>
            <email>379377944@qq.com</email>
            <timezone>8</timezone>
        </developer>
    </developers>

    <modules>
        <module>clickhouse-integration</module>
        <module>clickhouse-native-jdbc</module>
        <module>clickhouse-native-jdbc-shaded</module>
        <module>examples</module>
    </modules>

    <properties>
        <deploy.repo.snapshots.id>sonatype-nexus-snapshots</deploy.repo.snapshots.id>
        <deploy.repo.snapshots.url>https://oss.sonatype.org/content/repositories/snapshots</deploy.repo.snapshots.url>
        <deploy.repo.release.id>sonatype-nexus-staging</deploy.repo.release.id>
        <deploy.repo.release.url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</deploy.repo.release.url>

        <java.version>1.8</java.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <maven.compiler.encoding>UTF-8</maven.compiler.encoding>
        <maven.compiler.source>${java.version}</maven.compiler.source>
        <maven.compiler.target>${java.version}</maven.compiler.target>

        <build.testJarPhase>none</build.testJarPhase>

        <maven.assembly.plugin.version>3.1.1</maven.assembly.plugin.version>
        <maven.compiler.plugin.version>3.8.1</maven.compiler.plugin.version>
        <maven.checkstyle.plugin.version>3.1.1</maven.checkstyle.plugin.version>
        <maven.scala.plugin.version>4.3.0</maven.scala.plugin.version>
        <maven.exec.plugin.version>1.6.0</maven.exec.plugin.version>
        <maven.forbiddenapis.plugin.version>3.0.1</maven.forbiddenapis.plugin.version>
        <maven.gpg.plugin.version>1.5</maven.gpg.plugin.version>
        <maven.jar.plugin.version>3.1.2</maven.jar.plugin.version>
        <maven.javadoc.plugin.version>3.1.1</maven.javadoc.plugin.version>
        <maven.jacoco.plugin.version>0.8.2</maven.jacoco.plugin.version>
        <maven.shade.plugin.version>3.2.1</maven.shade.plugin.version>
        <maven.source.plugin.version>3.1.0</maven.source.plugin.version>
        <maven.surefire.plugin.version>3.0.0-M3</maven.surefire.plugin.version>
        <maven.failsafe.plugin.version>3.0.0-M3</maven.failsafe.plugin.version>
        <maven.release.plugin.version>2.5.3</maven.release.plugin.version>
        <maven.checkstyle.plugin.version>3.1.1</maven.checkstyle.plugin.version>

        <lz4.java.version>1.7.1</lz4.java.version>
        <jmh.version>1.26</jmh.version>
        <yandex-clickhouse-jdbc.version>0.2.4</yandex-clickhouse-jdbc.version>
        <mockito.version>3.6.0</mockito.version>
        <guava.version>16.0.1</guava.version>
        <slf4j.version>1.7.28</slf4j.version>
        <scala.version>2.11.12</scala.version>
        <scala.compat.version>2.11</scala.compat.version>
        <spark.version>2.4.7</spark.version>
        <jupiter.version>5.7.0</jupiter.version>

        <ClickHousePort>9000</ClickHousePort>
        <ClickHouseHTTPPort>8123</ClickHouseHTTPPort>
    </properties>

    <distributionManagement>
        <snapshotRepository>
            <id>${deploy.repo.snapshots.id}</id>
            <url>${deploy.repo.snapshots.url}</url>
        </snapshotRepository>
        <repository>
            <id>${deploy.repo.release.id}</id>
            <url>${deploy.repo.release.url}</url>
        </repository>
    </distributionManagement>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.github.housepower</groupId>
                <artifactId>clickhouse-integration</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>com.github.housepower</groupId>
                <artifactId>clickhouse-integration-spark_${scala.compat.version}</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>com.github.housepower</groupId>
                <artifactId>clickhouse-native-jdbc</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>com.github.housepower</groupId>
                <artifactId>clickhouse-native-jdbc</artifactId>
                <type>test-jar</type>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>com.github.housepower</groupId>
                <artifactId>clickhouse-native-jdbc-shaded</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>com.github.housepower</groupId>
                <artifactId>examples</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>org.lz4</groupId>
                <artifactId>lz4-java</artifactId>
                <version>${lz4.java.version}</version>
            </dependency>
            <dependency>
                <groupId>org.openjdk.jmh</groupId>
                <artifactId>jmh-core</artifactId>
                <version>${jmh.version}</version>
            </dependency>
            <dependency>
                <groupId>org.openjdk.jmh</groupId>
                <artifactId>jmh-generator-annprocess</artifactId>
                <version>${jmh.version}</version>
            </dependency>
            <dependency>
                <groupId>ru.yandex.clickhouse</groupId>
                <artifactId>clickhouse-jdbc</artifactId>
                <classifier>shaded</classifier>
                <version>${yandex-clickhouse-jdbc.version}</version>
                <exclusions>
                    <exclusion>
                        <groupId>*</groupId>
                        <artifactId>*</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>org.scala-lang</groupId>
                <artifactId>scala-compiler</artifactId>
                <version>${scala.version}</version>
            </dependency>
            <dependency>
                <groupId>org.scala-lang</groupId>
                <artifactId>scala-library</artifactId>
                <version>${scala.version}</version>
            </dependency>
            <dependency>
                <groupId>org.scala-lang</groupId>
                <artifactId>scala-reflect</artifactId>
                <version>${scala.version}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.spark</groupId>
                <artifactId>spark-core_${scala.compat.version}</artifactId>
                <version>${spark.version}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.spark</groupId>
                <artifactId>spark-sql_${scala.compat.version}</artifactId>
                <version>${spark.version}</version>
            </dependency>
            <dependency>
                <groupId>com.google.guava</groupId>
                <artifactId>guava</artifactId>
                <version>${guava.version}</version>
            </dependency>
            <dependency>
                <groupId>org.mockito</groupId>
                <artifactId>mockito-core</artifactId>
                <version>${mockito.version}</version>
            </dependency>
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-simple</artifactId>
                <version>${slf4j.version}</version>
            </dependency>
            <dependency>
                <groupId>org.junit.jupiter</groupId>
                <artifactId>junit-jupiter</artifactId>
                <version>${jupiter.version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>${maven.compiler.plugin.version}</version>
                    <configuration>
                        <source>${java.version}</source>
                        <target>${java.version}</target>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>net.alchim31.maven</groupId>
                    <artifactId>scala-maven-plugin</artifactId>
                    <version>${maven.scala.plugin.version}</version>
                    <executions>
                        <execution>
                            <id>eclipse-add-source</id>
                            <goals>
                                <goal>add-source</goal>
                            </goals>
                        </execution>
                        <execution>
                            <id>scala-compile-first</id>
                            <goals>
                                <goal>compile</goal>
                            </goals>
                        </execution>
                        <execution>
                            <id>scala-test-compile-first</id>
                            <goals>
                                <goal>testCompile</goal>
                            </goals>
                        </execution>
                        <execution>
                            <id>attach-scaladocs</id>
                            <goals>
                                <goal>doc-jar</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <scalaVersion>${scala.version}</scalaVersion>
                        <checkMultipleScalaVersions>true</checkMultipleScalaVersions>
                        <failOnMultipleScalaVersions>true</failOnMultipleScalaVersions>
                        <recompileMode>incremental</recompileMode>
                        <args>
                            <arg>-unchecked</arg>
                            <arg>-nobootcp</arg>
                            <arg>-deprecation</arg>
                            <arg>-feature</arg>
                            <arg>-explaintypes</arg>
                            <arg>-target:jvm-1.8</arg>
                        </args>
                        <jvmArgs>
                            <jvmArg>-Xms1024m</jvmArg>
                            <jvmArg>-Xmx1024m</jvmArg>
                            <jvmArg>-XX:ReservedCodeCacheSize=1g</jvmArg>
                        </jvmArgs>
                        <javacArgs>
                            <javacArg>-source</javacArg>
                            <javacArg>${java.version}</javacArg>
                            <javacArg>-target</javacArg>
                            <javacArg>${java.version}</javacArg>
                            <javacArg>-Xlint:all,-serial,-path,-try</javacArg>
                        </javacArgs>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-source-plugin</artifactId>
                    <version>${maven.source.plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-javadoc-plugin</artifactId>
                    <version>${maven.javadoc.plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.jacoco</groupId>
                    <artifactId>jacoco-maven-plugin</artifactId>
                    <version>${maven.jacoco.plugin.version}</version>
                    <executions>
                        <execution>
                            <id>pre-integration-test</id>
                            <goals>
                                <goal>prepare-agent</goal>
                            </goals>
                        </execution>
                        <execution>
                            <id>post-integration-test</id>
                            <phase>verify</phase>
                            <goals>
                                <goal>report</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>${maven.surefire.plugin.version}</version>
                    <configuration>
                        <excludes>
                            <exclude>**/*ITest*</exclude>
                        </excludes>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-failsafe-plugin</artifactId>
                    <version>${maven.failsafe.plugin.version}</version>
                    <executions>
                        <execution>
                            <id>integration-test</id>
                            <goals>
                                <goal>integration-test</goal>
                            </goals>
                        </execution>
                        <execution>
                            <id>verify</id>
                            <goals>
                                <goal>verify</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <includes>**/*ITest*</includes>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-shade-plugin</artifactId>
                    <version>${maven.shade.plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-release-plugin</artifactId>
                    <version>${maven.release.plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-gpg-plugin</artifactId>
                    <version>${maven.gpg.plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>exec-maven-plugin</artifactId>
                    <version>${maven.exec.plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-checkstyle-plugin</artifactId>
                    <version>${maven.checkstyle.plugin.version}</version>
                    <configuration>
                        <configLocation>dev/checkstyle.xml</configLocation>
                        <suppressionsLocation>dev/checkstyle-suppression.xml</suppressionsLocation>
                        <suppressionsFileExpression>checkstyle.suppression.file</suppressionsFileExpression>
                        <consoleOutput>true</consoleOutput>
                        <failsOnError>true</failsOnError>
                        <linkXRef>false</linkXRef>
                        <violationSeverity>error</violationSeverity>
                        <includeTestSourceDirectory>true</includeTestSourceDirectory>
                    </configuration>
                    <executions>
                        <execution>
                            <id>check-style</id>
                            <phase>validate</phase>
                            <goals>
                                <goal>checkstyle</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>de.thetaphi</groupId>
                    <artifactId>forbiddenapis</artifactId>
                    <version>${maven.forbiddenapis.plugin.version}</version>
                    <configuration>
                        <failOnUnsupportedJava>false</failOnUnsupportedJava>
                        <bundledSignatures>
                            <bundledSignature>jdk-unsafe</bundledSignature>
                            <!-- disallow deprecated methods from Java 8 -->
                            <bundledSignature>jdk-deprecated</bundledSignature>
                            <!-- disallow undocumented classes like sun.misc.Unsafe: -->
                            <bundledSignature>jdk-non-portable</bundledSignature>
                            <!-- disallow unsafe reflective access: -->
                            <bundledSignature>jdk-reflection</bundledSignature>
                        </bundledSignatures>
                        <excludes>**/*jmhTest.class</excludes>
                    </configuration>
                    <executions>
                        <execution>
                            <goals>
                                <goal>check</goal>
                                <goal>testCheck</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-assembly-plugin</artifactId>
                    <version>${maven.assembly.plugin.version}</version>
                    <configuration>
                        <tarLongFileMode>posix</tarLongFileMode>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-jar-plugin</artifactId>
                    <executions>
                        <execution>
                            <id>prepare-test-jar</id>
                            <phase>${build.testJarPhase}</phase>
                            <goals>
                                <goal>test-jar</goal>
                            </goals>
                            <configuration>
                                <excludes>
                                    <exclude>log4j.properties</exclude>
                                </excludes>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>de.thetaphi</groupId>
                <artifactId>forbiddenapis</artifactId>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>benchmark</id>
        </profile>
        <profile>
            <id>release</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                        <configuration>
                            <attach>true</attach>
                        </configuration>
                        <executions>
                            <execution>
                                <id>attach-sources</id>
                                <goals>
                                    <goal>jar-no-fork</goal>
                                    <goal>test-jar-no-fork</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>attach-javadocs</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-release-plugin</artifactId>
                        <configuration>
                            <mavenExecutorId>forked-path</mavenExecutorId>
                            <useReleaseProfile>true</useReleaseProfile>
                            <releaseProfiles>release</releaseProfiles>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
