# Template file for 'freecol'
pkgname=freecol
version=1.2.0
revision=1
hostmakedepends="openjdk11 apache-ant tar"
depends="virtual?java-runtime"
short_desc="Free Colonization clone"
maintainer="Vincent Legoll <vincent.legoll@gmail.com>"
license="GPL-2.0-only"
homepage="https://www.freecol.org/"
distfiles="https://github.com/FreeCol/freecol/archive/refs/tags/v${version}.tar.gz"
checksum="21f5c0cddb885dc24756b4fb93728d53c4b20eb12fcad98757a66ec35b78710f"

do_build() {
	. /etc/profile
	# Pass version to avoid interactivity in "askReleaseVersion" target
	# Do not generate the pdf documentation
	ant -Dfreecol.version=${version} -Dprint.manual.is.up.to.date=true -Dprint.devmanual.is.up.to.date=true clean dist
}

do_install() {
	vmkdir usr/bin
	vmkdir usr/share/freecol

	# Do not use the supplied launch script:
	# But instead create one with the right classpath & data folder
	cat <<-EOF >freecol
		#!/bin/sh
		exec java -Xmx2G -cp '/usr/share/java/freecol/*' net.sf.freecol.FreeCol --freecol-data /usr/share/freecol/data
	EOF
	vbin freecol

	vinstall dist/base/freecol/freecol.xpm 644 usr/share/pixmaps
	vinstall dist/base/freecol/freecol.desktop 644 usr/share/applications

	cp -pHR dist/base/freecol/data ${DESTDIR}/usr/share/freecol

	for f in dist/base/freecol/FreeCol.jar dist/base/freecol/jars/*.jar; do
		vinstall $f 644 usr/share/java/freecol
	done
}
