#!/usr/bin/make -f

export LC_ALL=C.UTF-8

%:
	dh $@ --with javahelper --with maven-repo-helper

override_jh_build:
	# Specifying 1.8 because we need default methods.
	jh_build --no-javadoc --javacopts="-source 1.8 -target 1.8"

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	# Running the tests manually in a temp folder. The classpath includes only
	# the built jar, the test sources and the jars of the test motor.
	# Two zip files inside the test sources, with data, have to be unzipped.
	SOURCEDIR=`pwd` && \
	        TESTDIR=`mktemp -d` && \
	        cp -r test/ $$TESTDIR && \
	        export CLASSPATH=$$TESTDIR/test:`readlink -f intervalstorej.jar`:/usr/share/java/testng.jar:/usr/share/java/jcommander.jar && \
	        cd $$TESTDIR && \
	        find test -name "*.java" | xargs javac -source 1.8 -target 1.8 && \
	        for F in $$(find test -name "*.zip"); do \
	                unzip $$F -d $${F%/*}; \
	        done && \
	        java org.testng.TestNG $$SOURCEDIR/debian/tests.xml
endif
