<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>ru.yandex.clickhouse</groupId>
    <artifactId>clickhouse-jdbc</artifactId>
    <version>0.2.6</version>
    <packaging>jar</packaging>

    <name>clickhouse-jdbc</name>
    <description>JDBC driver for ClickHouse</description>
    <url>https://github.com/ClickHouse/clickhouse-jdbc</url>
    <licenses>
        <license>
            <name>The Apache Software License, Version 2.0</name>
            <url>http://www.apache.org/licenses/LICENSE-2.0</url>
            <distribution>repo</distribution>
        </license>
    </licenses>
    <scm>
        <url>https://github.com/ClickHouse/clickhouse-jdbc</url>
        <connection>scm:git@github.com:ClickHouse/clickhouse-jdbc.git</connection>
        <developerConnection>scm:git@github.com:ClickHouse/clickhouse-jdbc.git</developerConnection>
    </scm>

    <developers>
        <developer>
            <id>serebrserg</id>
            <name>Sergey Serebryanik</name>
            <email>serebrserg@yandex-team.ru</email>
        </developer>
        <developer>
            <id>jkee</id>
            <name>Viktor Tarnavsky</name>
            <email>jkee@yandex-team.ru</email>
        </developer>
        <developer>
            <id>orantius</id>
            <name>Yuriy Galitskiy</name>
            <email>orantius@yandex-team.ru</email>
        </developer>
        <developer>
            <id>krash</id>
            <name>Alexandr Krasheninnikov</name>
            <email>krash3@gmail.com</email>
        </developer>
        <developer>
            <id>zhicwu</id>
            <name>Zhichun Wu</name>
            <email>zhicwu@gmail.com</email>
        </developer>
    </developers>

    <properties>
        <slf4j.version>1.7.30</slf4j.version>
        <project.current.year>2021</project.current.year>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <httpclient.version>4.5.13</httpclient.version>
        <lz4.version>1.7.1</lz4.version>
        <jackson-core.version>2.9.10</jackson-core.version>
        <jackson-databind.version>2.9.10.8</jackson-databind.version>
        <guava.version>29.0-jre</guava.version>
        <jaxb.version>2.3.1</jaxb.version>
        <jdk.version>1.7</jdk.version>
        <testcontainers.version>1.15.1</testcontainers.version>
        <testng.version>6.14.3</testng.version>
        <mockito.version>1.10.19</mockito.version>
        <wiremock.version>2.27.2</wiremock.version>
        <helper-plugin.version>3.2.0</helper-plugin.version>
        <deploy-plugin.version>3.0.0-M1</deploy-plugin.version>
        <staging-plugin.version>1.6.8</staging-plugin.version>
        <gpg-plugin.version>1.6</gpg-plugin.version>
        <javacc-plugin.version>4.1.4</javacc-plugin.version>
        <compiler-plugin.version>3.8.1</compiler-plugin.version>
        <source-plugin.version>3.2.1</source-plugin.version>
        <jar-plugin.version>3.2.0</jar-plugin.version>
        <javadoc-plugin.version>3.2.0</javadoc-plugin.version>
        <surefire-plugin.version>3.0.0-M5</surefire-plugin.version>
        <failsafe-plugin.version>3.0.0-M5</failsafe-plugin.version>
        <assembly-plugin.version>3.3.0</assembly-plugin.version>
        <shade-plugin.version>3.2.4</shade-plugin.version>
        <shade.base>ru.yandex.clickhouse.jdbc.internal</shade.base>
        <skipTests>false</skipTests>
        <skipITs>${skipTests}</skipITs>
        <skipUTs>${skipTests}</skipUTs>
        <spec.title>JDBC</spec.title>
        <spec.version>4.1</spec.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>${httpclient.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpmime</artifactId>
            <version>${httpclient.version}</version>
        </dependency>
        <dependency>
            <groupId>org.lz4</groupId>
            <artifactId>lz4-java</artifactId>
            <version>${lz4.version}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <version>${jackson-core.version}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>${jackson-databind.version}</version>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>${guava.version}</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${slf4j.version}</version>
        </dependency>
        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <version>${jaxb.version}</version>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>${slf4j.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>testcontainers</artifactId>
            <version>${testcontainers.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>${testng.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-all</artifactId>
            <version>${mockito.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.github.tomakehurst</groupId>
            <artifactId>wiremock-jre8</artifactId>
            <version>${wiremock.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

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

    <profiles>
        <profile>
            <id>release</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                        <version>${source-plugin.version}</version>
                        <executions>
                            <execution>
                                <id>attach-sources</id>
                                <goals>
                                    <goal>jar-no-fork</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>${javadoc-plugin.version}</version>
                        <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>
                        <version>${gpg-plugin.version}</version>
                        <configuration>
                            <!-- Prevent `gpg` from using pinentry programs -->
                            <gpgArguments>
                                <arg>--pinentry-mode</arg>
                                <arg>loopback</arg>
                            </gpgArguments>
                        </configuration>
                        <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-deploy-plugin</artifactId>
                        <version>${deploy-plugin.version}</version>
                        <configuration>
                            <skip>true</skip>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.sonatype.plugins</groupId>
                        <artifactId>nexus-staging-maven-plugin</artifactId>
                        <version>${staging-plugin.version}</version>
                        <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>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>${failsafe-plugin.version}</version>
                <configuration>
                    <argLine>-Duser.timezone=Europe/Moscow</argLine>
                    <includes>**/*.java</includes>
                    <skipTests>${skipTests}</skipTests>
                    <skipITs>${skipITs}</skipITs>
                    <useSystemClassLoader>false</useSystemClassLoader>
                </configuration>
                <executions>
                    <execution>
                        <id>run-integration-tests</id>
                        <phase>integration-test</phase>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${surefire-plugin.version}</version>
                <configuration>
                    <argLine>-Duser.timezone=Europe/Moscow</argLine>
                    <skipTests>${skipUTs}</skipTests>
                    <useSystemClassLoader>false</useSystemClassLoader>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.helger.maven</groupId>
                <artifactId>ph-javacc-maven-plugin</artifactId>
                <version>${javacc-plugin.version}</version>
                <executions>
                    <execution>
                        <id>jjc</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>javacc</goal>
                        </goals>
                        <configuration>
                            <jdkVersion>${jdk.version}</jdkVersion>
                            <javadocFriendlyComments>true</javadocFriendlyComments>
                            <packageName>ru.yandex.clickhouse.jdbc.parser</packageName>
                            <sourceDirectory>src/main/javacc</sourceDirectory>
                            <outputDirectory>src/main/java</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${compiler-plugin.version}</version>
                <configuration>
                    <source>${jdk.version}</source>
                    <target>${jdk.version}</target>
                    <showDeprecation>true</showDeprecation>
                    <showWarnings>true</showWarnings>
                    <fork>true</fork>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>${jar-plugin.version}</version>
                <configuration>
                    <archive>
                        <manifest>
                            <addDefaultEntries>true</addDefaultEntries>
                            <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                            <addBuildEnvironmentEntries>true</addBuildEnvironmentEntries>
                        </manifest>
                        <manifestEntries>
                            <Specification-Title>${spec.title}</Specification-Title>
                            <Specification-Version>${spec.version}</Specification-Version>
                            <Implementation-Vendor-Id>${project.groupId}</Implementation-Vendor-Id>
                        </manifestEntries>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>${assembly-plugin.version}</version>
                <configuration>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                    <archive>
                        <manifest>
                            <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                            <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>${shade-plugin.version}</version>
                <configuration>
                    <shadedArtifactAttached>true</shadedArtifactAttached>
                    <createDependencyReducedPom>true</createDependencyReducedPom>
                    <promoteTransitiveDependencies>true</promoteTransitiveDependencies>
                    <shadedClassifierName>shaded</shadedClassifierName>
                    <relocations>
                        <relocation>
                            <pattern>com.fasterxml.jackson</pattern>
                            <shadedPattern>${shade.base}.jackson</shadedPattern>
                        </relocation>
                        <relocation>
                            <pattern>com.google</pattern>
                            <shadedPattern>${shade.base}.google</shadedPattern>
                        </relocation>
                        <relocation>
                            <pattern>org.apache</pattern>
                            <shadedPattern>${shade.base}.apache</shadedPattern>
                        </relocation>
                        <relocation>
                            <pattern>org.checkerframework</pattern>
                            <shadedPattern>${shade.base}.checker</shadedPattern>
                        </relocation>
                        <relocation>
                            <pattern>net.jpountz</pattern>
                            <shadedPattern>${shade.base}.jpountz</shadedPattern>
                        </relocation>
                        <relocation>
                            <pattern>org.slf4j</pattern>
                            <shadedPattern>${shade.base}.slf4j</shadedPattern>
                        </relocation>
                    </relocations>
                    <transformers>
                        <transformer implementation="org.apache.maven.plugins.shade.resource.ApacheLicenseResourceTransformer"/>
                        <transformer implementation="org.apache.maven.plugins.shade.resource.ApacheNoticeResourceTransformer"/>
                        <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
                        <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                            <manifestEntries>
                                <!-- https://docs.oracle.com/en/java/javase/11/docs/api/java.sql/java/sql/package-summary.html -->
                                <Specification-Title>${spec.title}</Specification-Title>
                                <Specification-Version>${spec.version}</Specification-Version>
                                <Implementation-Title>${project.name}</Implementation-Title>
                                <Implementation-Version>${project.version}</Implementation-Version>
                                <Implementation-Vendor-Id>${project.groupId}</Implementation-Vendor-Id>
                            </manifestEntries>
                        </transformer>
                    </transformers>
                    <filters>
                        <filter>
                            <artifact>*:*</artifact>
                            <excludes>
                                <exclude>javax/**</exclude>
                                <exclude>mozilla/**</exclude>
                                <exclude>darwin/**</exclude>
                                <exclude>linux/**</exclude>
                                <exclude>win32/**</exclude>
                                <exclude>META-INF/maven/**</exclude>
                                <exclude>META-INF/native-image/**</exclude>
                                <exclude>META-INF/versions/**</exclude>
                                <exclude>META-INF/*.xml</exclude>
                            </excludes>
                        </filter>
                    </filters>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <keepDependenciesWithProvidedScope>false</keepDependenciesWithProvidedScope>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
