# Contributor: Stuart Cardall <developer@it-offshore.co.uk>
# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Stuart Cardall <developer@it-offshore.co.uk>
setvar pkgname = 'maven'
setvar pkgver = '3.5.0'
setvar _pkgname = ""$pkgname-${pkgver%%.*}""
setvar pkgrel = '0'
setvar pkgdesc = ""A Java project management and project comprehension tool.""
setvar url = ""http://maven.apache.org""
setvar arch = ""noarch""
setvar license = ""ASL-2.0""
setvar depends = ""openjdk8-jre""
setvar source = ""http://mirror.hosting90.cz/apache/$pkgname/$_pkgname/$pkgver/binaries/apache-$pkgname-$pkgver-bin.tar.gz""
setvar builddir = ""$srcdir/apache-$pkgname-$pkgver""

proc package {
	local m2_home="/usr/share/java/$_pkgname"
	local destdir="${pkgdir}${m2_home}"

	cd $builddir

	local dir; for dir in bin boot lib {
		mkdir -p -m755 "$destdir/$dir"
	}

	install -m644 -Dt "$destdir"/bin ./bin/*.conf || return 1
	install -m644 -Dt "$destdir"/boot ./boot/*.jar || return 1
	install -m644 -Dt "$destdir"/lib ./lib/*.jar || return 1
	cp -Rp ./conf "$destdir"/ || return 1

	mkdir -p "$pkgdir"/usr/bin || return 1

	local file; for file in mvn mvnDebug mvnyjp {
		install -m755 -Dt "$destdir"/bin ./bin/$file || return 1
		ln -sf "$m2_home"/bin/$file "$pkgdir"/usr/bin/$file || return 1
	}

	mkdir "$pkgdir"/etc || return 1
	cat > "$pkgdir"/etc/mavenrc <<< """
		M2_HOME="$m2_home"
		MAVEN_OPTS="'$'MAVEN_OPTS -Xmx512m"
"""
}

setvar sha512sums = ""d5a520ca8765ddbc86dca71249c602e2f798dedcc7430bc4979dd01918464c8dc69b694ec0dbbeeff6044179e1b98fce72af952663dd49503203d9742e328f3b  apache-maven-3.5.0-bin.tar.gz""