<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>tech.clickhouse</groupId>
        <artifactId>clickhouse-java</artifactId>
        <version>0.3.0</version>
    </parent>

    <groupId>ru.yandex.clickhouse</groupId>
    <artifactId>clickhouse-jdbc</artifactId>
    <version>0.3.0</version>
    <packaging>jar</packaging>

    <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>
        <httpclient.version>4.5.13</httpclient.version>
        <javacc-plugin.version>4.1.4</javacc-plugin.version>
        <shade.base>ru.yandex.clickhouse.jdbc.internal</shade.base>
        <spec.title>JDBC</spec.title>
        <spec.version>4.2</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>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
        </dependency>
        <dependency>
            <groupId>com.github.RoaringBitmap</groupId>
            <artifactId>RoaringBitmap</artifactId>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </dependency>

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

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
            </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>
                <configuration>
                    <source>${jdk.version}</source>
                    <target>${jdk.version}</target>
                    <showWarnings>true</showWarnings>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <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>
                <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>
                <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>org.apache</pattern>
                            <shadedPattern>${shade.base}.apache</shadedPattern>
                        </relocation>
                        <relocation>
                            <pattern>net.jpountz</pattern>
                            <shadedPattern>${shade.base}.jpountz</shadedPattern>
                        </relocation>
                        <relocation>
                            <pattern>org.roaringbitmap</pattern>
                            <shadedPattern>${shade.base}.bitmap</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>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>
