# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=java-netty-transport-native
_jarname=netty-transport-native-epoll
pkgver=4.1.115
_pkgver="$pkgver.Final"
pkgrel=0
pkgdesc="Native Netty transport for Linux"
url="https://netty.io"
# armhf,armv7,loongarch64,ppc64le,riscv64,s390x,x86: fails to build due to missing JAR
arch="all !armhf !armv7 !loongarch64 !ppc64le !riscv64 !s390x !x86"
license="Apache-2.0"
depends="java-jre-headless"
makedepends="
	autoconf
	automake
	java-jdk
	libtool
	linux-headers
	maven
	"
source="https://github.com/netty/netty/archive/netty-$_pkgver/netty-$pkgver.tar.gz"
builddir="$srcdir/netty-netty-$_pkgver/transport-native-epoll"
# net: fetches dependencies from Maven repos
# !check: EpollDatagramUnicast tests fail (TODO)
options="net !check"

# NOTE: Maven 3 dropped support for the M2_HOME variable.
export MAVEN_ARGS="--batch-mode -Dcheckstyle.skip=true -Duser.home=$srcdir/.home"

build() {
	export CFLAGS="${CFLAGS/-Os/-O2}"
	export CPPFLAGS="${CPPFLAGS/-Os/-O2}"

	mvn package -DskipTests
}

check() {
	mvn test
}

# NOTE: netty-transport-native-epoll contains only the binary, classes
#   are in a separate package (JAR) transport-classes-epoll. It first attempts
#   to load the binary from the 'java.library.path' (/usr/lib).
package() {
	mkdir -p "$pkgdir"/usr/lib
	cp -P target/native-build/target/lib/*.so "$pkgdir"/usr/lib/
}

sha512sums="
8bb9e0bb0eb3f25f9ad84644ea85fb90631b0828dc92968f2206a1e2c69cb44041fd1fa7d7fecf0f419f534ea878eb811efc85ceb85a8ace2bfbc0c3c6b9a6f2  netty-4.1.115.tar.gz
"
