<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Copyright 2020 The Netty Project
  ~
  ~ The Netty Project licenses this file to you under the Apache License,
  ~ version 2.0 (the "License"); you may not use this file except in compliance
  ~ with the License. You may obtain a copy of the License at:
  ~
  ~   https://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  ~ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  ~ License for the specific language governing permissions and limitations
  ~ under the License.
  -->
<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 https://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>org.sonatype.oss</groupId>
    <artifactId>oss-parent</artifactId>
    <version>9</version>
  </parent>

  <groupId>io.netty.incubator</groupId>
  <artifactId>netty-incubator-codec-quic</artifactId>
  <version>0.0.5.Final</version>
  <name>Netty/Incubator/Codec/Quic</name>
  <packaging>jar</packaging>
  <url>https://netty.io/</url>
  <description>
    Netty is an asynchronous event-driven network application framework for
    rapid development of maintainable high performance protocol servers and
    clients.
  </description>

  <organization>
    <name>The Netty Project</name>
    <url>https://netty.io/</url>
  </organization>

  <licenses>
    <license>
      <name>Apache License, Version 2.0</name>
      <url>https://www.apache.org/licenses/LICENSE-2.0</url>
    </license>
  </licenses>
  <inceptionYear>2020</inceptionYear>

  <scm>
    <url>https://github.com/netty/netty-incubator-codec-quic</url>
    <connection>scm:git:git://github.com/netty/netty-incubator-codec-quic.git</connection>
    <developerConnection>scm:git:ssh://git@github.com/netty/netty-incubator-codec-quic.git</developerConnection>
    <tag>netty-incubator-codec-quic-0.0.5.Final</tag>
  </scm>

  <developers>
    <developer>
      <id>netty.io</id>
      <name>The Netty Project Contributors</name>
      <email>netty@googlegroups.com</email>
      <url>https://netty.io/</url>
      <organization>The Netty Project</organization>
      <organizationUrl>https://netty.io/</organizationUrl>
    </developer>
  </developers>

  <properties>
    <javaModuleName>io.netty.incubator.codec.quic</javaModuleName>
    <nativeSourceDirectory>${project.basedir}/src/main/c</nativeSourceDirectory>
    <nativeLibOnlyDir>${project.build.directory}/native-lib-only</nativeLibOnlyDir>
    <skipTests>false</skipTests>
    <netty.version>4.1.59.Final</netty.version>
    <netty.build.version>28</netty.build.version>
    <jni.classifier>${os.detected.name}-${os.detected.arch}</jni.classifier>
    <jniLibName>netty_quiche_${os.detected.name}_${os.detected.arch}</jniLibName>
    <jniUtilIncludeDir>${project.build.directory}/netty-jni-util/</jniUtilIncludeDir>
    <boringsslBranch>chromium-stable</boringsslBranch>
    <boringsslSourceDir>${project.build.directory}/boringssl-source</boringsslSourceDir>
    <boringsslBuildDir>${boringsslSourceDir}/build</boringsslBuildDir>
    <boringsslHomeDir>${project.build.directory}/boringssl</boringsslHomeDir>
    <boringsslHomeBuildDir>${boringsslHomeDir}/build</boringsslHomeBuildDir>
    <boringsslHomeIncludeDir>${boringsslHomeDir}/include</boringsslHomeIncludeDir>

    <!--
      See https://boringssl.googlesource.com/boringssl/+/refs/heads/chromium-stable for the latest commit
    -->
    <boringsslCommitSha>3743aafdacff2f7b083615a043a37101f740fa53</boringsslCommitSha>
    <quicheSourceDir>${project.build.directory}/quiche-source</quicheSourceDir>
    <quicheBuildDir>${quicheSourceDir}/target/release</quicheBuildDir>
    <quicheHomeDir>${project.build.directory}/quiche</quicheHomeDir>
    <quicheHomeBuildDir>${quicheHomeDir}/build</quicheHomeBuildDir>
    <quicheHomeIncludeDir>${quicheHomeDir}/include</quicheHomeIncludeDir>
    <quicheBranch>master</quicheBranch>
    <quicheCommitSha>5092e4d1e8ae2773a56eddda6a8205f5e65b4b37</quicheCommitSha>
    <generatedSourcesDir>${project.build.directory}/generated-sources</generatedSourcesDir>
    <templateDir>${project.build.directory}/template</templateDir>
    <cargoTarget />
    <cflags>-std=c99 -Werror -fno-omit-frame-pointer -fvisibility=hidden -Wunused -Wno-unused-value -O3 -I${quicheHomeIncludeDir} -I${boringsslHomeIncludeDir}</cflags>
    <ldflags>-L${quicheHomeBuildDir} -lquiche -L${boringsslHomeBuildDir} -lssl -lcrypto</ldflags>
    <extraCflags />
    <extraCxxflags />
    <extraLdflags />
    <extraConfigureArg />
    <!-- We need 10.12 as minimum to compile quiche and use it.
         Anything below will fail when trying to load quiche with:
         Symbol not found: ___isPlatformVersionAtLeast
    -->
    <macosxDeploymentTarget />
    <test.argLine>-D_</test.argLine>
    <bundleNativeCode />
  </properties>
  <profiles>
    <profile>
      <id>windows</id>
      <activation>
        <os>
          <family>windows</family>
        </os>
      </activation>
      <properties>
        <boringsslHomeBuildDir>${boringsslHomeDir}/build/RelWithDebInfo</boringsslHomeBuildDir>
        <quicheTarget>x86_64-pc-windows-msvc</quicheTarget>
        <cargoTarget>--target=${quicheTarget}</cargoTarget>
        <quicheBuildDir>${quicheSourceDir}/target/${quicheTarget}/release</quicheBuildDir>
        <cmakeAsmFlags />
        <!-- On Windows, build with /MT for static linking -->
        <cmakeCFlags>/MT</cmakeCFlags>
        <!-- Disable one warning to be able to build on windows -->
        <cmakeCxxFlags>/MT /wd4091</cmakeCxxFlags>
        <libssl>ssl.lib</libssl>
        <libcrypto>crypto.lib</libcrypto>
        <libquiche>quiche.lib</libquiche>
        <bundleNativeCode>META-INF/native/${jniLibName}.dll;osname=win32;processor=${os.detected.arch}</bundleNativeCode>
      </properties>
    </profile>
    <profile>
      <id>mac</id>
      <activation>
        <os>
          <family>mac</family>
        </os>
      </activation>
      <properties>
        <!--  We need 10.12 as minimum to compile quiche and use it.
              Anything below will fail when trying to load quiche with:
              Symbol not found: ___isPlatformVersionAtLeast
        -->
        <macosxDeploymentTarget>10.12</macosxDeploymentTarget>
        <extraCflags>-O3 -fno-omit-frame-pointer</extraCflags>
        <extraCxxflags>-O3 -fno-omit-frame-pointer</extraCxxflags>
        <!-- On *nix, add ASM flags to disable executable stack -->
        <cmakeAsmFlags>-Wa,--noexecstack</cmakeAsmFlags>
        <cmakeCFlags>${extraCflags} -DOPENSSL_C11_ATOMIC</cmakeCFlags>
        <!-- We need to define __STDC_CONSTANT_MACROS and __STDC_FORMAT_MACROS when building boringssl on centos 6 -->
        <cmakeCxxFlags>${extraCflags} -DOPENSSL_C11_ATOMIC -Wno-error=range-loop-analysis</cmakeCxxFlags>
        <libssl>libssl.a</libssl>
        <libcrypto>libcrypto.a</libcrypto>
        <libquiche>libquiche.a</libquiche>
        <extraLdflags>-Wl,-exported_symbol,_JNI_*</extraLdflags>
        <extraConfigureArg>MACOSX_DEPLOYMENT_TARGET=${macosxDeploymentTarget}</extraConfigureArg>
        <bundleNativeCode>META-INF/native/lib${jniLibName}.jnilib;osname=macos;osname=macosx;processor=${os.detected.arch}</bundleNativeCode>
      </properties>
    </profile>
    <profile>
      <id>linux</id>
      <activation>
        <os>
          <family>linux</family>
        </os>
      </activation>
      <properties>
        <extraCflags>-O3 -fno-omit-frame-pointer</extraCflags>
        <extraCxxflags>-O3 -fno-omit-frame-pointer</extraCxxflags>
        <!-- On *nix, add ASM flags to disable executable stack -->
        <cmakeAsmFlags>-Wa,--noexecstack</cmakeAsmFlags>
        <cmakeCFlags>${extraCflags} -DOPENSSL_C11_ATOMIC</cmakeCFlags>
        <!-- We need to define __STDC_CONSTANT_MACROS and __STDC_FORMAT_MACROS when building boringssl on centos 6 -->
        <cmakeCxxFlags>${extraCxxflags} -DOPENSSL_C11_ATOMIC -Wno-error=maybe-uninitialized -Wno-error=shadow -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS</cmakeCxxFlags>
        <libssl>libssl.a</libssl>
        <libcrypto>libcrypto.a</libcrypto>
        <libquiche>libquiche.a</libquiche>
        <extraLdflags>-Wl,--strip-debug -Wl,--exclude-libs,ALL -lrt</extraLdflags>
        <bundleNativeCode>META-INF/native/lib${jniLibName}.so;osname=linux;processor=${os.detected.arch}</bundleNativeCode>
      </properties>
    </profile>
    <profile>
      <id>leak</id>
      <properties>
        <test.argLine>-Dio.netty.leakDetectionLevel=paranoid -Dio.netty.leakDetection.targetRecords=32</test.argLine>
      </properties>
    </profile>
  </profiles>

  <build>
    <extensions>
      <extension>
        <groupId>kr.motd.maven</groupId>
        <artifactId>os-maven-plugin</artifactId>
        <version>1.7.0</version>
      </extension>
    </extensions>
    <plugins>
      <!-- Also include c files in source jar -->
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <version>3.2.0</version>
        <executions>
          <execution>
            <phase>generate-sources</phase>
            <goals>
              <goal>add-source</goal>
            </goals>
            <configuration>
              <sources>
                <source>${nativeSourceDirectory}</source>
              </sources>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <version>3.1.2</version>
        <executions>
          <!-- unpack netty-jni-util files -->
          <execution>
            <id>unpack</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>unpack-dependencies</goal>
            </goals>
            <configuration>
              <includeGroupIds>io.netty</includeGroupIds>
              <includeArtifactIds>netty-jni-util</includeArtifactIds>
              <classifier>sources</classifier>
              <outputDirectory>${jniUtilIncludeDir}</outputDirectory>
              <includes>**.h,**.c</includes>
              <overWriteReleases>false</overWriteReleases>
              <overWriteSnapshots>true</overWriteSnapshots>
            </configuration>
          </execution>
        </executions>
      </plugin>
    <plugin>
      <artifactId>maven-antrun-plugin</artifactId>
      <version>1.8</version>
      <dependencies>
        <dependency>
          <groupId>org.apache.ant</groupId>
          <artifactId>ant</artifactId>
          <version>1.10.9</version>
        </dependency>
        <dependency>
          <groupId>org.apache.ant</groupId>
          <artifactId>ant-commons-net</artifactId>
          <version>1.9.6</version>
        </dependency>
        <dependency>
          <groupId>ant-contrib</groupId>
          <artifactId>ant-contrib</artifactId>
          <version>1.0b3</version>
        </dependency>
      </dependencies>
      <executions>

        <!-- Build the BoringSSL static libs -->
        <execution>
          <id>build-boringssl</id>
          <phase>generate-sources</phase>
          <goals>
            <goal>run</goal>
          </goals>
          <configuration>
            <target>
              <!-- Add the ant tasks from ant-contrib -->
              <taskdef resource="net/sf/antcontrib/antcontrib.properties" />
              <property environment="env" />
              <if>
                <available file="${boringsslHomeDir}" />
                <then>
                  <echo message="BoringSSL was already build, skipping the build step." />
                </then>
                <else>
                  <if>
                    <available file="${boringsslSourceDir}" />
                    <then>
                      <echo message="BoringSSL was already cloned, skipping the clone step." />
                    </then>
                    <else>
                      <echo message="Clone BoringSSL" />

                      <exec executable="git" failonerror="true" dir="${project.build.directory}" resolveexecutable="true">
                        <arg value="clone" />
                        <arg value="--branch" />
                        <arg value="${boringsslBranch}" />
                        <arg value="https://boringssl.googlesource.com/boringssl" />
                        <arg value="${boringsslSourceDir}" />
                      </exec>
                    </else>
                  </if>

                  <echo message="Building BoringSSL" />

                  <!-- Use the known SHA of the commit -->
                  <exec executable="git" failonerror="true" dir="${boringsslSourceDir}" resolveexecutable="true">
                    <arg value="checkout" />
                    <arg value="${boringsslCommitSha}" />
                  </exec>

                  <mkdir dir="${boringsslBuildDir}" />
                  <exec executable="cmake" failonerror="true" dir="${boringsslBuildDir}" resolveexecutable="true">
                    <env key="MACOSX_DEPLOYMENT_TARGET" value="${macosxDeploymentTarget}" />
                    <arg value="-DCMAKE_POSITION_INDEPENDENT_CODE=TRUE" />
                    <arg value="-DCMAKE_BUILD_TYPE=Release" />
                    <arg value="-DCMAKE_ASM_FLAGS=${cmakeAsmFlags}" />
                    <arg value="-DCMAKE_C_FLAGS_RELEASE=${cmakeCFlags}" />
                    <arg value="-DCMAKE_CXX_FLAGS_RELEASE=${cmakeCxxFlags}" />
                    <arg value="-GNinja" />
                    <arg value="${boringsslSourceDir}" />
                  </exec>
                  <if>
                    <!-- may be called ninja-build or ninja -->
                    <!-- See https://github.com/netty/netty-tcnative/issues/475 -->
                    <available file="ninja-build" filepath="${env.PATH}" />
                    <then>
                      <property name="ninjaExecutable" value="ninja-build" />
                    </then>
                    <else>
                      <property name="ninjaExecutable" value="ninja" />
                    </else>
                  </if>
                  <exec executable="${ninjaExecutable}" failonerror="true" dir="${boringsslBuildDir}" resolveexecutable="true">
                    <arg value="crypto" />
                    <arg value="ssl" />
                  </exec>

                  <!-- Only copy the libs and header files we need -->
                  <mkdir dir="${boringsslHomeBuildDir}" />
                  <copy file="${boringsslBuildDir}/ssl/${libssl}" todir="${boringsslHomeBuildDir}" verbose="true" />
                  <copy file="${boringsslBuildDir}/crypto/${libcrypto}" todir="${boringsslHomeBuildDir}" verbose="true" />
                  <copy todir="${boringsslHomeIncludeDir}" verbose="true">
                    <fileset dir="${boringsslSourceDir}/include" />
                  </copy>
                </else>
              </if>
            </target>
          </configuration>
        </execution>
        <!-- Build the Quiche static lib -->
        <execution>
          <id>build-quiche</id>
          <phase>generate-sources</phase>
          <goals>
             <goal>run</goal>
          </goals>
          <configuration>
            <target>
              <!-- Add the ant tasks from ant-contrib -->
              <taskdef resource="net/sf/antcontrib/antcontrib.properties" />
              <property environment="env" />
              <if>
                <available file="${quicheHomeDir}" />
                <then>
                  <echo message="Quiche was already build, skipping the build step." />
                </then>

                <else>
                  <if>
                    <available file="${quicheSourceDir}" />
                    <then>
                      <echo message="Quiche was already cloned, skipping the clone step." />
                    </then>
                    <else>
                      <echo message="Clone Quiche" />

                      <exec executable="git" failonerror="true" dir="${project.build.directory}" resolveexecutable="true">
                        <arg value="clone" />
                        <arg value="--recursive" />
                        <arg value="--branch" />
                        <arg value="${quicheBranch}" />
                        <arg value="https://github.com/cloudflare/quiche" />
                        <arg value="${quicheSourceDir}" />
                      </exec>

                      <!-- Use the known SHA of the commit -->
                      <exec executable="git" failonerror="true" dir="${quicheSourceDir}" resolveexecutable="true">
                        <arg value="checkout" />
                        <arg value="${quicheCommitSha}" />
                      </exec>
                    </else>
                  </if>
                  <echo message="Building Quiche" />
                  <if>
                    <equals arg1="${os.detected.name}" arg2="windows" />
                    <then>
                      <exec executable="cargo" failonerror="true" dir="${quicheSourceDir}" resolveexecutable="true">
                        <arg value="build" />
                        <arg value="--features" />
                        <arg value="ffi" />
                        <arg value="--release" />
                        <arg value="${cargoTarget}" />
                        <!-- See https://github.com/cloudflare/quiche/blob/0.7.0/src/build.rs#L73 -->
                        <env key="DEBUG" value="true" />
                        <env key="OPT_LEVEL" value="3" />
                        <env key="QUICHE_BSSL_PATH" value="${boringsslHomeDir}/" />
                      </exec>
                   </then>
                    <else>
                      <exec executable="cargo" failonerror="true" dir="${quicheSourceDir}" resolveexecutable="true">
                        <arg value="build" />
                        <arg value="--features" />
                        <arg value="ffi" />
                        <arg value="--release" />
                        <env key="CFLAGS" value="${extraCflags}" />
                        <env key="CXXFLAGS" value="${extraCxxflags}" />
                        <env key="QUICHE_BSSL_PATH" value="${boringsslHomeDir}/" />
                      </exec>
                    </else>
                  </if>
                  <!-- Only copy the libs and header files we need -->
                  <mkdir dir="${quicheHomeDir}" />
                  <copy file="${quicheBuildDir}/${libquiche}" todir="${quicheHomeBuildDir}/" />
                  <copy todir="${quicheHomeIncludeDir}">
                    <fileset dir="${quicheSourceDir}/include" />
                  </copy>
                </else>
              </if>
            </target>
          </configuration>
        </execution>
        <execution>
          <id>copy-src</id>
          <phase>generate-sources</phase>
          <goals>
            <goal>run</goal>
          </goals>
          <configuration>
            <target>
              <!-- Copy all of the c code -->
              <delete dir="${generatedSourcesDir}" quiet="true" />
              <copy todir="${generatedSourcesDir}/c">
                <fileset dir="${project.basedir}/src/main/c" />
              </copy>

              <copy todir="${generatedSourcesDir}/c">
                <fileset dir="${jniUtilIncludeDir}" />
              </copy>
            </target>
          </configuration>
        </execution>

        <execution>
          <!-- Adjust our template and copy it over so it can be used when compiling on windows -->
          <id>setup-template</id>
          <phase>generate-sources</phase>
          <goals>
            <goal>run</goal>
          </goals>
          <configuration>
            <target>
              <!-- Add the ant tasks from ant-contrib -->
              <taskdef resource="net/sf/antcontrib/antcontrib.properties" />
              <property environment="env" />
              <!-- Convert the paths to windows format -->
              <pathconvert property="boringsslHomeIncludeWindowsDir" targetos="windows">
                <path location="${boringsslHomeIncludeDir}" />
              </pathconvert>
              <pathconvert property="quicheHomeIncludeWindowsDir" targetos="windows">
                <path location="${quicheHomeIncludeDir}" />
              </pathconvert>
              <pathconvert property="boringsslHomeBuildWindowsDir" targetos="windows">
                <path location="${boringsslHomeBuildDir}" />
              </pathconvert>
              <pathconvert property="quicheHomeBuildWindowsDir" targetos="windows">
                <path location="${quicheHomeBuildDir}" />
              </pathconvert>

              <!-- Copy and filter the template MSVC project -->
              <filter token="BORINGSSL_INCLUDE_DIR" value="${boringsslHomeIncludeWindowsDir}" />
              <filter token="QUICHE_INCLUDE_DIR" value="${quicheHomeIncludeWindowsDir}" />
              <filter token="BORINGSSL_LIB_DIR" value="${boringsslHomeBuildWindowsDir}" />
              <filter token="QUICHE_LIB_DIR" value="${quicheHomeBuildWindowsDir}" />
              <filter token="QUICHE_LIB" value="${libquiche}" />
              <filter token="CRYPTO_LIB" value="${libcrypto}" />
              <filter token="SSL_LIB" value="${libssl}" />

              <copy file="src/main/native-package/vs2010.custom.props.template" tofile="${templateDir}/vs2010.custom.props" filtering="true" overwrite="true" verbose="true" />
            </target>
          </configuration>
        </execution>

        <!-- Copy the native lib that was generated and the license material for attribution -->
        <execution>
          <id>copy-native-lib-and-license</id>
          <phase>process-test-resources</phase>
          <goals>
            <goal>run</goal>
          </goals>
          <configuration>
            <target>
              <!-- Add the ant tasks from ant-contrib -->
              <taskdef resource="net/sf/antcontrib/antcontrib.properties" />

              <copy todir="${project.build.outputDirectory}" includeEmptyDirs="false">
                <zipfileset dir="${nativeLibOnlyDir}/META-INF/native" />
                <regexpmapper handledirsep="yes" from="^(?:[^/]+/)*([^/]+)$" to="META-INF/native/\1" />
              </copy>

              <!-- Copy license material for attribution-->
              <copy file="NOTICE.txt" todir="${project.build.outputDirectory}/META-INF/" />
              <copy file="LICENSE.txt" todir="${project.build.outputDirectory}/META-INF/" />
              <copy todir="${project.build.outputDirectory}/META-INF/license">
                <fileset dir="license" />
              </copy>

            </target>
          </configuration>
        </execution>
      </executions>
    </plugin>
    <plugin>
      <artifactId>maven-compiler-plugin</artifactId>
      <version>3.8.0</version>
      <configuration>
        <compilerVersion>1.8</compilerVersion>
        <fork>true</fork>
        <source>1.8</source>
        <target>1.8</target>
        <debug>true</debug>
        <optimize>true</optimize>
        <showDeprecation>true</showDeprecation>
        <showWarnings>true</showWarnings>
        <compilerArgument>-Xlint:-options</compilerArgument>
        <meminitial>256m</meminitial>
        <maxmem>1024m</maxmem>
        <excludes>
          <exclude>**/package-info.java</exclude>
        </excludes>
      </configuration>
    </plugin>
    <plugin>
      <artifactId>maven-checkstyle-plugin</artifactId>
      <version>3.1.0</version>
      <executions>
        <execution>
          <id>check-style</id>
          <goals>
            <goal>check</goal>
          </goals>
          <phase>validate</phase>
          <configuration>
            <consoleOutput>true</consoleOutput>
            <logViolationsToConsole>true</logViolationsToConsole>
            <failsOnError>true</failsOnError>
            <failOnViolation>true</failOnViolation>
            <configLocation>io/netty/checkstyle.xml</configLocation>
            <sourceDirectories>
              <sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
              <sourceDirectory>${project.build.testSourceDirectory}</sourceDirectory>
            </sourceDirectories>
          </configuration>
          <inherited>false</inherited>
        </execution>
      </executions>
      <dependencies>
        <dependency>
          <groupId>com.puppycrawl.tools</groupId>
          <artifactId>checkstyle</artifactId>
          <version>8.29</version>
        </dependency>
        <dependency>
          <groupId>io.netty</groupId>
          <artifactId>netty-build-common</artifactId>
          <version>${netty.build.version}</version>
        </dependency>
      </dependencies>
    </plugin>
    <plugin>
      <artifactId>maven-surefire-plugin</artifactId>
      <version>2.22.1</version>
      <configuration>
        <includes>
          <include>**/*Test*.java</include>
        </includes>
        <excludes>
          <exclude>**/Abstract*</exclude>
        </excludes>
        <runOrder>random</runOrder>
        <systemPropertyVariables>
          <logback.configurationFile>src/test/resources/logback-test.xml</logback.configurationFile>
          <logLevel>info</logLevel>
        </systemPropertyVariables>
        <properties>
          <property>
            <name>listener</name>
            <value>io.netty.build.junit.TimedOutTestsListener</value>
          </property>
        </properties>
        <!-- Ensure the whole stacktrace is preserved when an exception is thrown. See https://issues.apache.org/jira/browse/SUREFIRE-1457 -->
        <trimStackTrace>false</trimStackTrace>
        <argLine>${test.argLine}</argLine>
      </configuration>
      <dependencies>
        <dependency>
          <groupId>org.apache.maven.surefire</groupId>
          <artifactId>surefire-junit4</artifactId>
          <version>2.22.1</version>
        </dependency>
      </dependencies>
    </plugin>
    <!-- always produce osgi bundles -->
    <plugin>
      <groupId>org.apache.felix</groupId>
      <artifactId>maven-bundle-plugin</artifactId>
      <version>2.5.4</version>
      <executions>
        <execution>
          <id>generate-manifest</id>
          <phase>process-classes</phase>
          <goals>
            <goal>manifest</goal>
          </goals>
          <configuration>
            <supportedProjectTypes>
              <supportedProjectType>jar</supportedProjectType>
              <supportedProjectType>bundle</supportedProjectType>
            </supportedProjectTypes>
            <instructions>
              <Export-Package>${project.groupId}.*</Export-Package>
              <Bundle-NativeCode>${bundleNativeCode}</Bundle-NativeCode>
              <BoringSSL-Revision>${boringsslCommitSha}</BoringSSL-Revision>
              <BoringSSL-Branch>${boringsslBranch}</BoringSSL-Branch>
              <Quiche-Revision>${quicheCommitSha}</Quiche-Revision>
              <Quiche-Branch>${quicheBranch}</Quiche-Branch>
            </instructions>
          </configuration>
        </execution>
      </executions>
    </plugin>

    <plugin>
      <artifactId>maven-source-plugin</artifactId>
      <version>3.2.0</version>
      <!-- Eclipse-related OSGi manifests
            See https://github.com/netty/netty/issues/3886
            More information: https://rajakannappan.blogspot.ie/2010/03/automating-eclipse-source-bundle.html -->
      <configuration>
        <archive>
          <manifestEntries>
            <Bundle-ManifestVersion>2</Bundle-ManifestVersion>
            <Bundle-Name>${project.name}</Bundle-Name>
            <Bundle-SymbolicName>${project.groupId}.${project.artifactId}.source</Bundle-SymbolicName>
            <Bundle-Vendor>${project.organization.name}</Bundle-Vendor>
            <Bundle-Version>${parsedVersion.osgiVersion}</Bundle-Version>
            <Eclipse-SourceBundle>${project.groupId}.${project.artifactId};version="${parsedVersion.osgiVersion}";roots:="."</Eclipse-SourceBundle>
          </manifestEntries>
        </archive>
      </configuration>

      <executions>
        <execution>
          <id>attach-sources</id>
          <phase>prepare-package</phase>
          <goals>
            <goal>jar-no-fork</goal>
          </goals>
        </execution>
        <execution>
          <id>attach-test-sources</id>
          <phase>prepare-package</phase>
          <goals>
            <goal>test-jar-no-fork</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
    <plugin>
      <artifactId>maven-javadoc-plugin</artifactId>
      <version>2.10.4</version>
      <configuration>
        <detectOfflineLinks>false</detectOfflineLinks>
        <breakiterator>true</breakiterator>
        <version>false</version>
        <author>false</author>
        <keywords>true</keywords>
        <source>8</source>
      </configuration>
    </plugin>
    <plugin>
      <artifactId>maven-deploy-plugin</artifactId>
      <version>2.8.2</version>
      <configuration>
        <retryFailedDeploymentCount>10</retryFailedDeploymentCount>
      </configuration>
    </plugin>
    <plugin>
      <artifactId>maven-release-plugin</artifactId>
      <version>2.5.3</version>
      <configuration>
        <useReleaseProfile>false</useReleaseProfile>
        <arguments>-P restricted-release,sonatype-oss-release,full</arguments>
        <autoVersionSubmodules>true</autoVersionSubmodules>
        <allowTimestampedSnapshots>false</allowTimestampedSnapshots>
        <tagNameFormat>${project.artifactId}-@{project.version}</tagNameFormat>
      </configuration>
      <dependencies>
        <dependency>
          <groupId>org.apache.maven.scm</groupId>
          <artifactId>maven-scm-api</artifactId>
          <version>1.9.4</version>
        </dependency>
        <dependency>
          <groupId>org.apache.maven.scm</groupId>
          <artifactId>maven-scm-provider-gitexe</artifactId>
          <version>1.9.4</version>
        </dependency>
      </dependencies>
      </plugin>
      <plugin>
        <groupId>org.fusesource.hawtjni</groupId>
        <artifactId>hawtjni-maven-plugin</artifactId>
        <version>1.18</version>
        <executions>
          <execution>
            <id>build-native-lib</id>
            <configuration>
              <name>${jniLibName}</name>
              <nativeSourceDirectory>${generatedSourcesDir}</nativeSourceDirectory>
              <customPackageDirectory>${templateDir}</customPackageDirectory>
              <windowsBuildTool>msbuild</windowsBuildTool>
              <windowsCustomProps>true</windowsCustomProps>
              <windowsPlatformToolset>v140</windowsPlatformToolset>
              <libDirectory>${nativeLibOnlyDir}</libDirectory>
              <configureArgs>
                <configureArg>${extraConfigureArg}</configureArg>
                <configureArg>CFLAGS=${cflags}</configureArg>
                <configureArg>LDFLAGS=${ldflags} ${extraLdflags}</configureArg>
                <configureArg>--libdir=${project.build.directory}/native-build/target/lib</configureArg>
              </configureArgs>
            </configuration>
            <goals>
              <goal>generate</goal>
              <goal>build</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-jar-plugin</artifactId>
        <version>3.2.0</version>
        <executions>
          <execution>
            <id>default-jar</id>
            <configuration>
              <!-- Exclude native lib and attribution for the jar without classifier-->
              <excludes>
                <exclude>META-INF/native/**</exclude>
                <exclude>META-INF/license/**</exclude>
                <exclude>META-INF/NOTICE.txt</exclude>
                <exclude>META-INF/LICENSE.txt</exclude>
              </excludes>
            </configuration>
          </execution>
          <!-- Generate the JAR that contains the native library in it. -->
          <execution>
            <id>native-jar</id>
            <goals>
              <goal>jar</goal>
            </goals>
            <configuration>
              <archive>
                <manifest>
                  <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                </manifest>
                <manifestEntries>
                  <Automatic-Module-Name>${javaModuleName}</Automatic-Module-Name>
                </manifestEntries>
                <index>true</index>
                <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
              </archive>
              <classifier>${jni.classifier}</classifier>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <dependencies>
    <dependency>
      <groupId>io.netty</groupId>
      <artifactId>netty-jni-util</artifactId>
      <version>0.0.2.Final</version>
      <classifier>sources</classifier>
      <optional>true</optional>
    </dependency>
    <dependency>
      <groupId>io.netty</groupId>
      <artifactId>netty-common</artifactId>
      <version>${netty.version}</version>
    </dependency>
    <dependency>
      <groupId>io.netty</groupId>
      <artifactId>netty-buffer</artifactId>
      <version>${netty.version}</version>
    </dependency>
    <dependency>
      <groupId>io.netty</groupId>
      <artifactId>netty-codec</artifactId>
      <version>${netty.version}</version>
    </dependency>
    <dependency>
      <groupId>io.netty</groupId>
      <artifactId>netty-handler</artifactId>
      <version>${netty.version}</version>
    </dependency>
    <dependency>
      <groupId>io.netty</groupId>
      <artifactId>netty-transport</artifactId>
      <version>${netty.version}</version>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.13.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.hamcrest</groupId>
      <artifactId>hamcrest-library</artifactId>
      <version>1.3</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>io.netty</groupId>
      <artifactId>netty-build-common</artifactId>
      <version>${netty.build.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-classic</artifactId>
      <version>1.1.7</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.maven.surefire</groupId>
      <artifactId>surefire-junit4</artifactId>
      <version>2.22.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
</project>
