<?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-transport-native-io_uring</artifactId>
  <version>0.0.8.Final</version>
  <name>Netty/Incubator/Transport/Native/io_uring</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-transport-io_uring</url>
    <connection>scm:git:git://github.com/netty/netty-incubator-transport-io_uring.git</connection>
    <developerConnection>scm:git:ssh://git@github.com/netty/netty-incubator-transport-io_uring.git</developerConnection>
    <tag>netty-incubator-transport-native-io_uring-0.0.8.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.transport.io_uring</javaModuleName>
    <unix.common.lib.name>netty-unix-common</unix.common.lib.name>
    <unix.common.lib.dir>${project.build.directory}/unix-common-lib</unix.common.lib.dir>
    <unix.common.lib.unpacked.dir>${unix.common.lib.dir}/META-INF/native/lib</unix.common.lib.unpacked.dir>
    <unix.common.include.unpacked.dir>${unix.common.lib.dir}/META-INF/native/include</unix.common.include.unpacked.dir>
    <jni.compiler.args.cflags>CFLAGS=-O3 -Werror -fno-omit-frame-pointer -Wunused-variable -fvisibility=hidden -I${unix.common.include.unpacked.dir}</jni.compiler.args.cflags>
    <jni.compiler.args.ldflags>LDFLAGS=-L${unix.common.lib.unpacked.dir} -Wl,--no-as-needed -lrt -ldl -Wl,--whole-archive -l${unix.common.lib.name} -Wl,--no-whole-archive</jni.compiler.args.ldflags>
    <nativeSourceDirectory>${project.basedir}/src/main/c</nativeSourceDirectory>
    <skipTests>true</skipTests>
    <netty.build.version>29</netty.build.version>
    <jniArch>${os.detected.arch}</jniArch>
    <jni.classifier>${os.detected.name}-${jniArch}</jni.classifier>
    <jniLibName>netty_transport_native_io_uring_${jniArch}</jniLibName>
    <nativeLibOnlyDir>${project.build.directory}/native-lib-only</nativeLibOnlyDir>
    <extraConfigureArg />
    <extraConfigureArg2 />
    <test.argLine>-D_</test.argLine>

    <checkstyle.version>8.38</checkstyle.version>
    <junit.version>4.13.1</junit.version>
    <netty.version>4.1.65.Final</netty.version>
    <netty-tcnative-boringssl-static.version>2.0.39.Final</netty-tcnative-boringssl-static.version>

    <build-helper-maven-plugin.version>3.2.0</build-helper-maven-plugin.version>
    <maven-bundle-plugin.version>5.1.1</maven-bundle-plugin.version>
    <maven-checkstyle-plugin.version>3.1.1</maven-checkstyle-plugin.version>
    <maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
    <maven-dependency-plugin.version>3.1.2</maven-dependency-plugin.version>
    <maven-enforcer-plugin.version>1.4.1</maven-enforcer-plugin.version>
    <hawtjni-maven-plugin.version>1.18</hawtjni-maven-plugin.version>
    <maven-jar-plugin.version>3.2.0</maven-jar-plugin.version>
    <maven-source-plugin.version>3.2.1</maven-source-plugin.version>
    <maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
    <os-maven-plugin.version>1.7.0</os-maven-plugin.version>
  </properties>

  <build>
    <extensions>
      <extension>
        <groupId>kr.motd.maven</groupId>
        <artifactId>os-maven-plugin</artifactId>
        <version>${os-maven-plugin.version}</version>
      </extension>
    </extensions>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-checkstyle-plugin</artifactId>
          <version>${maven-checkstyle-plugin.version}</version>
          <dependencies>
            <dependency>
              <groupId>com.puppycrawl.tools</groupId>
              <artifactId>checkstyle</artifactId>
              <version>${checkstyle.version}</version>
            </dependency>
            <dependency>
              <groupId>io.netty</groupId>
              <artifactId>netty-build-common</artifactId>
              <version>${netty.build.version}</version>
            </dependency>
          </dependencies>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>${maven-compiler-plugin.version}</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>
            <!-- XXX: maven-release-plugin complains - MRELEASE-715 -->
            <!--
            <compilerArguments>
              <Xlint:-options />
              <Xlint:unchecked />
              <Xlint:deprecation />
            </compilerArguments>
            -->
            <meminitial>256m</meminitial>
            <maxmem>1024m</maxmem>
            <excludes>
              <exclude>**/package-info.java</exclude>
            </excludes>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-dependency-plugin</artifactId>
          <version>${maven-dependency-plugin.version}</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-enforcer-plugin</artifactId>
          <version>${maven-enforcer-plugin.version}</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-jar-plugin</artifactId>
          <version>${maven-jar-plugin.version}</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>${maven-surefire-plugin.version}</version>
          <dependencies>
            <dependency>
              <groupId>org.apache.maven.surefire</groupId>
              <artifactId>surefire-junit4</artifactId>
              <version>${maven-surefire-plugin.version}</version>
            </dependency>
          </dependencies>
        </plugin>
        <plugin>
          <groupId>org.fusesource.hawtjni</groupId>
          <artifactId>hawtjni-maven-plugin</artifactId>
          <version>${hawtjni-maven-plugin.version}</version>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <!-- Also include c files in source jar -->
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <version>${build-helper-maven-plugin.version}</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-jar-plugin</artifactId>
        <executions>
          <!-- Generate the fallback JAR that does not contain the native library. -->
          <execution>
            <id>default-jar</id>
            <configuration>
              <excludes>
                <exclude>META-INF/native/**</exclude>
              </excludes>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-checkstyle-plugin</artifactId>
        <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>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <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>debug</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>
      </plugin>
      <!-- always produce osgi bundles -->
      <plugin>
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-bundle-plugin</artifactId>
        <version>${maven-bundle-plugin.version}</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>
                <!-- enforce JVM vendor package as optional -->
                <Import-Package>sun.misc.*;resolution:=optional,sun.nio.ch;resolution:=optional,sun.security.*;resolution:=optional</Import-Package>
                <!-- override "internal" private package convention -->
                <Private-Package>!*</Private-Package>
              </instructions>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-source-plugin</artifactId>
        <version>${maven-source-plugin.version}</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>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>3.2.0</version>
        <configuration>
          <detectOfflineLinks>false</detectOfflineLinks>
          <breakiterator>true</breakiterator>
          <version>false</version>
          <author>false</author>
          <keywords>true</keywords>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-deploy-plugin</artifactId>
        <version>2.8.2</version>
        <configuration>
          <retryFailedDeploymentCount>10</retryFailedDeploymentCount>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <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.11.2</version>
          </dependency>
          <dependency>
            <groupId>org.apache.maven.scm</groupId>
            <artifactId>maven-scm-provider-gitexe</artifactId>
            <version>1.11.2</version>
          </dependency>
        </dependencies>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <id>linux</id>
      <activation>
        <os>
          <family>linux</family>
        </os>
      </activation>
      <properties>
        <skipTests>false</skipTests>
      </properties>
      <build>
        <plugins>
          <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>
              <!-- Copy the native lib that was generated -->
              <execution>
                <id>copy-native-lib</id>
                <phase>process-test-resources</phase>
                <goals>
                  <goal>run</goal>
                </goals>
                <configuration>
                  <target>
                    <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>
                  </target>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
              <!-- unpack the unix-common static library and include files -->
              <execution>
                <id>unpack</id>
                <phase>generate-sources</phase>
                <goals>
                  <goal>unpack-dependencies</goal>
                </goals>
                <configuration>
                  <includeGroupIds>io.netty</includeGroupIds>
                  <includeArtifactIds>netty-transport-native-unix-common</includeArtifactIds>
                  <classifier>${jni.classifier}</classifier>
                  <outputDirectory>${unix.common.lib.dir}</outputDirectory>
                  <includes>META-INF/native/**</includes>
                  <overWriteReleases>false</overWriteReleases>
                  <overWriteSnapshots>true</overWriteSnapshots>
                </configuration>
              </execution>
            </executions>
          </plugin>

          <plugin>
            <groupId>org.fusesource.hawtjni</groupId>
            <artifactId>hawtjni-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>build-native-lib</id>
                <configuration>
                  <name>${jniLibName}</name>
                  <nativeSourceDirectory>${nativeSourceDirectory}</nativeSourceDirectory>
                  <libDirectory>${nativeLibOnlyDir}</libDirectory>
                  <configureArgs>
                    <arg>${jni.compiler.args.ldflags}</arg>
                    <arg>${jni.compiler.args.cflags}</arg>
                    <configureArg>--libdir=${project.build.directory}/native-build/target/lib</configureArg>
                    <configureArg>${extraConfigureArg}</configureArg>
                    <configureArg>${extraConfigureArg2}</configureArg>
                  </configureArgs>
                </configuration>
                <goals>
                  <goal>generate</goal>
                  <goal>build</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <executions>
              <!-- 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>
                      <Bundle-NativeCode>META-INF/native/libnetty_transport_native_io_uring_${jniArch}.so; osname=Linux; processor=${jniArch},*</Bundle-NativeCode>
                      <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-transport-native-unix-common</artifactId>
          <version>${netty.version}</version>
          <classifier>${jni.classifier}</classifier>
          <!--
            The unix-common with classifier dependency is optional because it is not a runtime dependency, but a build time
            dependency to get the static library which is built directly into the shared library generated by this project.
          -->
          <optional>true</optional>
        </dependency>
      </dependencies>
    </profile>
    <profile>
      <id>linux-aarch64</id>
      <properties>
        <!-- use aarch_64 as this is also what os.detected.arch will use on an aarch64 system -->
        <jniArch>aarch_64</jniArch>
        <!-- As we cross-compile just skip the tests because we could not load this lib on the system anyway -->
        <skipTests>true</skipTests>
        <extraConfigureArg>--host=aarch64-linux-gnu</extraConfigureArg>
        <extraConfigureArg2>CC=aarch64-none-linux-gnu-gcc</extraConfigureArg2>
      </properties>
    </profile>
    <profile>
      <id>leak</id>
      <properties>
        <test.argLine>-Dio.netty.leakDetectionLevel=paranoid -Dio.netty.leakDetection.targetRecords=32</test.argLine>
      </properties>
    </profile>
  </profiles>

  <dependencies>
    <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-transport</artifactId>
      <version>${netty.version}</version>
    </dependency>
    <dependency>
      <groupId>io.netty</groupId>
      <artifactId>netty-transport-native-unix-common</artifactId>
      <version>${netty.version}</version>
    </dependency>
    <dependency>
      <groupId>io.netty</groupId>
      <artifactId>netty-testsuite</artifactId>
      <version>${netty.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>${junit.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>io.netty</groupId>
      <artifactId>netty-transport-native-unix-common-tests</artifactId>
      <version>${netty.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>io.netty</groupId>
      <artifactId>netty-tcnative-boringssl-static</artifactId>
      <version>${netty-tcnative-boringssl-static.version}</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>org.apache.maven.surefire</groupId>
      <artifactId>surefire-junit4</artifactId>
      <version>${maven-surefire-plugin.version}</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
</project>
