#!/usr/bin/make -f

%:
	dh $@ --with javahelper

override_dh_auto_build:
	ant jars
	ant javadocs

override_dh_auto_test:
	ant test -Drunonly.install=true -Ddocs.notrequired=true -Djunit.present=true -Djava.awt.headless=true

get-orig-source:
	git clone --filter=blob:none --sparse --single-branch --branch master \
	    https://github.com/Starlink/starjava \
            starjava-repo
	cd starjava-repo; \
	TAG=`git tag --list topcat-\* --sort=creatordate |tail -1` ;\
	git switch --detach $$TAG ; \
	git sparse-checkout add topcat
	mv starjava-repo/topcat starjava-topcat
	mv starjava-repo/LICENSE.txt starjava-topcat
	rm -rf starjava-repo
	VERSION=`xmllint --xpath '//project/property[@name="version"]/@value' starjava-topcat/build.xml | cut -d\" -f2| tr - .| tr  - . | tr -d +` ; \
	rm -rf starjava-topcat/src/lib/* starjava-topcat/src/docs/*.jar ; \
	rm -rf starjava-topcat/src/testlib/*.jar ; \
	tar cf starjava-topcat_$$VERSION.orig.tar starjava-topcat ; \
	rm -rf starjava-topcat ; \
	xz starjava-topcat_$$VERSION.orig.tar
