# Contributor: Roberto Oliveira <robertoguimaraes8@gmail.com>
# Maintainer: Patrycja Rosa <alpine@ptrcnull.me>
pkgname=gradle
pkgver=8.10
pkgrel=0
pkgdesc="Build tool with a focus on build automation and support for multi-language development"
url="https://gradle.org/"
arch="noarch"
options="!check"
license="Apache-2.0"
source="https://services.gradle.org/distributions/gradle-$pkgver-bin.zip"

# highest supported version in community
case "$CARCH" in
arm* | x86)
	depends="openjdk8"
	;;
*)
	depends="openjdk21"
	;;
esac

# secfixes:
#   7.6.1-r0:
#     - CVE-2023-26053
#   7.2-r0:
#     - CVE-2021-32751
#   6.8.3-r0:
#     - CVE-2020-11979

package() {
	local gradlehome="/usr/share/java/$pkgname"
	local destdir="$pkgdir/$gradlehome"

	install -dm755 "$destdir"/bin
	rm bin/*.bat
	install -m755 bin/* "$destdir"/bin

	install -dm755 "$pkgdir"/usr/bin
	ln -sf $gradlehome/bin/gradle "$pkgdir"/usr/bin/gradle

	install -dm755 "$destdir"/lib
	cp -a lib "$destdir"/

	# NOTICE file should be redistributed for derivative works
	local file; for file in LICENSE NOTICE; do
		install -m644 -D $file "$pkgdir"/usr/share/licenses/$pkgname/$file
	done
}

sha512sums="
1d54e3a9067e6caf50bdd50fad8a26a5d64bcfb30e216a93890690a1e749c6a0a624a2250e1afb854d44662f6b37176348b1c26085b4e7124dd8f7ae1fae3769  gradle-8.10-bin.zip
"
