<?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>ru.yandex.clickhouse</groupId>
    <artifactId>clickhouse-jdbc-bridge</artifactId>
    <packaging>jar</packaging>
    <version>2.0.2</version>
    <name>ClickHouse JDBC Bridge</name>
    <url>https://github.com/ClickHouse/clickhouse-jdbc-bridge</url>
    <description>JDBC bridge for ClickHouse.</description>
    <inceptionYear>2019</inceptionYear>

    <properties>
        <caffeine.version>2.8.6</caffeine.version>
        <dnsjava.version>3.3.1</dnsjava.version>
        <vertx.version>3.9.5</vertx.version>
        <micrometer.version>1.1.19</micrometer.version>
        <slf4j.version>1.7.30</slf4j.version>
        <hikaricp.version>3.4.5</hikaricp.version>
        <project.current.year>2021</project.current.year>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <java.version>1.8</java.version>
        <testcontainers.version>1.15.1</testcontainers.version>
        <testng.version>6.14.3</testng.version>
        <main.basedir>${project.basedir}</main.basedir>
        <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>
        <replacer-plugin.version>1.5.3</replacer-plugin.version>
        <license-plugin.version>2.11</license-plugin.version>
        <notice-plugin.version>1.1.0</notice-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>
        <shade-plugin.version>3.2.4</shade-plugin.version>
        <shade.base>ru.yandex.clickhouse.jdbcbridge.internal</shade.base>
        <deb-plugin.version>1.0.20</deb-plugin.version>
        <rpm-plugin.version>2.2.0</rpm-plugin.version>
        <skipTests>false</skipTests>
        <skipITs>${skipTests}</skipITs>
        <skipUTs>${skipTests}</skipUTs>
    </properties>

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

    <developers>
        <developer>
            <name>Zhichun Wu</name>
            <email>zhicwu@gmail.com</email>
        </developer>
    </developers>

    <scm>
        <connection>scm:git:git@github.com:ClickHouse/clickhouse-jdbc-bridge.git</connection>
        <developerConnection>scm:git:git@github.com:ClickHouse/clickhouse-jdbc-bridge.git</developerConnection>
        <url>https://github.com/ClickHouse/clickhouse-jdbc-bridge</url>
        <tag>${project.version}</tag>
    </scm>

    <dependencies>
        <!-- In-memory cache -->
        <dependency>
            <groupId>com.github.ben-manes.caffeine</groupId>
            <artifactId>caffeine</artifactId>
            <version>${caffeine.version}</version>
        </dependency>

        <!-- Connection pooling -->
        <dependency>
            <groupId>com.zaxxer</groupId>
            <artifactId>HikariCP</artifactId>
            <version>${hikaricp.version}</version>
        </dependency>

        <!-- SRV record resolving -->
        <dependency>
            <groupId>dnsjava</groupId>
            <artifactId>dnsjava</artifactId>
            <version>${dnsjava.version}</version>
        </dependency>

        <!-- Async Web server -->
        <dependency>
            <groupId>io.vertx</groupId>
            <artifactId>vertx-core</artifactId>
            <version>${vertx.version}</version>
        </dependency>
        <dependency>
            <groupId>io.vertx</groupId>
            <artifactId>vertx-config</artifactId>
            <version>${vertx.version}</version>
        </dependency>
        <dependency>
            <groupId>io.vertx</groupId>
            <artifactId>vertx-web</artifactId>
            <version>${vertx.version}</version>
        </dependency>
        <dependency>
            <groupId>io.vertx</groupId>
            <artifactId>vertx-web-client</artifactId>
            <version>${vertx.version}</version>
        </dependency>
        <dependency>
            <groupId>io.vertx</groupId>
            <artifactId>vertx-micrometer-metrics</artifactId>
            <version>${vertx.version}</version>
        </dependency>

        <!-- Monitoring -->
        <dependency>
            <groupId>io.micrometer</groupId>
            <artifactId>micrometer-registry-prometheus</artifactId>
            <version>${micrometer.version}</version>
        </dependency>

        <!-- Logging -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${slf4j.version}</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>${slf4j.version}</version>
        </dependency>

        <!-- Unit/Integration test -->
        <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>
            <exclusions>
                <exclusion>
                    <groupId>org.apache-extras.beanshell</groupId>
                    <artifactId>bsh</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>

    <!-- http://central.sonatype.org/pages/apache-maven.html -->
    <distributionManagement>
        <snapshotRepository>
            <id>ossrh</id>
            <url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
        </snapshotRepository>
        <repository>
            <id>ossrh</id>
            <url>https://s01.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>
                        <!-- https://github.com/microsoft/WSL/issues/2465#issuecomment-377583291 -->
                        <groupId>com.github.fracpete</groupId>
                        <artifactId>debian-maven-plugin</artifactId>
                        <version>${deb-plugin.version}</version>
                        <executions>
                            <execution>
                                <id>generate-deb</id>
                                <goals>
                                    <goal>package</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <projectUrl>${project.url}</projectUrl>
                            <projectOrganization>${project.developers[0].name}</projectOrganization>
                            <packageDescription>JDBC bridge for ClickHouse. It acts as a stateless proxy passing queries from ClickHouse to external datasources.</packageDescription>
                            <createSymLinks>true</createSymLinks>
                            <createIncludeFiles>false</createIncludeFiles>
                            <excludeAllArtifacts>true</excludeAllArtifacts>
                            <excludeAllDependencies>true</excludeAllDependencies>
                            <libDirectory>/usr/local/lib/java</libDirectory>
                            <useDefaultCopyResources>false</useDefaultCopyResources>
                            <useDefaultFixPermissions>true</useDefaultFixPermissions>
                            <copyResources>
                                <copyResource>
                                    <source>docker</source>
                                    <target>target/deb/etc/clickhouse-jdbc-bridge</target>
                                    <include>.*\.properties</include>
                                </copyResource>
                                <copyResource>
                                    <source>docker</source>
                                    <target>target/deb/etc/clickhouse-jdbc-bridge</target>
                                    <include>.*\.example</include>
                                </copyResource>
                                <copyResource>
                                    <source>docker/config</source>
                                    <target>target/deb/etc/clickhouse-jdbc-bridge/config</target>
                                    <include>.*</include>
                                </copyResource>
                                <copyResource>
                                    <source>src/main/bin</source>
                                    <target>target/deb/usr/local/bin</target>
                                    <include>.*</include>
                                </copyResource>
                            </copyResources>
                            <packageDependencies>
                                <packageDependency>default-jre</packageDependency>
                            </packageDependencies>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>rpm-maven-plugin</artifactId>
                        <version>${rpm-plugin.version}</version>
                        <executions>
                            <execution>
                                <id>generate-rpm</id>
                                <goals>
                                    <goal>rpm</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <license>Apache License 2.0</license>
                            <group>Applications/Databases</group>
                            <changelogFile>src/changelog</changelogFile>
                            <defineStatements>
                                <defineStatement>_unpackaged_files_terminate_build 0</defineStatement>
                            </defineStatements>
                            <requires>
                                <require>jre-headless &gt;= 1.8</require>
                            </requires>
                            <mappings>
                                <mapping>
                                    <directory>/etc/clickhouse-jdbc-bridge</directory>
                                    <filemode>0644</filemode>
                                    <username>root</username>
                                    <groupname>root</groupname>
                                    <sources>
                                        <source>
                                            <location>docker/log4j.properties</location>
                                        </source>
                                        <source>
                                            <location>docker/set-env.sh.example</location>
                                        </source>
                                    </sources>
                                </mapping>
                                <mapping>
                                    <directory>/etc/clickhouse-jdbc-bridge/config</directory>
                                    <filemode>0644</filemode>
                                    <username>root</username>
                                    <groupname>root</groupname>
                                    <sources>
                                        <source>
                                            <location>docker/config</location>
                                        </source>
                                    </sources>
                                </mapping>
                                <mapping>
                                    <directory>/usr/local/lib/java</directory>
                                    <filemode>0644</filemode>
                                    <username>root</username>
                                    <groupname>root</groupname>
                                    <sources>
                                        <source>
                                            <location>target/clickhouse-jdbc-bridge-${project.version}-shaded.jar</location>
                                        </source>
                                        <softlinkSource>
                                            <location>/usr/local/lib/java/clickhouse-jdbc-bridge-${project.version}-shaded.jar</location>
                                            <destination>clickhouse-jdbc-bridge-shaded.jar</destination>
                                        </softlinkSource>
                                    </sources>
                                </mapping>
                                <mapping>
                                    <directory>/usr/local/bin</directory>
                                    <filemode>0755</filemode>
                                    <username>root</username>
                                    <groupname>root</groupname>
                                    <sources>
                                        <source>
                                            <location>src/main/bin</location>
                                        </source>
                                    </sources>
                                </mapping>
                            </mappings>
                        </configuration>
                    </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://s01.oss.sonatype.org/</nexusUrl>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.jasig.maven</groupId>
                <artifactId>maven-notice-plugin</artifactId>
                <version>${notice-plugin.version}</version>
                <configuration>
                    <noticeTemplate>misc/notice.template</noticeTemplate>
                    <licenseMapping>
                        <param>misc/license-mappings.xml</param>
                    </licenseMapping>
                    <generateChildNotices>false</generateChildNotices>
                    <includeChildDependencies>false</includeChildDependencies>
                </configuration>
                <executions>
                    <execution>
                        <id>check-license</id>
                        <phase>initialize</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.google.code.maven-replacer-plugin</groupId>
                <artifactId>replacer</artifactId>
                <version>${replacer-plugin.version}</version>
                <executions>
                    <execution>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>replace</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <file>src/main/resources/log4j.properties</file>
                    <outputFile>target/classes/log4j.properties</outputFile>
                    <replacements>
                        <replacement>
                            <token>org.apache.log4j</token>
                            <value>${shade.base}.log4j</value>
                        </replacement>
                    </replacements>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.mycila</groupId>
                <artifactId>license-maven-plugin</artifactId>
                <version>${license-plugin.version}</version>
                <configuration>
                    <header>misc/license-header.template</header>
                    <properties>
                        <inceptionYear>${project.inceptionYear}</inceptionYear>
                        <latestYearOfContribution>${project.current.year}</latestYearOfContribution>
                    </properties>
                    <includes>
                        <include>src/**/*.java</include>
                    </includes>
                </configuration>
                <executions>
                    <execution>
                        <id>check-license</id>
                        <phase>initialize</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${compiler-plugin.version}</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${surefire-plugin.version}</version>
                <configuration>
                    <groups>unit</groups>
                    <skipTests>${skipUTs}</skipTests>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>${failsafe-plugin.version}</version>
                <configuration>
                    <includes>**/*.java</includes>
                    <groups>sit</groups>
                    <skipTests>${skipTests}</skipTests>
                    <skipITs>${skipITs}</skipITs>
                </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-jar-plugin</artifactId>
                <version>${jar-plugin.version}</version>
                <configuration>
                    <archive>
                        <manifest>
                            <mainClass>ru.yandex.clickhouse.jdbcbridge.JdbcBridgeVerticle</mainClass>
                        </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.github</pattern>
                            <shadedPattern>${shade.base}.github</shadedPattern>
                        </relocation>
                        <relocation>
                            <pattern>com.zaxxer</pattern>
                            <shadedPattern>${shade.base}.zaxxer</shadedPattern>
                        </relocation>
                        <relocation>
                            <pattern>io.dropwizard</pattern>
                            <shadedPattern>${shade.base}.dropwizard</shadedPattern>
                        </relocation>
                        <relocation>
                            <pattern>io.micrometer</pattern>
                            <shadedPattern>${shade.base}.micrometer</shadedPattern>
                        </relocation>
                        <relocation>
                            <pattern>io.prometheus</pattern>
                            <shadedPattern>${shade.base}.prometheus</shadedPattern>
                        </relocation>
                        <relocation>
                            <pattern>io.vertx</pattern>
                            <shadedPattern>${shade.base}.vertx</shadedPattern>
                        </relocation>
                        <relocation>
                            <pattern>io.netty</pattern>
                            <shadedPattern>${shade.base}.netty</shadedPattern>
                        </relocation>
                        <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>com.codahale.metrics</pattern>
                            <shadedPattern>${shade.base}.metrics</shadedPattern>
                        </relocation>
                        <relocation>
                            <pattern>org.apache.log4j</pattern>
                            <shadedPattern>${shade.base}.log4j</shadedPattern>
                        </relocation>
                        <relocation>
                            <pattern>org.checkerframework</pattern>
                            <shadedPattern>${shade.base}.checker</shadedPattern>
                        </relocation>
                        <relocation>
                            <pattern>org.xbill.DNS</pattern>
                            <shadedPattern>${shade.base}.dnsjava</shadedPattern>
                        </relocation>
                        <relocation>
                            <pattern>org.slf4j</pattern>
                            <shadedPattern>${shade.base}.slf4j</shadedPattern>
                        </relocation>
                        <relocation>
                            <pattern>org.HdrHistogram</pattern>
                            <shadedPattern>${shade.base}.HdrHistogram</shadedPattern>
                        </relocation>
                        <relocation>
                            <pattern>org.LatencyUtils</pattern>
                            <shadedPattern>${shade.base}.LatencyUtils</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"/>
                    </transformers>
                    <filters>
                        <filter>
                            <artifact>*:*</artifact>
                            <excludes>
                                <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>
