<?xml version="1.0" encoding="UTF-8"?>
<project
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"
    xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

    <modelVersion>4.0.0</modelVersion>
    <groupId>dnsjava</groupId>
    <artifactId>dnsjava</artifactId>
    <packaging>bundle</packaging>
    <version>3.6.1</version>
    <name>dnsjava</name>
    <description>dnsjava is an implementation of DNS in Java. It supports all defined record types (including the DNSSEC
        types), and unknown types. It can be used for queries, zone transfers, and dynamic updates. It includes a cache
        which can be used by clients, and a minimal implementation of a server. It supports TSIG authenticated messages,
        partial DNSSEC verification, and EDNS0.
    </description>
    <url>https://github.com/dnsjava/dnsjava</url>
    <organization>
        <name>dnsjava.org</name>
        <url>https://github.com/dnsjava/dnsjava</url>
    </organization>
    <licenses>
        <license>
            <name>BSD-3-Clause</name>
            <url>https://opensource.org/licenses/BSD-3-Clause</url>
            <distribution>repo</distribution>
        </license>
    </licenses>
    <scm>
        <connection>scm:git:https://github.com/dnsjava/dnsjava</connection>
        <developerConnection>scm:git:https://github.com/dnsjava/dnsjava</developerConnection>
        <url>https://github.com/dnsjava/dnsjava</url>
        <tag>v3.6.1</tag>
    </scm>
    <developers>
        <developer>
            <id>bwelling</id>
            <name>Brian Wellington</name>
        </developer>
        <developer>
            <id>ibauersachs</id>
            <name>Ingo Bauersachs</name>
        </developer>
    </developers>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <target.jdk>8</target.jdk>
        <maven.compiler.showCompilationChanges>true</maven.compiler.showCompilationChanges>
        <maven.compiler.createMissingPackageInfoClass>false</maven.compiler.createMissingPackageInfoClass>

        <org.junit.version>5.10.3</org.junit.version>
        <!-- Stay on 4.x for Java 8 compatibility. Newer versions are used for Java 11+ builds -->
        <mockito.version>4.11.0</mockito.version>
        <slf4j.version>1.7.36</slf4j.version>
        <lombok.version>1.18.34</lombok.version>
        <jna.version>5.14.0</jna.version>
        <bouncycastle.version>1.78.1</bouncycastle.version>
        <vertx.version>4.5.9</vertx.version>
        <!-- Stay on 1.7 for Java 8 compatibility. Newer versions are used for Java 11+ builds -->
        <google-java-format.version>1.7</google-java-format.version>
        <spotless.version>2.30.0</spotless.version>

        <sonar.projectKey>dnsjava_dnsjava</sonar.projectKey>
        <sonar.organization>dnsjava</sonar.organization>
        <sonar.host.url>https://sonarcloud.io</sonar.host.url>
        <sonar.java.source>${target.jdk}</sonar.java.source>
        <sonar.coverage.jacoco.xmlReportPaths>${project.build.directory}/site/jacoco/jacoco.xml
        </sonar.coverage.jacoco.xmlReportPaths>
        <delombok.output>${project.build.directory}/delombok</delombok.output>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-gpg-plugin</artifactId>
                <version>3.2.4</version>
                <executions>
                    <execution>
                        <id>sign-artifacts</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>sign</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <gpgArguments>
                        <arg>--pinentry-mode</arg>
                        <arg>loopback</arg>
                    </gpgArguments>
                    <useAgent>false</useAgent>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.13.0</version>
                <configuration>
                    <compilerArgs>
                        <arg>-Xlint:all,-serial,-processing</arg>
                        <arg>-Xpkginfo:always</arg>
                    </compilerArgs>
                    <annotationProcessorPaths>
                        <path>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                            <version>${lombok.version}</version>
                        </path>
                        <path>
                            <groupId>org.openjdk.jcstress</groupId>
                            <artifactId>jcstress-core</artifactId>
                            <version>0.16</version>
                            <exclusions>
                                <exclusion>
                                    <groupId>*</groupId>
                                    <artifactId>*</artifactId>
                                </exclusion>
                            </exclusions>
                        </path>
                    </annotationProcessorPaths>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>3.3.1</version>
            </plugin>

            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <version>5.1.9</version>
                <extensions>true</extensions>
                <configuration>
                    <niceManifest>true</niceManifest>
                    <excludeDependencies>lombok</excludeDependencies>
                    <instructions>
                        <Bundle-Name>dnsjava</Bundle-Name>
                        <Bundle-Description>dnsjava is an implementation of DNS in Java</Bundle-Description>
                        <Bundle-SymbolicName>org.xbill.dns</Bundle-SymbolicName>
                        <Bundle-DocURL>https://javadoc.io/doc/dnsjava/dnsjava</Bundle-DocURL>
                        <_noclassforname>true</_noclassforname>
                        <_donotcopy>android|sun</_donotcopy>
                        <_nouses>true</_nouses>
                        <_noee>true</_noee>
                        <Export-Package>
                            org.xbill.DNS.*
                        </Export-Package>
                        <Private-Package>!android.*,!sun.*,.</Private-Package>
                        <Import-Package>
                            !org.xbill.DNS*,
                            !sun.*,
                            !lombok,
                            !android.*,
                            javax.naming.*;resolution:=optional,
                            org.slf4j;version="[1.7,3)",
                            com.sun.jna.*;resolution:=optional;version="[5,6)",
                            *
                        </Import-Package>
                        <Bundle-License>
                            BSD-3-Clause;link="https://raw.githubusercontent.com/dnsjava/dnsjava/master/LICENSE"
                        </Bundle-License>
                        <_removeheaders>Bnd-*, Tool, Require-Capability, Include-Resource, Private-Package</_removeheaders>
                        <_snapshot>SNAPSHOT</_snapshot>
                        <Include-Resource>
                            {maven-resources},
                            META-INF/LICENSE=LICENSE
                        </Include-Resource>
                        <Main-Class>org.xbill.DNS.tools.Tools</Main-Class>
                        <_fixupmessages>"Classes found in the wrong directory";is:=ignore</_fixupmessages>
                        <Multi-Release>true</Multi-Release>
                    </instructions>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.projectlombok</groupId>
                <artifactId>lombok-maven-plugin</artifactId>
                <version>1.18.20.0</version>
                <configuration>
                    <sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
                    <addOutputDirectory>false</addOutputDirectory>
                    <outputDirectory>${delombok.output}</outputDirectory>
                </configuration>
                <executions>
                    <execution>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>delombok</goal>
                        </goals>
                    </execution>
                </executions>

                <dependencies>
                    <dependency>
                        <groupId>org.projectlombok</groupId>
                        <artifactId>lombok</artifactId>
                        <version>${lombok.version}</version>
                    </dependency>
                </dependencies>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>3.8.0</version>
                <configuration>
                    <source>${target.jdk}</source>
                    <sourcepath>${delombok.output}</sourcepath>
                    <debug>true</debug>
                    <windowtitle>dnsjava documentation</windowtitle>
                    <footer/>
                    <doclint>none</doclint>
                    <excludePackageNames>android,android.*,sun.*</excludePackageNames>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.3.1</version>
                <configuration>
                    <rerunFailingTestsCount>3</rerunFailingTestsCount>
                    <includes>
                        <!-- Override default config to include inner test classes -->
                        <include>**/*Test*</include>
                    </includes>
                    <excludes>
                        <!-- Override default config to not exclude inner test classes -->
                        <exclude/>
                    </excludes>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>0.8.12</version>
                <executions>
                    <execution>
                        <id>prepare-agent</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>report</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>default-cli</id>
                        <goals>
                            <goal>merge</goal>
                        </goals>
                        <configuration>
                            <fileSets>
                                <fileSet>
                                    <directory>${project.build.directory}</directory>
                                    <includes>
                                        <include>jacoco-*.exec</include>
                                    </includes>
                                </fileSet>
                            </fileSets>
                            <destFile>${project.build.directory}/jacoco.exec</destFile>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>com.github.siom79.japicmp</groupId>
                <artifactId>japicmp-maven-plugin</artifactId>
                <version>0.21.2</version>
                <configuration>
                    <newVersion>
                        <file>
                            <path>${project.build.directory}/${project.artifactId}-${project.version}.jar</path>
                        </file>
                    </newVersion>
                    <parameter>
                        <onlyModified>true</onlyModified>
                        <accessModifier>public</accessModifier>
                        <breakBuildBasedOnSemanticVersioning>true</breakBuildBasedOnSemanticVersioning>
                        <breakBuildOnBinaryIncompatibleModifications>true</breakBuildOnBinaryIncompatibleModifications>
                        <breakBuildOnSourceIncompatibleModifications>true</breakBuildOnSourceIncompatibleModifications>
                        <excludes>
                            <!-- Ignore classes that we need for compilation only -->
                            <exclude>android</exclude>
                            <exclude>sun</exclude>
                            <!-- internal API detected as public -->
                            <exclude>org.xbill.DNS.config.IPHlpAPI</exclude>
                            <exclude>org.xbill.DNS.spi.DnsjavaInetAddressResolver</exclude>
                            <exclude>org.xbill.DNS.spi.DNSJavaNameService</exclude>
                            <exclude>org.xbill.DNS.spi.DNSJavaNameServiceDescriptor</exclude>
                        </excludes>
                        <overrideCompatibilityChangeParameters>
                            <overrideCompatibilityChangeParameter>
                                <compatibilityChange>ANNOTATION_DEPRECATED_ADDED</compatibilityChange>
                                <semanticVersionLevel>PATCH</semanticVersionLevel>
                                <sourceCompatible>true</sourceCompatible>
                                <binaryCompatible>true</binaryCompatible>
                            </overrideCompatibilityChangeParameter>
                        </overrideCompatibilityChangeParameters>
                    </parameter>
                </configuration>
                <executions>
                    <execution>
                        <id>check-compatibility</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>cmp</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>com.diffplug.spotless</groupId>
                <artifactId>spotless-maven-plugin</artifactId>
                <version>${spotless.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>check</goal>
                        </goals>
                        <phase>verify</phase>
                    </execution>
                </executions>
                <configuration>
                    <formats>
                        <format>
                            <includes>
                                <include>*.*</include>
                            </includes>
                            <excludes>
                                <exclude>*.iml</exclude>
                                <exclude>jcstress-*</exclude>
                            </excludes>
                            <trimTrailingWhitespace/>
                            <endWithNewline/>
                        </format>
                    </formats>

                    <java>
                        <includes>
                            <include>src/main/java/**/*.java</include>
                            <include>src/main/java11/**/*.java</include>
                            <include>src/main/java18/**/*.java</include>
                            <include>src/test/java/**/*.java</include>
                        </includes>
                        <googleJavaFormat>
                            <version>${google-java-format.version}</version>
                        </googleJavaFormat>
                        <removeUnusedImports/>
                        <importOrder/>
                    </java>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
                <version>3.4.0</version>
                <executions>
                    <execution>
                        <id>check</id>
                        <goals>
                            <goal>check</goal>
                        </goals>
                        <phase>verify</phase>
                    </execution>
                </executions>
                <configuration>
                    <!--
                    Still too many failure (mostly in Javadoc) to enable it fully:
                    <configLocation>google_checks.xml</configLocation>
                    -->
                    <configLocation>checkstyle/checkstyle-config.xml</configLocation>
                    <suppressionsLocation>checkstyle/checkstyle-suppressions.xml</suppressionsLocation>
                    <includeTestSourceDirectory>true</includeTestSourceDirectory>
                    <linkXRef>false</linkXRef>
                    <consoleOutput>true</consoleOutput>
                    <failsOnError>true</failsOnError>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>com.puppycrawl.tools</groupId>
                        <artifactId>checkstyle</artifactId>
                        <version>9.3</version>
                    </dependency>
                </dependencies>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>3.1.2</version>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-clean-plugin</artifactId>
                <version>3.4.0</version>
                <configuration>
                    <filesets>
                        <fileset>
                            <!-- JCStress writes to the project directory without any option to configure the target -->
                            <directory>${project.basedir}</directory>
                            <includes>
                                <include>jcstress-*</include>
                            </includes>
                        </fileset>
                    </filesets>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-site-plugin</artifactId>
                <version>3.12.1</version>
            </plugin>

            <plugin>
                <groupId>org.sonatype.plugins</groupId>
                <artifactId>nexus-staging-maven-plugin</artifactId>
                <version>1.7.0</version>
                <extensions>true</extensions>
                <configuration>
                    <serverId>ossrh</serverId>
                    <nexusUrl>https://oss.sonatype.org/</nexusUrl>
                    <autoReleaseAfterClose>true</autoReleaseAfterClose>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>animal-sniffer-maven-plugin</artifactId>
                <version>1.24</version>
                <configuration>
                    <signature>
                        <groupId>net.sf.androidscents.signature</groupId>
                        <artifactId>android-api-level-26</artifactId>
                        <version>8.0.0_r2</version>
                    </signature>
                    <ignores>
                        <ignore>javax.naming.NamingException</ignore>
                        <ignore>javax.naming.directory.*</ignore>
                        <ignore>sun.net.spi.nameservice.*</ignore>
                        <ignore>java.net.spi.*</ignore>
                    </ignores>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.ow2.asm</groupId>
                        <artifactId>asm</artifactId>
                        <version>9.6</version>
                    </dependency>
                </dependencies>
                <executions>
                    <execution>
                        <id>animal-sniffer</id>
                        <phase>test</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>3.3.1</version>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-install-plugin</artifactId>
                <version>3.1.2</version>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <version>3.6.0</version>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${slf4j.version}</version>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>${lombok.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>net.java.dev.jna</groupId>
            <artifactId>jna</artifactId>
            <version>${jna.version}</version>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>net.java.dev.jna</groupId>
            <artifactId>jna-platform</artifactId>
            <version>${jna.version}</version>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.bouncycastle</groupId>
            <artifactId>bcprov-jdk18on</artifactId>
            <version>${bouncycastle.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.bouncycastle</groupId>
            <artifactId>bcutil-jdk18on</artifactId>
            <version>${bouncycastle.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>${org.junit.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>${org.junit.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-params</artifactId>
            <version>${org.junit.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <version>3.26.3</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>${mockito.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-junit-jupiter</artifactId>
            <version>${mockito.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>net.bytebuddy</groupId>
            <artifactId>byte-buddy-agent</artifactId>
            <version>1.14.18</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <version>${slf4j.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.vertx</groupId>
            <artifactId>vertx-core</artifactId>
            <version>${vertx.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.vertx</groupId>
            <artifactId>vertx-junit5</artifactId>
            <version>${vertx.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <!-- Not actually needed, but required to silence javac annotation processor warnings -->
            <groupId>io.vertx</groupId>
            <artifactId>vertx-codegen</artifactId>
            <version>${vertx.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.16.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.openjdk.jcstress</groupId>
            <artifactId>jcstress-core</artifactId>
            <version>0.16</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <profiles>
        <profile>
            <id>java8</id>
            <activation>
                <jdk>[,9)</jdk>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <configuration>
                            <source>${target.jdk}</source>
                            <target>${target.jdk}</target>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>java11</id>
            <activation>
                <jdk>[11,)</jdk>
            </activation>

            <properties>
                <mockito.version>5.12.0</mockito.version>
                <google-java-format.version>1.17.0</google-java-format.version>
                <spotless.version>2.43.0</spotless.version>
            </properties>

            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.felix</groupId>
                        <artifactId>maven-bundle-plugin</artifactId>
                        <configuration>
                            <instructions>
                                <Include-Resource>
                                    {maven-resources},
                                    META-INF/versions=-target/classes/META-INF/versions,
                                    META-INF/LICENSE=LICENSE
                                </Include-Resource>
                            </instructions>
                        </configuration>
                    </plugin>

                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <configuration>
                            <release>${target.jdk}</release>
                            <compilerArgs>
                                <arg>-Xlint:all,-serial,-processing,-requires-automatic</arg>
                                <arg>-Xpkginfo:always</arg>
                            </compilerArgs>
                        </configuration>

                        <executions>
                            <!-- Compile by default for Java 8 -->
                            <execution>
                                <id>default-compile</id>
                                <goals>
                                    <goal>compile</goal>
                                </goals>
                                <configuration>
                                    <release>${target.jdk}</release>
                                    <compileSourceRoots>
                                        <compileSourceRoot>${project.basedir}/src/main/java</compileSourceRoot>
                                    </compileSourceRoots>
                                </configuration>
                            </execution>

                            <!-- Compile Java 11+ stuff (module-info) -->
                            <execution>
                                <id>compile-java11</id>
                                <goals>
                                    <goal>compile</goal>
                                </goals>
                                <configuration>
                                    <release>11</release>
                                    <multiReleaseOutput>true</multiReleaseOutput>
                                    <compileSourceRoots>
                                        <compileSourceRoot>${project.basedir}/src/main/java11</compileSourceRoot>
                                    </compileSourceRoots>
                                </configuration>
                            </execution>

                            <execution>
                                <id>default-testCompile</id>
                                <configuration>
                                    <release>${target.jdk}</release>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>

                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <argLine>
                                @{argLine}
                                --add-opens java.base/sun.net.dns=ALL-UNNAMED
                            </argLine>
                            <additionalClasspathElements>
                                <additionalClasspathElement>${project.build.outputDirectory}/META-INF/versions/11</additionalClasspathElement>
                            </additionalClasspathElements>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <!-- Hide java11 from IDEA as it still doesn't understand Multi-Release jars -->
            <id>java11-not-idea</id>
            <activation>
                <activeByDefault>false</activeByDefault>
                <jdk>[11,)</jdk>
                <property>
                    <name>!idea.version</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>build-helper-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>add-java11-source</id>
                                <phase>generate-sources</phase>
                                <goals>
                                    <goal>add-source</goal>
                                </goals>
                                <configuration>
                                    <sources>
                                        <source>src/main/java11</source>
                                    </sources>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <!-- Include java11 in IDEA before Java 18 as it still doesn't understand Multi-Release jars -->
            <id>java11-idea</id>
            <activation>
                <activeByDefault>false</activeByDefault>
                <jdk>[11,18)</jdk>
                <property>
                    <name>idea.version</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>build-helper-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>add-java11-source</id>
                                <phase>generate-sources</phase>
                                <goals>
                                    <goal>add-source</goal>
                                </goals>
                                <configuration>
                                    <sources>
                                        <source>src/main/java11</source>
                                    </sources>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>java18</id>
            <activation>
                <jdk>[18,)</jdk>
            </activation>

            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <executions>
                            <!-- Compile Java 18+ stuff (DNS SPI) -->
                            <execution>
                                <id>compile-java18</id>
                                <goals>
                                    <goal>compile</goal>
                                </goals>
                                <configuration>
                                    <release>18</release>
                                    <multiReleaseOutput>true</multiReleaseOutput>
                                    <compileSourceRoots>
                                        <compileSourceRoot>${project.basedir}/src/main/java18</compileSourceRoot>
                                    </compileSourceRoots>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>

                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <version>3.7.1</version>
                        <executions>
                            <execution>
                                <phase>initialize</phase>
                                <goals>
                                    <goal>properties</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>

                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <argLine>
                                @{argLine}
                                --add-opens java.base/sun.net.dns=ALL-UNNAMED
                                -javaagent:${net.bytebuddy:byte-buddy-agent:jar}
                            </argLine>
                            <additionalClasspathElements>
                                <additionalClasspathElement>${project.build.outputDirectory}/META-INF/versions/11</additionalClasspathElement>
                                <additionalClasspathElement>${project.build.outputDirectory}/META-INF/versions/18</additionalClasspathElement>
                            </additionalClasspathElements>
                        </configuration>
                    </plugin>

                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>build-helper-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>add-java18-source</id>
                                <phase>generate-sources</phase>
                                <goals>
                                    <goal>add-source</goal>
                                </goals>
                                <configuration>
                                    <sources>
                                        <source>src/main/java18</source>
                                    </sources>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

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