<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://maven.apache.org/POM/4.0.0"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion>
    <groupId>org.mariadb.jdbc</groupId>
    <artifactId>mariadb-java-client</artifactId>
    <packaging>jar</packaging>
    <name>mariadb-java-client</name>
    <version>4.0.0</version>
    <description>JDBC driver for MariaDB and MySQL</description>
    <url>https://mariadb.com/kb/en/mariadb/about-mariadb-connector-j/</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.release>17</maven.compiler.release>
        <argLine></argLine>
        <jmh.version>1.37</jmh.version>
        <junit.version>6.1.3</junit.version>
        <junit-pioneer.version>2.3.0</junit-pioneer.version>
        <logback.version>1.6.3</logback.version>
        <jacoco.version>0.8.15</jacoco.version>
        <mysql-connector-java.version>26.7.0</mysql-connector-java.version>
        <bnd-maven-plugin.version>7.4.0</bnd-maven-plugin.version>
        <spotless.version>3.10.2</spotless.version>
        <cyclonedx-maven-plugin.version>2.9.3</cyclonedx-maven-plugin.version>
        <gmavenplus-plugin.version>5.1.0</gmavenplus-plugin.version>
        <groovy.version>6.0.0</groovy.version>
    </properties>

    <licenses>
        <license>
            <name>LGPL-2.1-or-later</name>
            <url>https://spdx.org/licenses/LGPL-2.1-or-later.html</url>
        </license>
    </licenses>

    <organization>
        <name>MariaDB plc</name>
        <url>https://mariadb.com</url>
    </organization>

    <developers>
        <developer>
            <id>mariadbJdbcDevelopers</id>
            <name>mariadb jdbc developers</name>
            <url>http://mariadb.org/</url>
        </developer>
    </developers>

    <scm>
        <connection>scm:git:git://github.com/mariadb-corporation/mariadb-connector-j.git</connection>
        <url>https://github.com/mariadb-corporation/mariadb-connector-j</url>
        <developerConnection>scm:git:git@github.com:MariaDB/mariadb-connector-j.git
        </developerConnection>
    </scm>

    <issueManagement>
        <system>JIRA</system>
        <url>https://mariadb.atlassian.net/browse/CONJ</url>
    </issueManagement>

    <distributionManagement>
        <snapshotRepository>
            <id>ossrh</id>
            <url>https://central.sonatype.com/repository/maven-snapshots/</url>
        </snapshotRepository>
    </distributionManagement>

    <dependencyManagement>
        <dependencies>

            <dependency>
                <groupId>org.junit</groupId>
                <artifactId>junit-bom</artifactId>
                <version>${junit.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

        </dependencies>

    </dependencyManagement>

    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.16.0</version>
                <configuration>
                    <release>${maven.compiler.release}</release>
                    <showWarnings>true</showWarnings>
                    <compilerArgs>
                        <arg>-Xlint:all,-path,-processing,-requires-automatic,-requires-transitive-automatic,-missing-explicit-ctor,-exports,-try</arg>
                    </compilerArgs>
                </configuration>
                <executions>
                    <execution>
                        <id>default-testCompile</id>
                        <configuration>
                            <!-- tests run on the class path (surefire useModulePath=false): compile them
                                 there too, so that test-only JDK modules such as jdk.jfr are visible -->
                            <useModulePath>false</useModulePath>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>${jacoco.version}</version>
                <executions>
                    <execution>
                        <id>jacoco-initialize</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>report</id>
                        <phase>test</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>3.12.0</version>
                <configuration>
                    <release>${maven.compiler.release}</release>
                    <excludePackageNames>
                        org.mariadb.jdbc.client,org.mariadb.jdbc.codec,org.mariadb.jdbc.message,org.mariadb.jdbc.util,org.mariadb.jdbc.plugin.authentication.standard.ed25519,org.mariadb.jdbc.plugin.authentication.standard.ed25519.*
                    </excludePackageNames>
                </configuration>
                <executions>
                    <execution>
                        <id>attach-javadocs</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.5.1</version>
                <configuration>
                    <archive>
                        <manifestEntries>
                            <Export-Package>org.mariadb.jdbc</Export-Package>
                            <Import-Package>
                                javax.naming,javax.naming.ldap,javax.management,javax.sql,javax.net;resolution:=optional,javax.net.ssl;resolution:=optional,javax.transaction.xa;resolution:=optional,org.ietf.jgss;resolution:=optional,javax.security.auth.login;resolution:=optional,javax.security.auth.x500;resolution:=optional,javax.crypto;resolution:=optional,org.slf4j;resolution:=optional
                            </Import-Package>
                        </manifestEntries>
                        <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
                    </archive>
                </configuration>
                <executions>
                    <!-- The jar is built before the tests run, so that surefire tests the jar itself
                         (module descriptor, manifest headers written by bnd) rather than target/classes -->
                    <execution>
                        <id>default-jar</id>
                        <phase>process-test-classes</phase>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>3.4.0</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>jar-no-fork</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.sonatype.central</groupId>
                <artifactId>central-publishing-maven-plugin</artifactId>
                <version>0.11.0</version>
                <extensions>true</extensions>
                <executions>
                    <execution>
                        <phase>deploy</phase>
                    </execution>
                </executions>
                <configuration>
                    <publishingServerId>ossrh</publishingServerId>
                    <autoPublish>true</autoPublish>
                    <waitUntil>published</waitUntil>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-gpg-plugin</artifactId>
                <version>3.2.8</version>
                <executions>
                    <execution>
                        <phase>verify</phase>
                        <goals>
                            <goal>sign</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.diffplug.spotless</groupId>
                <artifactId>spotless-maven-plugin</artifactId>
                <version>${spotless.version}</version>
                <configuration>
                    <formats>
                        <format>
                            <includes>
                                <include>*.md</include>
                                <include>.gitignore</include>
                            </includes>
                            <trimTrailingWhitespace/>
                            <endWithNewline/>
                            <indent>
                                <tabs>true</tabs>
                                <spacesPerTab>2</spacesPerTab>
                            </indent>
                        </format>
                    </formats>
                    <java>
                        <excludes>
                            <exclude>src/main/java/org/mariadb/jdbc/plugin/authentication/standard/ed25519/**/*.java
                            </exclude>
                        </excludes>
                        <googleJavaFormat>
                            <version>1.36.1</version>
                            <style>GOOGLE</style>
                            <reflowLongStrings>true</reflowLongStrings>
                            <formatJavadoc>true</formatJavadoc>
                            <groupArtifact>com.google.googlejavaformat:google-java-format</groupArtifact>
                        </googleJavaFormat>
                        <licenseHeader>
                            <file>${project.basedir}/licenseheader.txt</file>
                        </licenseHeader>
                    </java>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.6.0</version>
                <configuration>
                    <!-- tests run on the class path, not as a module patch -->
                    <useModulePath>false</useModulePath>
                    <!-- tests load the driver from the built jar (see maven-jar-plugin), not from
                         target/classes: what is tested is what gets published -->
                    <classesDirectory>${project.build.directory}/${project.build.finalName}.jar</classesDirectory>
                    <!-- junit-pioneer @SetEnvironmentVariable needs java.base opened -->
                    <argLine>@{argLine} --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED</argLine>
                    <systemPropertyVariables>
                        <!-- GSSAPI tests use the JDK native GSS-API bridge (SSPI on windows CI) -->
                        <sun.security.jgss.native>true</sun.security.jgss.native>
                    </systemPropertyVariables>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.cyclonedx</groupId>
                <artifactId>cyclonedx-maven-plugin</artifactId>
                <version>${cyclonedx-maven-plugin.version}</version>
                <configuration>
                    <projectType>library</projectType>
                    <schemaVersion>1.6</schemaVersion>
                    <outputFormat>json</outputFormat>
                    <outputName>bom</outputName>
                    <includeBomSerialNumber>true</includeBomSerialNumber>
                    <includeLicenseText>false</includeLicenseText>
                    <includeTestScope>false</includeTestScope>
                </configuration>
                <executions>
                    <execution>
                        <id>generate-sbom</id>
                        <phase>package</phase>
                        <goals>
                            <goal>makeBom</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!-- Rewrites target/bom.json in place after makeBom with supplier, bundled code, jar hash
                 and a random serial number (see .github/sbom/enrich.groovy). Must stay declared right
                 after cyclonedx-maven-plugin so it runs after it within the package phase. -->
            <plugin>
                <groupId>org.codehaus.gmavenplus</groupId>
                <artifactId>gmavenplus-plugin</artifactId>
                <version>${gmavenplus-plugin.version}</version>
                <dependencies>
                    <dependency>
                        <groupId>org.apache.groovy</groupId>
                        <artifactId>groovy</artifactId>
                        <version>${groovy.version}</version>
                    </dependency>
                    <dependency>
                        <groupId>org.apache.groovy</groupId>
                        <artifactId>groovy-json</artifactId>
                        <version>${groovy.version}</version>
                    </dependency>
                </dependencies>
                <executions>
                    <execution>
                        <id>enrich-sbom</id>
                        <phase>package</phase>
                        <goals>
                            <goal>execute</goal>
                        </goals>
                        <configuration>
                            <scripts>
                                <script>file:///${project.basedir}/.github/sbom/enrich.groovy</script>
                            </scripts>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>biz.aQute.bnd</groupId>
                <artifactId>bnd-maven-plugin</artifactId>
                <version>${bnd-maven-plugin.version}</version>
                <configuration>
                    <bndfile>bnd.bnd</bndfile>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>bnd-process</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

        </plugins>
    </build>

    <dependencies>

        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.junit-pioneer</groupId>
            <artifactId>junit-pioneer</artifactId>
            <version>${junit-pioneer.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>2.0.19</version>
            <optional>true</optional>
        </dependency>

        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>${logback.version}</version>
            <scope>test</scope>
        </dependency>

    </dependencies>

    <profiles>
        <profile>
            <id>bench</id>
            <dependencies>
                <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>com.mysql</groupId>
                    <artifactId>mysql-connector-j</artifactId>
                    <version>${mysql-connector-java.version}</version>
                </dependency>
            </dependencies>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <version>3.16.0</version>
                        <configuration>
                            <compilerArgs combine.children="append">
                                <!-- JDK 23+ no longer runs classpath annotation processors
                                     by default; JMH's generator must be enabled explicitly. -->
                                <arg>-proc:full</arg>
                                <!-- benchmark sources are compiled into the driver module but use
                                     JMH and other class path libraries the module descriptor does
                                     not require: let the module read the class path -->
                                <arg>--add-reads</arg>
                                <arg>org.mariadb.jdbc=ALL-UNNAMED</arg>
                            </compilerArgs>
                        </configuration>
                    </plugin>

                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>build-helper-maven-plugin</artifactId>
                        <version>3.6.2</version>
                        <executions>
                            <execution>
                                <id>add-source</id>
                                <phase>generate-sources</phase>
                                <goals>
                                    <goal>add-source</goal>
                                </goals>
                                <configuration>
                                    <sources>
                                        <source>src/benchmark/java</source>
                                    </sources>
                                </configuration>
                            </execution>
                            <execution>
                                <id>add-resource</id>
                                <phase>generate-resources</phase>
                                <goals>
                                    <goal>add-resource</goal>
                                </goals>
                                <configuration>
                                    <resources>
                                        <resource>
                                            <directory>src/benchmark/resources</directory>
                                        </resource>
                                    </resources>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-shade-plugin</artifactId>
                        <version>3.6.2</version>
                        <configuration>
                            <finalName>benchmarks</finalName>
                            <transformers>
                                <transformer
                                        implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass>org.openjdk.jmh.Main</mainClass>
                                </transformer>
                            </transformers>
                            <filters>
                                <filter>
                                    <artifact>*:*</artifact>
                                    <excludes>
                                        <exclude>META-INF/*.SF</exclude>
                                        <exclude>META-INF/*.DSA</exclude>
                                        <exclude>META-INF/*.RSA</exclude>
                                    </excludes>
                                </filter>
                            </filters>
                        </configuration>
                        <executions>
                            <execution>
                                <phase>package</phase>
                                <goals>
                                    <goal>shade</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <!--
              Runs Facebook Infer static analysis locally, mirroring the CI 'infer' job.
              Infer is not a Maven plugin; it wraps the build, so this profile shells out to the
              'infer' executable (must be on PATH). Bound to 'validate' so the outer build performs
              no compilation; Infer's own inner build runs 'mvn compile'. The fail-on-issue flag makes
              the build fail if Infer reports anything (RacerD is disabled via .inferconfig).
              The outer 'clean' wipes target once (a nested inner 'mvn clean' would conflict with
              this outer Maven process holding target/), then Infer's inner 'mvn compile' captures.
              Usage: mvn -Pinfer clean validate
            -->
            <id>infer</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <version>3.6.4</version>
                        <executions>
                            <execution>
                                <id>infer</id>
                                <phase>validate</phase>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <configuration>
                                    <executable>infer</executable>
                                    <workingDirectory>${project.basedir}</workingDirectory>
                                    <arguments>
                                        <argument>run</argument>
                                        <argument>--fail-on-issue</argument>
                                        <argument>--</argument>
                                        <argument>mvn</argument>
                                        <argument>compile</argument>
                                    </arguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>
