#!/usr/bin/make -f
export GRADLE_USER_HOME=$(CURDIR)/.gradlehome
DEB_GRADLE_OPTS := --project-prop finalRelease=true --stacktrace --offline
VERSION := $(shell dpkg-parsechangelog | grep '^Version:' | cut -f 2 -d ' ' | sed 's/-[^-]*$$//')
%:
	dh $@ --with javahelper

override_dh_auto_build:
	mkdir $(CURDIR)/.gradlehome
	gradle $(DEB_GRADLE_OPTS) assemble
  
override_dh_auto_clean:
	dh_auto_clean
	-gradle $(DEB_GRADLE_OPTS) clean
	for dir in .gradle .gradlehome multiverse-core/build; do \
		rm -rf $(CURDIR)/$$dir; \
	done;
	mh_clean

override_dh_install:
	dh_install
	mh_installpom -plibmultiverse-core-java --no-parent multiverse-core/pom.xml
	mh_installjar -plibmultiverse-core-java -l multiverse-core/pom.xml \
		multiverse-core/build/libs/multiverse-core-$(VERSION).jar

get-orig-source:
	cd $(dir $(firstword $(MAKEFILE_LIST)))../ && \
	uscan \
		--verbose \
		--rename  \
		--no-symlink \
		--destdir $(CURDIR)      \
		--watchfile debian/watch \
		--force-download
