# Copyright 1999-2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

MAVEN_ID="ai.h2o:h2o-jetty-9:${PV}"

JAVA_PKG_IUSE="doc source test binary"
JAVA_TESTING_FRAMEWORKS="pkgdiff"

inherit java-pkg-2 java-pkg-simple

MY_PN="h2o-jetty-9"
MY_P="${MY_PN}-${PV}"

DESCRIPTION="H2O Jetty 9"
HOMEPAGE="https://www.h2o.ai/"
SRC_URI="
	https://github.com/h2oai/h2o-3/archive/refs/tags/jenkins-${PV}.tar.gz -> h2o-${PV}.tar.gz
	https://repo1.maven.org/maven2/ai/h2o/${MY_PN}/${PV}/${MY_P}.jar -> ${P}-bin.jar
"
LICENSE="Apache-2.0"
SLOT="$(ver_cut 1-2)"
KEYWORDS="~amd64"

# Bundled class originally from Jetty 9 included and should be removed,
# which makes the produced JAR's content differ from the pre-built one
RESTRICT="test"

CP_DEPEND="
	~dev-java/h2o-webserver-iface-${PV}:${SLOT}
	dev-java/jetty-jaas:9
	dev-java/jetty-proxy:9
	dev-java/jetty-server:9
	dev-java/jetty-servlet:9
	dev-java/jetty-servlets:9
	dev-java/websocket-api:9
	dev-java/websocket-server:9
"

BDEPEND="
	app-arch/unzip
"

DEPEND="
	>=virtual/jdk-1.8:*
	!binary? (
		${CP_DEPEND}
	)
"

RDEPEND="
	>=virtual/jre-1.8:*
	${CP_DEPEND}
"

S="${WORKDIR}/h2o-3-jenkins-${PV}/${MY_PN}"

JAVA_RESOURCE_DIRS="src/main/resources"
JAVA_SRC_DIR="src/main/java"
JAVA_BINJAR_FILENAME="${P}-bin.jar"

JAVA_TEST_SRC_DIR="skip-junit-tests-due-to-unpackaged-test-deps"

JAVA_RM_FILES=(
	# Removed bundled class from Jetty
	"${JAVA_SRC_DIR}/org/eclipse/jetty/server/Response.java"
)